|
|
|
@ -1,21 +1,12 @@
|
|
|
|
|
package gui;
|
|
|
|
|
|
|
|
|
|
import static alg.XML_processing.*;
|
|
|
|
|
import static gui.GUIController.*;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
import alg.XML_processing;
|
|
|
|
|
import javafx.application.HostServices;
|
|
|
|
|
import javafx.beans.InvalidationListener;
|
|
|
|
|
import javafx.beans.Observable;
|
|
|
|
|
import javafx.beans.binding.StringBinding;
|
|
|
|
|
import javafx.beans.property.ReadOnlyDoubleWrapper;
|
|
|
|
|
import javafx.beans.value.ChangeListener;
|
|
|
|
|
import javafx.beans.value.ObservableValue;
|
|
|
|
|
import javafx.scene.image.ImageView;
|
|
|
|
@ -147,15 +138,6 @@ public class StringAnalysisTabNew2 {
|
|
|
|
|
@FXML
|
|
|
|
|
private CheckComboBox<String> taxonomyCCB;
|
|
|
|
|
private ArrayList<Taxonomy> taxonomy;
|
|
|
|
|
//
|
|
|
|
|
// @FXML
|
|
|
|
|
// private CheckBox calculatecvvCB;
|
|
|
|
|
// private boolean calculateCvv;
|
|
|
|
|
|
|
|
|
|
// @FXML
|
|
|
|
|
// private TextField stringLengthTF;
|
|
|
|
|
// private Integer stringLength;
|
|
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
|
private ComboBox<String> calculateForCB;
|
|
|
|
|
private CalculateFor calculateFor;
|
|
|
|
@ -225,8 +207,6 @@ public class StringAnalysisTabNew2 {
|
|
|
|
|
|
|
|
|
|
private Corpus corpus;
|
|
|
|
|
private HashMap<String, HashSet<String>> solarFiltersMap;
|
|
|
|
|
private Filter filter;
|
|
|
|
|
private boolean useDb;
|
|
|
|
|
private HostServices hostService;
|
|
|
|
|
private ListChangeListener<String> taxonomyListener;
|
|
|
|
|
private ListChangeListener<String> alsoVisualizeListener;
|
|
|
|
@ -236,44 +216,25 @@ public class StringAnalysisTabNew2 {
|
|
|
|
|
private ChangeListener<Boolean> minimalOccurrencesListener;
|
|
|
|
|
private ChangeListener<Boolean> minimalTaxonomyListener;
|
|
|
|
|
private ChangeListener<Boolean> minimalRelFreListener;
|
|
|
|
|
private boolean useDb;
|
|
|
|
|
|
|
|
|
|
// private static final ObservableList<String> N_GRAM_COMPUTE_FOR_WORDS = FXCollections.observableArrayList("lema", "različnica", "oblikoskladenjska oznaka");
|
|
|
|
|
// private static final ObservableList<String> N_GRAM_COMPUTE_FOR_LETTERS = FXCollections.observableArrayList("lema", "različnica");
|
|
|
|
|
// private static final ObservableList<String> N_GRAM_COMPUTE_FOR_WORDS_ORTH = FXCollections.observableArrayList("različnica");
|
|
|
|
|
// private static final ObservableList<String> N_GRAM_COMPUTE_FOR_WORDS_GOS = FXCollections.observableArrayList("lema", "različnica", "oblikoskladenjska oznaka", "normalizirana različnica");
|
|
|
|
|
// private static final ObservableList<String> alsoVisualizeItemsLemma = FXCollections.observableArrayList("besedna vrsta", "oblikoskladenjska oznaka");
|
|
|
|
|
// private static final ObservableList<String> alsoVisualizeItemsWord = FXCollections.observableArrayList("lema", "besedna vrsta", "oblikoskladenjska oznaka");
|
|
|
|
|
// private static final ObservableList<String> alsoVisualizeItemsWordGos = FXCollections.observableArrayList("lema", "besedna vrsta", "oblikoskladenjska oznaka", "normalizirana različnica");
|
|
|
|
|
// private static final ObservableList<String> alsoVisualizeItemsNormalizedWord = FXCollections.observableArrayList("lema", "besedna vrsta", "oblikoskladenjska oznaka");
|
|
|
|
|
// private static final ObservableList<String> alsoVisualizeItemsMsd = FXCollections.observableArrayList("besedna vrsta");
|
|
|
|
|
private static final ObservableList<String> COLLOCABILITY_ITEMS = FXCollections.observableArrayList("Dice", "t-score", "MI", "MI3", "logDice", "simple LL");
|
|
|
|
|
// private static final ObservableList<String> alsoVisualizeItemsEmpty = FXCollections.observableArrayList();
|
|
|
|
|
|
|
|
|
|
// private static final ObservableList<String> N_GRAM_COMPUTE_FOR_LETTERS = FXCollections.observableArrayList("lema", "različnica");
|
|
|
|
|
private static final String [] N_GRAM_COMPUTE_FOR_WORDS_ARRAY = {"calculateFor.WORD", "calculateFor.LOWERCASE_WORD", "calculateFor.LEMMA", "calculateFor.MORPHOSYNTACTIC_SPECS"};
|
|
|
|
|
private static final ArrayList<String> N_GRAM_COMPUTE_FOR_WORDS = new ArrayList<>(Arrays.asList(N_GRAM_COMPUTE_FOR_WORDS_ARRAY));
|
|
|
|
|
// private static final ObservableList<String> N_GRAM_COMPUTE_FOR_WORDS_ORTH = FXCollections.observableArrayList("različnica");
|
|
|
|
|
private static final String [] N_GRAM_COMPUTE_FOR_WORDS_ORTH_ARRAY = {"calculateFor.WORD", "calculateFor.LOWERCASE_WORD"};
|
|
|
|
|
private static final ArrayList<String> N_GRAM_COMPUTE_FOR_WORDS_ORTH = new ArrayList<>(Arrays.asList(N_GRAM_COMPUTE_FOR_WORDS_ORTH_ARRAY));
|
|
|
|
|
// private static final ObservableList<String> N_GRAM_COMPUTE_FOR_WORDS_GOS = FXCollections.observableArrayList("lema", "različnica", "normalizirana različnica");
|
|
|
|
|
private static final String [] N_GRAM_COMPUTE_FOR_WORDS_GOS_ARRAY = {"calculateFor.WORD", "calculateFor.LOWERCASE_WORD", "calculateFor.LEMMA", "calculateFor.MORPHOSYNTACTIC_SPECS", "calculateFor.NORMALIZED_WORD"};
|
|
|
|
|
private static final ArrayList<String> N_GRAM_COMPUTE_FOR_WORDS_GOS = new ArrayList<>(Arrays.asList(N_GRAM_COMPUTE_FOR_WORDS_GOS_ARRAY));
|
|
|
|
|
// private static final ObservableList<String> alsoVisualizeItemsLemma = FXCollections.observableArrayList("besedna vrsta", "oblikoskladenjska oznaka");
|
|
|
|
|
private static final String [] ALSO_VISUALIZE_ITEMS_LEMMA_ARRAY = {"calculateFor.WORD_TYPE", "calculateFor.MORPHOSYNTACTIC_SPECS"};
|
|
|
|
|
private static final ArrayList<String> ALSO_VISUALIZE_ITEMS_LEMMA = new ArrayList<>(Arrays.asList(ALSO_VISUALIZE_ITEMS_LEMMA_ARRAY));
|
|
|
|
|
// private static final ObservableList<String> alsoVisualizeItemsWord = FXCollections.observableArrayList("lema", "besedna vrsta", "oblikoskladenjska oznaka");
|
|
|
|
|
private static final String [] ALSO_VISUALIZE_ITEMS_WORDS_ARRAY = {"calculateFor.LEMMA", "calculateFor.WORD_TYPE", "calculateFor.MORPHOSYNTACTIC_SPECS"};
|
|
|
|
|
private static final ArrayList<String> ALSO_VISUALIZE_ITEMS_WORDS = new ArrayList<>(Arrays.asList(ALSO_VISUALIZE_ITEMS_WORDS_ARRAY));
|
|
|
|
|
// private static final ObservableList<String> alsoVisualizeItemsWordGos = FXCollections.observableArrayList("lema", "besedna vrsta", "oblikoskladenjska oznaka", "normalizirana različnica");
|
|
|
|
|
private static final String [] ALSO_VISUALIZE_ITEMS_WORDS_GOS_ARRAY = {"calculateFor.LEMMA", "calculateFor.WORD_TYPE", "calculateFor.MORPHOSYNTACTIC_SPECS", "calculateFor.NORMALIZED_WORD"};
|
|
|
|
|
private static final ArrayList<String> ALSO_VISUALIZE_ITEMS_WORDS_GOS = new ArrayList<>(Arrays.asList(ALSO_VISUALIZE_ITEMS_WORDS_GOS_ARRAY));
|
|
|
|
|
// private static final ObservableList<String> alsoVisualizeItemsNormalizedWord = FXCollections.observableArrayList("lema", "besedna vrsta", "oblikoskladenjska oznaka");
|
|
|
|
|
private static final String [] ALSO_VISUALIZE_ITEMS_NORMALIZED_WORDS_ARRAY = {"calculateFor.LEMMA", "calculateFor.WORD_TYPE", "calculateFor.MORPHOSYNTACTIC_SPECS"};
|
|
|
|
|
private static final ArrayList<String> ALSO_VISUALIZE_ITEMS_NORMALIZED_WORDS = new ArrayList<>(Arrays.asList(ALSO_VISUALIZE_ITEMS_NORMALIZED_WORDS_ARRAY));
|
|
|
|
|
// private static final ObservableList<String> alsoVisualizeItemsMsd = FXCollections.observableArrayList("besedna vrsta");
|
|
|
|
|
private static final String [] ALSO_VISUALIZE_ITEMS_MSD_ARRAY = {"calculateFor.WORD_TYPE"};
|
|
|
|
|
private static final ArrayList<String> ALSO_VISUALIZE_ITEMS_MSD = new ArrayList<>(Arrays.asList(ALSO_VISUALIZE_ITEMS_MSD_ARRAY));
|
|
|
|
|
// private static final ObservableList<String> alsoVisualizeItemsEmpty = FXCollections.observableArrayList();
|
|
|
|
|
private static final String [] ALSO_VISUALIZE_ITEMS_EMPTY_ARRAY = {};
|
|
|
|
|
private static final ArrayList<String> ALSO_VISUALIZE_ITEMS_EMPTY = new ArrayList<>(Arrays.asList(ALSO_VISUALIZE_ITEMS_EMPTY_ARRAY));
|
|
|
|
|
|
|
|
|
@ -282,9 +243,6 @@ public class StringAnalysisTabNew2 {
|
|
|
|
|
|
|
|
|
|
// TODO: pass observables for taxonomy based on header scan
|
|
|
|
|
// after header scan
|
|
|
|
|
private ObservableList<String> taxonomyCCBValues;
|
|
|
|
|
private CorpusType currentCorpusType;
|
|
|
|
|
|
|
|
|
|
public void init() {
|
|
|
|
|
// add CSS style
|
|
|
|
|
stringAnalysisTabPaneNew2.getStylesheets().add("style.css");
|
|
|
|
@ -420,13 +378,6 @@ public class StringAnalysisTabNew2 {
|
|
|
|
|
} else {
|
|
|
|
|
alsoVisualizeCCB.getItems().setAll(I18N.translatedObservableList(ALSO_VISUALIZE_ITEMS_EMPTY));
|
|
|
|
|
}
|
|
|
|
|
// alsoVisualizeCCB.getCheckModel().getCheckedItems().addListener((ListChangeListener<String>) c -> {
|
|
|
|
|
// alsoVisualize = new ArrayList<>();
|
|
|
|
|
// ObservableList<String> checkedItems = alsoVisualizeCCB.getCheckModel().getCheckedItems();
|
|
|
|
|
// alsoVisualize.addAll(checkedItems);
|
|
|
|
|
// logger.info(String.format("Selected also visualize items: %s", StringUtils.join(checkedItems, ",")));
|
|
|
|
|
// });
|
|
|
|
|
// alsoVisualizeCCB.getCheckModel().clearChecks();
|
|
|
|
|
|
|
|
|
|
alsoVisualizeListener = new ListChangeListener<String>() {
|
|
|
|
|
@Override
|
|
|
|
@ -437,9 +388,6 @@ public class StringAnalysisTabNew2 {
|
|
|
|
|
logger.info(String.format("Selected also visualize items: %s", StringUtils.join(checkedItems, ",")));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
// alsoVisualizeCCB.getCheckModel().clearChecks();
|
|
|
|
|
// alsoVisualizeCCB.getItems().removeAll();
|
|
|
|
|
// alsoVisualizeCCB.getItems().setAll(I18N.translatedObservableList(ALSO_VISUALIZE_ITEMS_WORDS));
|
|
|
|
|
|
|
|
|
|
alsoVisualizeCCB.getCheckModel().getCheckedItems().addListener(alsoVisualizeListener);
|
|
|
|
|
|
|
|
|
@ -500,16 +448,6 @@ public class StringAnalysisTabNew2 {
|
|
|
|
|
collocabilityCCB.setDisable(false);
|
|
|
|
|
|
|
|
|
|
collocabilityCCB.getCheckModel().getCheckedItems().addListener(collocabilityListener);
|
|
|
|
|
// collocabilityCCB.getCheckModel().getCheckedItems().addListener((ListChangeListener<String>) c -> {
|
|
|
|
|
// collocability = new ArrayList<>();
|
|
|
|
|
// ObservableList<Collocability> checkedItems = FXCollections.observableArrayList();
|
|
|
|
|
// for (String el : collocabilityCCB.getCheckModel().getCheckedItems()) {
|
|
|
|
|
// checkedItems.add(Collocability.factory(el));
|
|
|
|
|
// }
|
|
|
|
|
// collocability.addAll(checkedItems);
|
|
|
|
|
// logger.info(String.format("Selected collocabilities: %s", StringUtils.join(collocabilityCCB.getCheckModel().getCheckedItems(), ",")));
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// msd
|
|
|
|
|
if (msdListener != null){
|
|
|
|
@ -595,9 +533,6 @@ public class StringAnalysisTabNew2 {
|
|
|
|
|
public void onChanged(ListChangeListener.Change<? extends String> c){
|
|
|
|
|
if(changing) {
|
|
|
|
|
ObservableList<String> checkedItems = taxonomyCCB.getCheckModel().getCheckedItems();
|
|
|
|
|
// ArrayList<Taxonomy> checkedItemsTaxonomy = Taxonomy.convertStringListToTaxonomyList(checkedItems);
|
|
|
|
|
//
|
|
|
|
|
// Taxonomy.modifyingTaxonomy(taxonomy, checkedItemsTaxonomy, corpus);
|
|
|
|
|
ArrayList<Taxonomy> checkedItemsTaxonomy = Taxonomy.modifyingTaxonomy(taxonomy, checkedItems, corpus);
|
|
|
|
|
|
|
|
|
|
taxonomy = new ArrayList<>();
|
|
|
|
@ -606,7 +541,6 @@ public class StringAnalysisTabNew2 {
|
|
|
|
|
taxonomyCCB.getItems().removeAll();
|
|
|
|
|
taxonomyCCB.getItems().setAll(corpus.getObservableListTaxonomy());
|
|
|
|
|
|
|
|
|
|
// taxonomyCCB.getCheckModel().clearChecks();
|
|
|
|
|
changing = false;
|
|
|
|
|
taxonomyCCB.getCheckModel().clearChecks();
|
|
|
|
|
for (Taxonomy t : checkedItemsTaxonomy) {
|
|
|
|
@ -646,32 +580,6 @@ public class StringAnalysisTabNew2 {
|
|
|
|
|
skipValue = 0;
|
|
|
|
|
|
|
|
|
|
// cvv
|
|
|
|
|
// calculatecvvCB.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
|
|
|
|
// calculateCvv = newValue;
|
|
|
|
|
// logger.info("calculate cvv: " + calculateCvv);
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// calculatecvvCB.setSelected(false);
|
|
|
|
|
|
|
|
|
|
// string length
|
|
|
|
|
// stringLengthTF.focusedProperty().addListener((observable, oldValue, newValue) -> {
|
|
|
|
|
// if (!newValue) {
|
|
|
|
|
// // focus lost
|
|
|
|
|
// String value = stringLengthTF.getText();
|
|
|
|
|
// if (!ValidationUtil.isEmpty(value)) {
|
|
|
|
|
// if (!ValidationUtil.isNumber(value)) {
|
|
|
|
|
// logAlert("stringlengthTf: " + I18N.get("message.WARNING_ONLY_NUMBERS_ALLOWED"));
|
|
|
|
|
// GUIController.showAlert(Alert.AlertType.ERROR, I18N.get("message.WARNING_ONLY_NUMBERS_ALLOWED"));
|
|
|
|
|
// }
|
|
|
|
|
// stringLength = Integer.parseInt(value);
|
|
|
|
|
// } else {
|
|
|
|
|
// GUIController.showAlert(Alert.AlertType.ERROR, I18N.get("message.WARNING_MISSING_STRING_LENGTH"));
|
|
|
|
|
// stringLengthTF.setText("1");
|
|
|
|
|
// logAlert(I18N.get("message.WARNING_MISSING_STRING_LENGTH"));
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
minimalOccurrencesTF.setText("1");
|
|
|
|
|
minimalOccurrences = 1;
|
|
|
|
|
|
|
|
|
@ -781,108 +689,6 @@ public class StringAnalysisTabNew2 {
|
|
|
|
|
cancel.setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* case a: values for combo boxes can change after a corpus change
|
|
|
|
|
* <ul>
|
|
|
|
|
* <li>different corpus type - reset all fields so no old values remain</li>
|
|
|
|
|
* <li>same corpus type, different subset - keep</li>
|
|
|
|
|
* </ul>
|
|
|
|
|
* <p>
|
|
|
|
|
* case b: values for combo boxes can change after a header scan
|
|
|
|
|
* <ul>
|
|
|
|
|
* <li>at first, fields are populated by corpus type defaults</li>
|
|
|
|
|
* <li>after, with gathered data</li>
|
|
|
|
|
* </ul>
|
|
|
|
|
* <p></p>
|
|
|
|
|
* ngrams: 1
|
|
|
|
|
* calculateFor: word
|
|
|
|
|
* msd:
|
|
|
|
|
* taxonomy:
|
|
|
|
|
* skip: 0
|
|
|
|
|
* iscvv: false
|
|
|
|
|
* string length: 1
|
|
|
|
|
*/
|
|
|
|
|
// public void populateFields() {
|
|
|
|
|
// // corpus changed if: current one is null (this is first run of the app)
|
|
|
|
|
// // or if currentCorpus != gui's corpus
|
|
|
|
|
// boolean corpusChanged = currentCorpusType == null
|
|
|
|
|
// || currentCorpusType != corpus.getCorpusType();
|
|
|
|
|
//
|
|
|
|
|
// // keep ngram value if set
|
|
|
|
|
// if (ngramValue == null) {
|
|
|
|
|
// ngramValueCB.getSelectionModel().select("1");
|
|
|
|
|
// ngramValue = 1;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // TODO: check for GOS, GIGAFIDA, SOLAR...
|
|
|
|
|
// // refresh and:
|
|
|
|
|
// // TODO if current value != null && is in new calculateFor ? keep : otherwise reset
|
|
|
|
|
// if (calculateFor == null) {
|
|
|
|
|
// calculateForCB.getSelectionModel().select(calculateForCB.getItems().get(0));
|
|
|
|
|
// calculateFor = CalculateFor.factory(calculateForCB.getItems().get(0));
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (!filter.hasMsd()) {
|
|
|
|
|
// // if current corpus doesn't have msd data, disable this field
|
|
|
|
|
// msd = new ArrayList<>();
|
|
|
|
|
// msdTF.setText("");
|
|
|
|
|
// msdTF.setDisable(true);
|
|
|
|
|
// logger.info("no msd data");
|
|
|
|
|
// } else {
|
|
|
|
|
// if (ValidationUtil.isEmpty(msd)
|
|
|
|
|
// || (!ValidationUtil.isEmpty(msd) && corpusChanged)) {
|
|
|
|
|
// // msd has not been set previously
|
|
|
|
|
// // or msd has been set but the corpus changed -> reset
|
|
|
|
|
// msd = new ArrayList<>();
|
|
|
|
|
// msdTF.setText("");
|
|
|
|
|
// msdTF.setDisable(false);
|
|
|
|
|
// logger.info("msd reset");
|
|
|
|
|
// } else if (!ValidationUtil.isEmpty(msd) && !corpusChanged) {
|
|
|
|
|
// // if msd has been set, but corpus type remained the same, we can keep any set msd value
|
|
|
|
|
// msdTF.setText(StringUtils.join(msdStrings, " "));
|
|
|
|
|
// msdTF.setDisable(false);
|
|
|
|
|
// logger.info("msd kept");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // TODO: taxonomy: refresh and keep if in new taxonomy, otherwise empty (no selection)
|
|
|
|
|
//
|
|
|
|
|
// // keep skip value
|
|
|
|
|
// if (skipValue == null) {
|
|
|
|
|
// skipValueCB.getSelectionModel().select("0");
|
|
|
|
|
// skipValue = 0;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // keep calculateCvv
|
|
|
|
|
// calculatecvvCB.setSelected(calculateCvv);
|
|
|
|
|
//
|
|
|
|
|
// // keep string length if set
|
|
|
|
|
// if (stringLength != null) {
|
|
|
|
|
// stringLengthTF.setText(String.valueOf(stringLength));
|
|
|
|
|
// } else {
|
|
|
|
|
// stringLengthTF.setText("1");
|
|
|
|
|
// stringLength = 1;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // TODO: trigger on rescan
|
|
|
|
|
// if ((currentCorpusType != null && currentCorpusType != corpus.getCorpusType())) {
|
|
|
|
|
// // user changed corpus (by type) or by selection & triggered a rescan of headers
|
|
|
|
|
// // see if we read taxonomy from headers, otherwise use default values for given corpus
|
|
|
|
|
// ObservableList<String> tax = corpus.getObservableListTaxonomy();
|
|
|
|
|
// taxonomyCCBValues = tax != null ? tax : Taxonomy.getDefaultForComboBox(corpus.getCorpusType());
|
|
|
|
|
//
|
|
|
|
|
// currentCorpusType = corpus.getCorpusType();
|
|
|
|
|
// // setTaxonomyIsDirty(false);
|
|
|
|
|
// } else {
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // see if we read taxonomy from headers, otherwise use default values for given corpus
|
|
|
|
|
// ObservableList<String> tax = corpus.getObservableListTaxonomy();
|
|
|
|
|
// taxonomyCCBValues = tax != null ? tax : Taxonomy.getDefaultForComboBox(corpus.getCorpusType());
|
|
|
|
|
// taxonomyCCB.getItems().addAll(taxonomyCCBValues);
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
private void addTooltipToImage(ImageView image, StringBinding stringBinding){
|
|
|
|
|
Tooltip tooltip = new Tooltip();
|
|
|
|
|
tooltip.textProperty().bind(stringBinding);
|
|
|
|
@ -898,7 +704,6 @@ public class StringAnalysisTabNew2 {
|
|
|
|
|
calculateForL.textProperty().bind(I18N.createStringBinding("label.calculateFor"));
|
|
|
|
|
alsoVisualizeL.textProperty().bind(I18N.createStringBinding("label.alsoVisualize"));
|
|
|
|
|
displayTaxonomyL.textProperty().bind(I18N.createStringBinding("label.displayTaxonomy"));
|
|
|
|
|
// writeMsdAtTheEndL.textProperty().bind(I18N.createStringBinding("label.writeMsdAtTheEnd"));
|
|
|
|
|
skipValueL.textProperty().bind(I18N.createStringBinding("label.skipValue"));
|
|
|
|
|
slowSpeedWarning1L.textProperty().bind(I18N.createStringBinding("label.slowSpeedWarning"));
|
|
|
|
|
slowSpeedWarning2L.textProperty().bind(I18N.createStringBinding("label.slowSpeedWarning"));
|
|
|
|
@ -948,10 +753,6 @@ public class StringAnalysisTabNew2 {
|
|
|
|
|
|
|
|
|
|
if (mode == MODE.WORD) {
|
|
|
|
|
paneWords.setVisible(true);
|
|
|
|
|
// paneLetters.setVisible(false);
|
|
|
|
|
// if (corpus.getCorpusType() == CorpusType.GOS)
|
|
|
|
|
// calculateForCB.getItems().setAll(N_GRAM_COMPUTE_FOR_WORDS_GOS);
|
|
|
|
|
// else
|
|
|
|
|
if (corpus.getCorpusType() == CorpusType.GOS) {
|
|
|
|
|
calculateForCB.itemsProperty().unbind();
|
|
|
|
|
calculateForCB.itemsProperty().bind(I18N.createObjectBinding(N_GRAM_COMPUTE_FOR_WORDS_GOS));
|
|
|
|
@ -980,7 +781,6 @@ public class StringAnalysisTabNew2 {
|
|
|
|
|
filter.setDisplayTaxonomy(displayTaxonomy);
|
|
|
|
|
filter.setAl(AnalysisLevel.STRING_LEVEL);
|
|
|
|
|
filter.setSkipValue(skipValue);
|
|
|
|
|
// filter.setIsCvv(calculateCvv);
|
|
|
|
|
filter.setSolarFilters(solarFiltersMap);
|
|
|
|
|
filter.setNotePunctuations(notePunctuations);
|
|
|
|
|
filter.setMultipleKeys(alsoVisualize);
|
|
|
|
@ -993,16 +793,11 @@ public class StringAnalysisTabNew2 {
|
|
|
|
|
filter.setCollocability(collocability);
|
|
|
|
|
filter.setTaxonomySetOperation(taxonomySetOperation);
|
|
|
|
|
|
|
|
|
|
// if (ngramValue != null && ngramValue == 0) {
|
|
|
|
|
// filter.setStringLength(stringLength);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
String message = Validation.validateForStringLevel(filter);
|
|
|
|
|
if (message == null) {
|
|
|
|
|
// no errors
|
|
|
|
|
logger.info("Executing: ", filter.toString());
|
|
|
|
|
StatisticsNew statistic = new StatisticsNew(corpus, filter, useDb);
|
|
|
|
|
// ADD THINGS HERE!!!
|
|
|
|
|
execute(statistic);
|
|
|
|
|
} else {
|
|
|
|
|
logAlert(message);
|
|
|
|
@ -1043,547 +838,6 @@ public class StringAnalysisTabNew2 {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// public void calculate_collocabilities(StatisticsNew statistics, StatisticsNew oneWordStatistics) {
|
|
|
|
|
// statistics.updateCalculateCollocabilities(oneWordStatistics);
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// private final Task<Void> prepareTaskForMinRelFre(StatisticsNew statistic) {
|
|
|
|
|
// Filter f = statistic.getFilter();
|
|
|
|
|
// logger.info("Started execution: ", f);
|
|
|
|
|
// Task<Void> task_collocability = null;
|
|
|
|
|
//
|
|
|
|
|
// try{
|
|
|
|
|
// Filter f2 = (Filter) f.clone();
|
|
|
|
|
// f2.setIsMinimalRelFreScraper(true);
|
|
|
|
|
// StatisticsNew statisticsMinRelFre = new StatisticsNew(corpus, f2, useDb);
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//// StatisticsNew statisticsMinRelFre = new StatisticsNew(corpus, f, useDb);
|
|
|
|
|
//
|
|
|
|
|
// Collection<File> corpusFiles = statisticsMinRelFre.getCorpus().getDetectedCorpusFiles();
|
|
|
|
|
//
|
|
|
|
|
// final Task<Void> task = new Task<Void>() {
|
|
|
|
|
// @SuppressWarnings("Duplicates")
|
|
|
|
|
// @Override
|
|
|
|
|
// protected Void call() throws Exception {
|
|
|
|
|
// final boolean multipleFiles = CorpusType.multipleFilesCorpuses().contains(statisticsMinRelFre.getCorpus().getCorpusType());
|
|
|
|
|
// if(multipleFiles){
|
|
|
|
|
// cancel.setVisible(true);
|
|
|
|
|
// }
|
|
|
|
|
// Date startTime = new Date();
|
|
|
|
|
// Date previousTime = new Date();
|
|
|
|
|
// int remainingSeconds = -1;
|
|
|
|
|
// int corpusSize;
|
|
|
|
|
// int i;
|
|
|
|
|
// if(statistic.getFilter().getCollocability().size() > 0){
|
|
|
|
|
// i = 0;
|
|
|
|
|
// corpusSize = corpusFiles.size() * 3;
|
|
|
|
|
// } else {
|
|
|
|
|
// i = 0;
|
|
|
|
|
// corpusSize = corpusFiles.size() * 2;
|
|
|
|
|
// }
|
|
|
|
|
// for (File f : corpusFiles) {
|
|
|
|
|
// final int iFinal = i;
|
|
|
|
|
// XML_processing xml_processing = new XML_processing();
|
|
|
|
|
// xml_processing.isCancelled = false;
|
|
|
|
|
// i++;
|
|
|
|
|
// if(xml_processing.progressBarListener != null) {
|
|
|
|
|
// xml_processing.progressProperty().removeListener(xml_processing.progressBarListener);
|
|
|
|
|
// }
|
|
|
|
|
// if (multipleFiles) {
|
|
|
|
|
// if ((new Date()).getTime() - previousTime.getTime() > 500 || remainingSeconds == -1){
|
|
|
|
|
// remainingSeconds = (int) (((new Date()).getTime() - startTime.getTime()) * (1.0/i) * (corpusSize - i) / 1000);
|
|
|
|
|
// previousTime = new Date();
|
|
|
|
|
// }
|
|
|
|
|
// this.updateProgress(i, corpusSize);
|
|
|
|
|
// this.updateMessage(String.format(I18N.get("message.ONGOING_NOTIFICATION_ANALYZING_FILE_X_OF_Y"), i, corpusSize, f.getName(), remainingSeconds));
|
|
|
|
|
//// if (isCancelled()) {
|
|
|
|
|
//// updateMessage(I18N.get("message.CANCELING_NOTIFICATION"));
|
|
|
|
|
//// break;
|
|
|
|
|
//// }
|
|
|
|
|
// } else {
|
|
|
|
|
// xml_processing.progressBarListener = new InvalidationListener() {
|
|
|
|
|
// int remainingSeconds = -1;
|
|
|
|
|
// Date previousTime = new Date();
|
|
|
|
|
// @Override
|
|
|
|
|
// public void invalidated(Observable observable) {
|
|
|
|
|
// cancel.setVisible(true);
|
|
|
|
|
// if ((new Date()).getTime() - previousTime.getTime() > 500 || remainingSeconds == -1){
|
|
|
|
|
// remainingSeconds = (int) (((new Date()).getTime() - xml_processing.startTime.getTime()) *
|
|
|
|
|
// (1.0/(iFinal * 100 + ((ReadOnlyDoubleWrapper) observable).get() + 1)) *
|
|
|
|
|
// ((corpusSize - iFinal - 1) * 100 + 100 - ((ReadOnlyDoubleWrapper) observable).get()) / 1000);
|
|
|
|
|
//// System.out.println(((new Date()).getTime() - xml_processing.startTime.getTime()));
|
|
|
|
|
//// System.out.println((1.0/(iFinal * 100 + ((ReadOnlyDoubleWrapper) observable).get())) + 1);
|
|
|
|
|
//// System.out.println(((corpusSize - iFinal - 1) * 100 + 100 - ((ReadOnlyDoubleWrapper) observable).get()));
|
|
|
|
|
//// System.out.println(remainingSeconds);
|
|
|
|
|
// previousTime = new Date();
|
|
|
|
|
// }
|
|
|
|
|
// xml_processing.isCancelled = isCancelled();
|
|
|
|
|
// updateProgress((iFinal * 100) + ((ReadOnlyDoubleWrapper) observable).get() + 1, corpusSize * 100);
|
|
|
|
|
// updateMessage(String.format(I18N.get("message.ONGOING_NOTIFICATION_ANALYZING_FILE_X_OF_Y"), 1, 1, f.getName(), remainingSeconds));
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// xml_processing.progressProperty().addListener(xml_processing.progressBarListener);
|
|
|
|
|
// }
|
|
|
|
|
// xml_processing.readXML(f.toString(), statisticsMinRelFre);
|
|
|
|
|
// if (isCancelled()) {
|
|
|
|
|
// updateMessage(I18N.get("message.CANCELING_NOTIFICATION"));
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// if(!(multipleFiles)){
|
|
|
|
|
// cancel.setVisible(false);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // add remaining minRelFre results
|
|
|
|
|
// if(statisticsMinRelFre.getFilter().getIsMinimalRelFreScraper()) {
|
|
|
|
|
//// long countFor1MWords = stats.getCountWordsForMinimalRelFreNgrams() +
|
|
|
|
|
// long countFor1MWords = statisticsMinRelFre.getUniGramOccurrences().get(statisticsMinRelFre.getCorpus().getTotal()).longValue();
|
|
|
|
|
// double absToRelFactor = (statisticsMinRelFre.getFilter().getMinimalRelFre() / 1000000.0) * countFor1MWords;
|
|
|
|
|
//
|
|
|
|
|
// statisticsMinRelFre.updateMinimalRelFre(statisticsMinRelFre.getTaxonomyResult().get(statisticsMinRelFre.getCorpus().getTotal()).entrySet(), absToRelFactor);
|
|
|
|
|
//
|
|
|
|
|
// // reset all values
|
|
|
|
|
// for(Taxonomy taxonomy : statisticsMinRelFre.getTaxonomyResult().keySet()){
|
|
|
|
|
// statisticsMinRelFre.getTaxonomyResult().put(taxonomy, new ConcurrentHashMap<>());
|
|
|
|
|
// }
|
|
|
|
|
// for(Taxonomy taxonomy : statisticsMinRelFre.getUniGramOccurrences().keySet()){
|
|
|
|
|
// statisticsMinRelFre.getUniGramOccurrences().put(taxonomy, new AtomicLong(0));
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//// System.out.println("asd");
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// ngramProgressBar.progressProperty().bind(task.progressProperty());
|
|
|
|
|
// progressLabel.textProperty().bind(task.messageProperty());
|
|
|
|
|
// task.setOnSucceeded(e -> {
|
|
|
|
|
// statistic.updateMinimalRelFre(statisticsMinRelFre.getMinimalRelFreNgrams(), statisticsMinRelFre.getMinimalRelFre1grams());
|
|
|
|
|
// final Task<Void> taskCollocability = prepareMainTask(statistic);
|
|
|
|
|
// final Thread thread_collocability = new Thread(taskCollocability, "task_collocability");
|
|
|
|
|
// thread_collocability.setDaemon(true);
|
|
|
|
|
// thread_collocability.start();
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// task.setOnFailed(e -> {
|
|
|
|
|
// showAlert(Alert.AlertType.ERROR, I18N.get("message.ERROR_WHILE_EXECUTING"));
|
|
|
|
|
// logger.error("Error while executing", e);
|
|
|
|
|
// ngramProgressBar.progressProperty().unbind();
|
|
|
|
|
// ngramProgressBar.setProgress(0.0);
|
|
|
|
|
// // ngramProgressBar.setStyle(Settings.FX_ACCENT_NOK);
|
|
|
|
|
// progressLabel.textProperty().unbind();
|
|
|
|
|
// progressLabel.setText("");
|
|
|
|
|
// cancel.setVisible(false);
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// task.setOnCancelled(e -> {
|
|
|
|
|
// showAlert(Alert.AlertType.INFORMATION, I18N.get("message.NOTIFICATION_ANALYSIS_CANCELED"));
|
|
|
|
|
// ngramProgressBar.progressProperty().unbind();
|
|
|
|
|
// ngramProgressBar.setProgress(0.0);
|
|
|
|
|
// // ngramProgressBar.setStyle(Settings.FX_ACCENT_OK);
|
|
|
|
|
// progressLabel.textProperty().unbind();
|
|
|
|
|
// progressLabel.setText("");
|
|
|
|
|
// cancel.setVisible(false);
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// // When cancel button is pressed cancel analysis
|
|
|
|
|
// cancel.setOnAction(e -> {
|
|
|
|
|
// task.cancel();
|
|
|
|
|
// logger.info("cancel button");
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// return task;
|
|
|
|
|
// }catch(CloneNotSupportedException c){ return null; }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// private final Task<Void> prepareMainTask(StatisticsNew statistic) {
|
|
|
|
|
// Filter f = statistic.getFilter();
|
|
|
|
|
// logger.info("Started execution: ", f);
|
|
|
|
|
// Task<Void> task_collocability = null;
|
|
|
|
|
//
|
|
|
|
|
// Collection<File> corpusFiles = statistic.getCorpus().getDetectedCorpusFiles();
|
|
|
|
|
//
|
|
|
|
|
// final Task<Void> task = new Task<Void>() {
|
|
|
|
|
// @SuppressWarnings("Duplicates")
|
|
|
|
|
// @Override
|
|
|
|
|
// protected Void call() throws Exception {
|
|
|
|
|
// final boolean multipleFiles = CorpusType.multipleFilesCorpuses().contains(statistic.getCorpus().getCorpusType());
|
|
|
|
|
// if(multipleFiles){
|
|
|
|
|
// cancel.setVisible(true);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//// int i = corpusFiles.size();
|
|
|
|
|
//// Date startTime = new Date();
|
|
|
|
|
//// Date previousTime = new Date();
|
|
|
|
|
//// int remainingSeconds = -1;
|
|
|
|
|
//// int corpusSize;
|
|
|
|
|
//// if (statistic.getFilter().getCollocability().size() > 0) {
|
|
|
|
|
//// corpusSize = corpusFiles.size() * 2;
|
|
|
|
|
//// } else {
|
|
|
|
|
//// corpusSize = corpusFiles.size();
|
|
|
|
|
//// }
|
|
|
|
|
//
|
|
|
|
|
// Date startTime = new Date();
|
|
|
|
|
// Date previousTime = new Date();
|
|
|
|
|
// int remainingSeconds = -1;
|
|
|
|
|
// int corpusSize;
|
|
|
|
|
// int i;
|
|
|
|
|
// int taskIndex = 0;
|
|
|
|
|
// if(statistic.getFilter().getCollocability().size() > 0 && statistic.getFilter().getMinimalRelFre() > 1){
|
|
|
|
|
// i = corpusFiles.size();
|
|
|
|
|
// corpusSize = corpusFiles.size() * 3;
|
|
|
|
|
// } else if (statistic.getFilter().getMinimalRelFre() > 1) {
|
|
|
|
|
// i = corpusFiles.size();
|
|
|
|
|
// corpusSize = corpusFiles.size() * 2;
|
|
|
|
|
// } else if (statistic.getFilter().getCollocability().size() > 0) {
|
|
|
|
|
// i = 0;
|
|
|
|
|
// corpusSize = corpusFiles.size() * 2;
|
|
|
|
|
// } else {
|
|
|
|
|
// i = 0;
|
|
|
|
|
// corpusSize = corpusFiles.size();
|
|
|
|
|
// }
|
|
|
|
|
// for (File f : corpusFiles) {
|
|
|
|
|
// final int iFinal = i;
|
|
|
|
|
// XML_processing xml_processing = new XML_processing();
|
|
|
|
|
// xml_processing.isCancelled = false;
|
|
|
|
|
// i++;
|
|
|
|
|
// taskIndex++;
|
|
|
|
|
// if(xml_processing.progressBarListener != null) {
|
|
|
|
|
// xml_processing.progressProperty().removeListener(xml_processing.progressBarListener);
|
|
|
|
|
// }
|
|
|
|
|
// if (multipleFiles) {
|
|
|
|
|
// if ((new Date()).getTime() - previousTime.getTime() > 500 || remainingSeconds == -1){
|
|
|
|
|
// remainingSeconds = (int) (((new Date()).getTime() - startTime.getTime()) * (1.0/taskIndex) * (corpusSize - i) / 1000);
|
|
|
|
|
// previousTime = new Date();
|
|
|
|
|
// }
|
|
|
|
|
// this.updateProgress(i, corpusSize);
|
|
|
|
|
// this.updateMessage(String.format(I18N.get("message.ONGOING_NOTIFICATION_ANALYZING_FILE_X_OF_Y"), i, corpusSize, f.getName(), remainingSeconds));
|
|
|
|
|
//
|
|
|
|
|
//// if ((new Date()).getTime() - previousTime.getTime() > 500 || remainingSeconds == -1){
|
|
|
|
|
//// remainingSeconds = (int) (((new Date()).getTime() - startTime.getTime()) * (1.0/i) * (corpusSize - i) / 1000);
|
|
|
|
|
//// previousTime = new Date();
|
|
|
|
|
//// }
|
|
|
|
|
//// this.updateProgress(i, corpusSize);
|
|
|
|
|
//// this.updateMessage(String.format(I18N.get("message.ONGOING_NOTIFICATION_ANALYZING_FILE_X_OF_Y"), i, corpusSize, f.getName(), remainingSeconds));
|
|
|
|
|
//
|
|
|
|
|
// } else {
|
|
|
|
|
// xml_processing.progressBarListener = new InvalidationListener() {
|
|
|
|
|
// int remainingSeconds = -1;
|
|
|
|
|
// Date previousTime = new Date();
|
|
|
|
|
// @Override
|
|
|
|
|
// public void invalidated(Observable observable) {
|
|
|
|
|
// cancel.setVisible(true);
|
|
|
|
|
// if ((new Date()).getTime() - previousTime.getTime() > 500 || remainingSeconds == -1){
|
|
|
|
|
// remainingSeconds = (int) (((new Date()).getTime() - xml_processing.startTime.getTime()) *
|
|
|
|
|
// (1.0/(iFinal * 100 + ((ReadOnlyDoubleWrapper) observable).get() + 1)) *
|
|
|
|
|
// ((corpusSize - iFinal - 1) * 100 + 100 - ((ReadOnlyDoubleWrapper) observable).get()) / 1000);
|
|
|
|
|
//// System.out.println(((new Date()).getTime() - xml_processing.startTime.getTime()));
|
|
|
|
|
//// System.out.println((1.0/(iFinal * 100 + ((ReadOnlyDoubleWrapper) observable).get())) + 1);
|
|
|
|
|
//// System.out.println(((corpusSize - iFinal - 1) * 100 + 100 - ((ReadOnlyDoubleWrapper) observable).get()));
|
|
|
|
|
//// System.out.println(remainingSeconds);
|
|
|
|
|
// previousTime = new Date();
|
|
|
|
|
// }
|
|
|
|
|
// xml_processing.isCancelled = isCancelled();
|
|
|
|
|
// updateProgress((iFinal * 100) + ((ReadOnlyDoubleWrapper) observable).get() + 1, corpusSize * 100);
|
|
|
|
|
// updateMessage(String.format(I18N.get("message.ONGOING_NOTIFICATION_ANALYZING_FILE_X_OF_Y"), 1, 1, f.getName(), remainingSeconds));
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// xml_processing.progressProperty().addListener(xml_processing.progressBarListener);
|
|
|
|
|
// }
|
|
|
|
|
// xml_processing.readXML(f.toString(), statistic);
|
|
|
|
|
// if (isCancelled()) {
|
|
|
|
|
// updateMessage(I18N.get("message.CANCELING_NOTIFICATION"));
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// if(!(multipleFiles)){
|
|
|
|
|
// cancel.setVisible(false);
|
|
|
|
|
// }
|
|
|
|
|
//// readXML(f.toString(), statistic);
|
|
|
|
|
//// i++;
|
|
|
|
|
//// if (isCancelled()) {
|
|
|
|
|
//// updateMessage(I18N.get("message.CANCELING_NOTIFICATION"));
|
|
|
|
|
//// break;
|
|
|
|
|
//// }
|
|
|
|
|
//// if (statistic.getFilter().getCollocability().size() > 0) {
|
|
|
|
|
//// this.updateProgress(i, corpusFiles.size() * 2);
|
|
|
|
|
//// this.updateMessage(String.format(I18N.get("message.ONGOING_NOTIFICATION_ANALYZING_FILE_X_OF_Y"), i, corpusFiles.size() * 2, f.getName()));
|
|
|
|
|
//// } else {
|
|
|
|
|
//// this.updateProgress(i, corpusFiles.size());
|
|
|
|
|
//// this.updateMessage(String.format(I18N.get("message.ONGOING_NOTIFICATION_ANALYZING_FILE_X_OF_Y"), i, corpusFiles.size(), f.getName()));
|
|
|
|
|
//// }
|
|
|
|
|
////// this.updateMessage(String.format(ONGOING_NOTIFICATION_ANALYZING_FILE_X_OF_Y, i, corpusFiles.size() * 2, f.getName()));
|
|
|
|
|
// }
|
|
|
|
|
// // if getMinimalRelFre > 1 erase all words that have lower occurrences at the end of processing
|
|
|
|
|
// if (statistic.getFilter().getMinimalRelFre() > 1){
|
|
|
|
|
//// long countFor1MWords = stats.getCountWordsForMinimalRelFreNgrams() +
|
|
|
|
|
// long countFor1MWords = statistic.getUniGramOccurrences().get(statistic.getCorpus().getTotal()).longValue();
|
|
|
|
|
// double absToRelFactor = (statistic.getFilter().getMinimalRelFre() / 1000000.0) * countFor1MWords;
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// for(Map.Entry<MultipleHMKeys, AtomicLong> entry : statistic.getTaxonomyResult().get(statistic.getCorpus().getTotal()).entrySet()){
|
|
|
|
|
// if(entry.getValue().longValue() < absToRelFactor){
|
|
|
|
|
// statistic.getTaxonomyResult().get(statistic.getCorpus().getTotal()).remove(entry.getKey());
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// statistic.updateMinimalRelFre(statistic.getTaxonomyResult().get(statistic.getCorpus().getTotal()).entrySet(), absToRelFactor);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// ngramProgressBar.progressProperty().bind(task.progressProperty());
|
|
|
|
|
// progressLabel.textProperty().bind(task.messageProperty());
|
|
|
|
|
// task.setOnSucceeded(e -> {
|
|
|
|
|
// if (f.getCollocability().size() > 0) {
|
|
|
|
|
// try{
|
|
|
|
|
// Filter f2 = (Filter) f.clone();
|
|
|
|
|
// f2.setNgramValue(1);
|
|
|
|
|
// StatisticsNew statisticsOneGrams = new StatisticsNew(corpus, f2, useDb);
|
|
|
|
|
// final Task<Void> taskCollocability = prepareTaskForCollocability(statistic, statisticsOneGrams);
|
|
|
|
|
// final Thread thread_collocability = new Thread(taskCollocability, "task_collocability");
|
|
|
|
|
// thread_collocability.setDaemon(true);
|
|
|
|
|
// thread_collocability.start();
|
|
|
|
|
// }catch(CloneNotSupportedException c){}
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// } else {
|
|
|
|
|
// try {
|
|
|
|
|
//// System.out.print(statistics);
|
|
|
|
|
// boolean successullySaved = statistic.saveResultToDisk();
|
|
|
|
|
// if (successullySaved) {
|
|
|
|
|
// showAlert(Alert.AlertType.INFORMATION, I18N.get("message.NOTIFICATION_ANALYSIS_COMPLETED"));
|
|
|
|
|
// } else {
|
|
|
|
|
// showAlert(Alert.AlertType.INFORMATION, I18N.get("message.NOTIFICATION_ANALYSIS_COMPLETED_NO_RESULTS"));
|
|
|
|
|
// }
|
|
|
|
|
// } catch (UnsupportedEncodingException e1) {
|
|
|
|
|
// showAlert(Alert.AlertType.ERROR, I18N.get("message.ERROR_WHILE_SAVING_RESULTS_TO_CSV"));
|
|
|
|
|
// logger.error("Error while saving", e1);
|
|
|
|
|
// } catch (OutOfMemoryError e1) {
|
|
|
|
|
// showAlert(Alert.AlertType.ERROR, I18N.get("message.ERROR_NOT_ENOUGH_MEMORY"));
|
|
|
|
|
// logger.error("Out of memory error", e1);
|
|
|
|
|
// }
|
|
|
|
|
// ngramProgressBar.progressProperty().unbind();
|
|
|
|
|
//// ngramProgressBar.setStyle(Settings.FX_ACCENT_OK);
|
|
|
|
|
// progressLabel.textProperty().unbind();
|
|
|
|
|
// progressLabel.setText("");
|
|
|
|
|
// cancel.setVisible(false);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// task.setOnFailed(e -> {
|
|
|
|
|
// showAlert(Alert.AlertType.ERROR, I18N.get("message.ERROR_WHILE_EXECUTING"));
|
|
|
|
|
// logger.error("Error while executing", e);
|
|
|
|
|
// ngramProgressBar.progressProperty().unbind();
|
|
|
|
|
// ngramProgressBar.setProgress(0.0);
|
|
|
|
|
//// ngramProgressBar.setStyle(Settings.FX_ACCENT_NOK);
|
|
|
|
|
// progressLabel.textProperty().unbind();
|
|
|
|
|
// progressLabel.setText("");
|
|
|
|
|
// cancel.setVisible(false);
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// task.setOnCancelled(e -> {
|
|
|
|
|
// showAlert(Alert.AlertType.INFORMATION, I18N.get("message.NOTIFICATION_ANALYSIS_CANCELED"));
|
|
|
|
|
// ngramProgressBar.progressProperty().unbind();
|
|
|
|
|
// ngramProgressBar.setProgress(0.0);
|
|
|
|
|
//// ngramProgressBar.setStyle(Settings.FX_ACCENT_OK);
|
|
|
|
|
// progressLabel.textProperty().unbind();
|
|
|
|
|
// progressLabel.setText("");
|
|
|
|
|
// cancel.setVisible(false);
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// // When cancel button is pressed cancel analysis
|
|
|
|
|
// cancel.setOnAction(e -> {
|
|
|
|
|
// task.cancel();
|
|
|
|
|
// logger.info("cancel button");
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// return task;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// private final Task<Void> prepareTaskForCollocability(StatisticsNew statistic, StatisticsNew statisticsOneGrams) {
|
|
|
|
|
// Collection<File> corpusFiles = statisticsOneGrams.getCorpus().getDetectedCorpusFiles();
|
|
|
|
|
//
|
|
|
|
|
// final Task<Void> task = new Task<Void>() {
|
|
|
|
|
// @SuppressWarnings("Duplicates")
|
|
|
|
|
// @Override
|
|
|
|
|
// protected Void call() throws Exception {
|
|
|
|
|
// final boolean multipleFiles = CorpusType.multipleFilesCorpuses().contains(statistic.getCorpus().getCorpusType());
|
|
|
|
|
// if(multipleFiles){
|
|
|
|
|
// cancel.setVisible(true);
|
|
|
|
|
// }
|
|
|
|
|
//// int i = corpusFiles.size();
|
|
|
|
|
// Date startTime = new Date();
|
|
|
|
|
// Date previousTime = new Date();
|
|
|
|
|
// int remainingSeconds = -1;
|
|
|
|
|
//// int corpusSize;
|
|
|
|
|
//// if (statistic.getFilter().getCollocability().size() > 0) {
|
|
|
|
|
//// corpusSize = corpusFiles.size() * 2;
|
|
|
|
|
//// } else {
|
|
|
|
|
//// corpusSize = corpusFiles.size();
|
|
|
|
|
//// }
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// int corpusSize;
|
|
|
|
|
// int i;
|
|
|
|
|
// int taskIndex = 0;
|
|
|
|
|
// if(statistic.getFilter().getMinimalRelFre() > 1){
|
|
|
|
|
// i = corpusFiles.size() * 2;
|
|
|
|
|
// corpusSize = corpusFiles.size() * 3;
|
|
|
|
|
// } else {
|
|
|
|
|
// i = corpusFiles.size();
|
|
|
|
|
// corpusSize = corpusFiles.size() * 2;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// for (File f : corpusFiles) {
|
|
|
|
|
// final int iFinal = i;
|
|
|
|
|
// XML_processing xml_processing = new XML_processing();
|
|
|
|
|
// i++;
|
|
|
|
|
// taskIndex++;
|
|
|
|
|
// if(xml_processing.progressBarListener != null) {
|
|
|
|
|
// xml_processing.progressProperty().removeListener(xml_processing.progressBarListener);
|
|
|
|
|
// }
|
|
|
|
|
// if (multipleFiles) {
|
|
|
|
|
// if ((new Date()).getTime() - previousTime.getTime() > 500 || remainingSeconds == -1){
|
|
|
|
|
// remainingSeconds = (int) (((new Date()).getTime() - startTime.getTime()) * (1.0/taskIndex) * (corpusSize - i) / 1000);
|
|
|
|
|
// previousTime = new Date();
|
|
|
|
|
// }
|
|
|
|
|
// this.updateProgress(i, corpusSize);
|
|
|
|
|
// this.updateMessage(String.format(I18N.get("message.ONGOING_NOTIFICATION_ANALYZING_FILE_X_OF_Y"), i, corpusSize, f.getName(), remainingSeconds));
|
|
|
|
|
//// if (isCancelled()) {
|
|
|
|
|
//// updateMessage(I18N.get("message.CANCELING_NOTIFICATION"));
|
|
|
|
|
//// break;
|
|
|
|
|
//// }
|
|
|
|
|
// } else {
|
|
|
|
|
// xml_processing.progressBarListener = new InvalidationListener() {
|
|
|
|
|
// int remainingSeconds = -1;
|
|
|
|
|
// Date previousTime = new Date();
|
|
|
|
|
// @Override
|
|
|
|
|
// public void invalidated(Observable observable) {
|
|
|
|
|
// cancel.setVisible(true);
|
|
|
|
|
// if ((new Date()).getTime() - previousTime.getTime() > 500 || remainingSeconds == -1){
|
|
|
|
|
// remainingSeconds = (int) (((new Date()).getTime() - xml_processing.startTime.getTime()) *
|
|
|
|
|
// (1.0/(iFinal * 100 + ((ReadOnlyDoubleWrapper) observable).get() + 1)) *
|
|
|
|
|
// ((corpusSize - iFinal - 1) * 100 + 100 - ((ReadOnlyDoubleWrapper) observable).get()) / 1000);
|
|
|
|
|
//// System.out.println(((new Date()).getTime() - xml_processing.startTime.getTime()));
|
|
|
|
|
//// System.out.println((1.0/(iFinal * 100 + ((ReadOnlyDoubleWrapper) observable).get() + 1)));
|
|
|
|
|
//// System.out.println(((corpusSize - iFinal - 1) * 100 + 100 - ((ReadOnlyDoubleWrapper) observable).get()));
|
|
|
|
|
//// System.out.println(remainingSeconds);
|
|
|
|
|
// previousTime = new Date();
|
|
|
|
|
// }
|
|
|
|
|
// xml_processing.isCancelled = isCancelled();
|
|
|
|
|
// updateProgress((iFinal * 100) + ((ReadOnlyDoubleWrapper) observable).get() + 1, corpusSize * 100);
|
|
|
|
|
// updateMessage(String.format(I18N.get("message.ONGOING_NOTIFICATION_ANALYZING_FILE_X_OF_Y"), 1, 1, f.getName(), remainingSeconds));
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// xml_processing.progressProperty().addListener(xml_processing.progressBarListener);
|
|
|
|
|
// }
|
|
|
|
|
// xml_processing.isCollocability = true;
|
|
|
|
|
// xml_processing.readXML(f.toString(), statisticsOneGrams);
|
|
|
|
|
// xml_processing.isCollocability = false;
|
|
|
|
|
// if (isCancelled()) {
|
|
|
|
|
// updateMessage(I18N.get("message.CANCELING_NOTIFICATION"));
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
//// readXML(f.toString(), statisticsOneGrams);
|
|
|
|
|
//// i++;
|
|
|
|
|
//// this.updateProgress(i, corpusFiles.size() * 2);
|
|
|
|
|
//// if (statistic.getFilter().getCollocability().size() > 0) {
|
|
|
|
|
//// this.updateMessage(String.format(I18N.get("message.ONGOING_NOTIFICATION_ANALYZING_FILE_X_OF_Y"), i, corpusFiles.size() * 2, f.getName()));
|
|
|
|
|
//// } else {
|
|
|
|
|
//// this.updateMessage(String.format(I18N.get("message.ONGOING_NOTIFICATION_ANALYZING_FILE_X_OF_Y"), i, corpusFiles.size(), f.getName()));
|
|
|
|
|
//// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// ngramProgressBar.progressProperty().bind(task.progressProperty());
|
|
|
|
|
// progressLabel.textProperty().bind(task.messageProperty());
|
|
|
|
|
//
|
|
|
|
|
// task.setOnSucceeded(e -> {
|
|
|
|
|
// try {
|
|
|
|
|
// System.out.print(statistic);
|
|
|
|
|
//// calculate_collocabilities(statistic, statisticsOneGrams);
|
|
|
|
|
// statistic.updateCalculateCollocabilities(statisticsOneGrams);
|
|
|
|
|
// boolean successullySaved = statistic.saveResultToDisk();
|
|
|
|
|
// if (successullySaved) {
|
|
|
|
|
// showAlert(Alert.AlertType.INFORMATION, I18N.get("message.NOTIFICATION_ANALYSIS_COMPLETED"));
|
|
|
|
|
// } else {
|
|
|
|
|
// showAlert(Alert.AlertType.INFORMATION, I18N.get("message.NOTIFICATION_ANALYSIS_COMPLETED_NO_RESULTS"));
|
|
|
|
|
// }
|
|
|
|
|
// } catch (UnsupportedEncodingException e1) {
|
|
|
|
|
// showAlert(Alert.AlertType.ERROR, I18N.get("message.ERROR_WHILE_SAVING_RESULTS_TO_CSV"));
|
|
|
|
|
// logger.error("Error while saving", e1);
|
|
|
|
|
// } catch (OutOfMemoryError e1) {
|
|
|
|
|
// showAlert(Alert.AlertType.ERROR, I18N.get("message.ERROR_NOT_ENOUGH_MEMORY"));
|
|
|
|
|
// logger.error("Out of memory error", e1);
|
|
|
|
|
// }
|
|
|
|
|
//// try {
|
|
|
|
|
//// boolean successullySaved = statistic.saveResultToDisk();
|
|
|
|
|
//// if (successullySaved) {
|
|
|
|
|
//// showAlert(Alert.AlertType.INFORMATION, Messages.NOTIFICATION_ANALYSIS_COMPLETED);
|
|
|
|
|
//// } else {
|
|
|
|
|
//// showAlert(Alert.AlertType.INFORMATION, Messages.NOTIFICATION_ANALYSIS_COMPLETED_NO_RESULTS);
|
|
|
|
|
//// }
|
|
|
|
|
//// } catch (UnsupportedEncodingException e1) {
|
|
|
|
|
//// showAlert(Alert.AlertType.ERROR, ERROR_WHILE_SAVING_RESULTS_TO_CSV);
|
|
|
|
|
//// logger.error("Error while saving", e1);
|
|
|
|
|
//// } catch (OutOfMemoryError e1){
|
|
|
|
|
//// showAlert(Alert.AlertType.ERROR, ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
|
//// logger.error("Out of memory error", e1);
|
|
|
|
|
//// }
|
|
|
|
|
////
|
|
|
|
|
// ngramProgressBar.progressProperty().unbind();
|
|
|
|
|
//// ngramProgressBar.setStyle(Settings.FX_ACCENT_OK);
|
|
|
|
|
// progressLabel.textProperty().unbind();
|
|
|
|
|
// progressLabel.setText("");
|
|
|
|
|
// cancel.setVisible(false);
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// task.setOnFailed(e -> {
|
|
|
|
|
// showAlert(Alert.AlertType.ERROR, I18N.get("message.ERROR_WHILE_EXECUTING"));
|
|
|
|
|
// logger.error("Error while executing", e);
|
|
|
|
|
// ngramProgressBar.progressProperty().unbind();
|
|
|
|
|
// ngramProgressBar.setProgress(0.0);
|
|
|
|
|
//// ngramProgressBar.setStyle(Settings.FX_ACCENT_NOK);
|
|
|
|
|
// progressLabel.textProperty().unbind();
|
|
|
|
|
// progressLabel.setText("");
|
|
|
|
|
// cancel.setVisible(false);
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// task.setOnCancelled(e -> {
|
|
|
|
|
// showAlert(Alert.AlertType.INFORMATION, I18N.get("message.NOTIFICATION_ANALYSIS_CANCELED"));
|
|
|
|
|
// ngramProgressBar.progressProperty().unbind();
|
|
|
|
|
// ngramProgressBar.setProgress(0.0);
|
|
|
|
|
//// ngramProgressBar.setStyle(Settings.FX_ACCENT_OK);
|
|
|
|
|
// progressLabel.textProperty().unbind();
|
|
|
|
|
// progressLabel.setText("");
|
|
|
|
|
// cancel.setVisible(false);
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// // When cancel button is pressed cancel analysis
|
|
|
|
|
// cancel.setOnAction(e -> {
|
|
|
|
|
// task.cancel();
|
|
|
|
|
//// logger.info("cancel button");
|
|
|
|
|
// });
|
|
|
|
|
// return task;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
private void execute(StatisticsNew statistic) {
|
|
|
|
|
Filter f = statistic.getFilter();
|
|
|
|
|
logger.info("Started execution: ", f);
|
|
|
|
@ -1591,13 +845,11 @@ public class StringAnalysisTabNew2 {
|
|
|
|
|
Tasks t = new Tasks(corpus, useDb, cancel, ngramProgressBar, progressLabel);
|
|
|
|
|
if (f.getMinimalRelFre() > 1){
|
|
|
|
|
final Task<Void> mainTask = t.prepareTaskForMinRelFre(statistic);
|
|
|
|
|
// final Task<Void> mainTask = prepareTaskForMinRelFre(statistic);
|
|
|
|
|
final Thread thread = new Thread(mainTask, "task");
|
|
|
|
|
thread.setDaemon(true);
|
|
|
|
|
thread.start();
|
|
|
|
|
} else {
|
|
|
|
|
final Task<Void> mainTask = t.prepareMainTask(statistic);
|
|
|
|
|
// final Task<Void> mainTask = prepareMainTask(statistic);
|
|
|
|
|
final Thread thread = new Thread(mainTask, "task");
|
|
|
|
|
thread.setDaemon(true);
|
|
|
|
|
thread.start();
|
|
|
|
|