Modified word tab

This commit is contained in:
Luka 2018-06-27 10:14:40 +02:00
parent a18e52a599
commit d5d06fd7c5
9 changed files with 98 additions and 16 deletions

View File

@ -352,11 +352,13 @@ public class StatisticsNew {
// n.gram nivo
if (ngramLevel > 1) {
info.put("n-gram nivo:", String.valueOf(ngramLevel));
} else if (ngramLevel == 1){
info.put("n-gram nivo:", "nivo besed");
} else {
info.put("n-gram nivo:", "nivo črk");
}
// else if (ngramLevel == 1){
// info.put("n-gram nivo:", "nivo besed");
// } else {
// info.put("n-gram nivo:", "nivo črk");
// }
// skip
if (ngramLevel > 1)
info.put("Skip:", isNotEmpty(filter.getSkipValue()) ? filter.getSkipValue().toString() : "0");
@ -382,15 +384,15 @@ public class StatisticsNew {
}
if (isNotEmpty(filter.getTaxonomy()) && Tax.getCorpusTypesWithTaxonomy().contains(corpus.getCorpusType())) {
ArrayList<String> tax = Tax.getTaxonomyForInfo(corpus.getCorpusType(), filter.getTaxonomy());
info.put("Taksonomija: ", "");
String sep = "";
for (String s : tax) {
info.put(sep = sep + " ", s);
}
}
// if (isNotEmpty(filter.getTaxonomy()) && Tax.getCorpusTypesWithTaxonomy().contains(corpus.getCorpusType())) {
// ArrayList<String> tax = Tax.getTaxonomyForInfo(corpus.getCorpusType(), filter.getTaxonomy());
//
// info.put("Taksonomija: ", "");
// String sep = "";
// for (String s : tax) {
// info.put(sep = sep + " ", s);
// }
// }
if (corpus.getCorpusType() == CorpusType.SOLAR) {
HashMap<String, ObservableList<String>> filters = corpus.getSolarFilters();

View File

@ -109,6 +109,8 @@ public class GUIController extends Application {
ctController.setFfsController(ffsController);
//ctController.setWordFormationTab(wordFormationTab);
ctController.setWordLevelTab(wordLevelTab);
//System.out.println(com.sun.javafx.runtime.VersionInfo.getRuntimeVersion());
ctController.setHostServices(getHostServices());
satNew2Controller.setCorpus(corpus);

View File

@ -35,9 +35,11 @@ public class Messages {
public static final String NOTIFICATION_ANALYSIS_COMPLETED = "Analiza je zaključena, rezultati so shranjeni.";
public static final String NOTIFICATION_ANALYSIS_COMPLETED_NO_RESULTS = "Analiza je zaključena, vendar ni bilo moč izračunati statistike, ki bi ustrezala vsem navedenim pogojem.";
public static final String RESULTS_PATH_SET_TO_DEFAULT = "Lokacija za shranjevanje rezultatov je nastavljena na lokacijo korpusa.";
public static final String NOTIFICATION_ANALYSIS_CANCLED = "Analiziranje je bilo prekinjeno.";
// ongoing notifications - displayed while processing, dynamically changing
public static final String ONGOING_NOTIFICATION_ANALYZING_FILE_X_OF_Y = "Analiziram datoteko %d od %d (%s)";
public static final String CANCELING_NOTIFICATION = "Prekinjeno";
// Labels
public static final String LABEL_CORPUS_LOCATION_NOT_SET = "Lokacija korpusa ni nastavljena";

View File

@ -37,6 +37,10 @@ public class OneWordAnalysisTab {
private ArrayList<Pattern> msd;
private ArrayList<String> msdStrings;
@FXML
private CheckComboBox<String> alsoVisualizeCCB;
private ArrayList<String> alsoVisualize;
@FXML
private CheckComboBox<String> taxonomyCCB;
private ArrayList<String> taxonomy;
@ -49,6 +53,9 @@ public class OneWordAnalysisTab {
@FXML
private Button computeNgramsB;
@FXML
private Button cancel;
@FXML
public ProgressBar ngramProgressBar;
@FXML
@ -73,7 +80,8 @@ public class OneWordAnalysisTab {
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> alsoVisualizeItemsLemma = FXCollections.observableArrayList("besedna vrsta", "oblikoskladenjska oznaka");
private static final ObservableList<String> alsoVisualizeItemsDifferential = FXCollections.observableArrayList("lema", "besedna vrsta", "oblikoskladenjska oznaka");
// TODO: pass observables for taxonomy based on header scan
// after header scan
@ -126,6 +134,16 @@ public class OneWordAnalysisTab {
msdTF.setText("");
msd = new ArrayList<>();
alsoVisualizeCCB.getItems().removeAll();
alsoVisualizeCCB.getItems().setAll(alsoVisualizeItemsLemma);
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();
// taxonomy
if (Tax.getCorpusTypesWithTaxonomy().contains(corpus.getCorpusType())) {
taxonomyCCB.getItems().removeAll();
@ -334,6 +352,10 @@ public class OneWordAnalysisTab {
for (File f : corpusFiles) {
readXML(f.toString(), statistic);
i++;
if (isCancelled()) {
updateMessage(CANCELING_NOTIFICATION);
break;
}
this.updateProgress(i, corpusFiles.size());
this.updateMessage(String.format(ONGOING_NOTIFICATION_ANALYZING_FILE_X_OF_Y, i, corpusFiles.size(), f.getName()));
}
@ -374,6 +396,21 @@ public class OneWordAnalysisTab {
progressLabel.setText("");
});
task.setOnCancelled(e -> {
showAlert(Alert.AlertType.INFORMATION, Messages.NOTIFICATION_ANALYSIS_CANCLED);
ngramProgressBar.progressProperty().unbind();
ngramProgressBar.setProgress(0.0);
ngramProgressBar.setStyle(Settings.FX_ACCENT_OK);
progressLabel.textProperty().unbind();
progressLabel.setText("");
});
// When cancel button is pressed cancel analysis
cancel.setOnAction(e -> {
task.cancel();
logger.info("cancel button");
});
final Thread thread = new Thread(task, "task");
thread.setDaemon(true);
thread.start();

View File

@ -9,7 +9,8 @@ import org.apache.commons.lang3.math.NumberUtils;
public class ValidationUtil {
public static boolean isNumber(String value) {
return NumberUtils.isCreatable(value);
//return NumberUtils.isCreatable(value);
return NumberUtils.isNumber(value);
}
/**

View File

@ -55,9 +55,35 @@ public class Export {
public static String SetToCSV(Set<Pair<String, Map<String, Long>>> set, File resultsPath, LinkedHashMap<String, String> headerInfoBlock) {
//Delimiter used in CSV file
String NEW_LINE_SEPARATOR = "\n";
Object[] FILE_HEADER;
//Count frequencies
int num_frequencies = 0;
for (Pair<String, Map<String, Long>> p : set) {
Map<String, Long> map = p.getRight();
for (Map.Entry<String, Long> e : map.entrySet()) {
num_frequencies += e.getValue();
}
}
//CSV file header
Object[] FILE_HEADER = {"word", "frequency", "percent"};
if (headerInfoBlock.containsKey("Analiza") && headerInfoBlock.get("Analiza").equals("Besede")) {
if (headerInfoBlock.containsKey("Izračunaj za:") && headerInfoBlock.get("Izračunaj za:").equals("različnica")) {
headerInfoBlock.put("Skupna vsota vseh različnic:", String.valueOf(num_frequencies));
FILE_HEADER = new Object[]{"Različnica", "Skupna absolutna pogostost", "Delež glede na vse različnice"};
} else if (headerInfoBlock.containsKey("Izračunaj za:") && headerInfoBlock.get("Izračunaj za:").equals("lema")) {
headerInfoBlock.put("Skupna vsota vseh lem:", String.valueOf(num_frequencies));
FILE_HEADER = new Object[]{"Lema", "Skupna absolutna pogostost", "Delež glede na vse leme"};
} else if (headerInfoBlock.containsKey("Izračunaj za:") && headerInfoBlock.get("Izračunaj za:").equals("oblikoskladenjska oznaka")) {
headerInfoBlock.put("Skupna vsota vseh oblikoskladenjskih oznak:", String.valueOf(num_frequencies));
FILE_HEADER = new Object[]{"Oblikoskladenjska oznaka", "Skupna absolutna pogostost", "Delež glede na vse oblikoskladenjske oznake"};
} else {
headerInfoBlock.put("Skupna vsota vseh različnic:", String.valueOf(num_frequencies));
FILE_HEADER = new Object[]{"Lema", "Skupna pogostost", "Delež glede na leme"};
}
} else
FILE_HEADER = new Object[]{"word", "frequency", "percent"};
String fileName = "";

View File

@ -48,6 +48,9 @@
<Hyperlink fx:id="helpH" alignment="TOP_LEFT" layoutX="710.0" layoutY="16.0" text="Pomoč" />
<Button fx:id="cancel" layoutX="540.0" layoutY="482.0" mnemonicParsing="false"
prefHeight="25.0" prefWidth="250.0" text="Prekini"/>
<ProgressBar fx:id="ngramProgressBar" layoutX="10.0" layoutY="517.0" prefHeight="16.0" prefWidth="780.0" progress="0.0" />
<Label fx:id="progressLabel" layoutX="10.0" layoutY="541.0" prefHeight="25.0" prefWidth="780.0" />

View File

@ -30,6 +30,8 @@
</items>
</ComboBox>
<Label layoutX="300.0" layoutY="20.0" prefHeight="25.0" text="Izpiši tudi:" />
<CheckComboBox fx:id="alsoVisualizeCCB" layoutX="400.0" layoutY="20.0" prefHeight="25.0" prefWidth="180.0"/>
<!-- MSD and Taxonomy separated -->
<Label layoutX="10.0" layoutY="80.0" prefHeight="25.0" text="Omejitev podatkov" />
@ -50,6 +52,9 @@
<Hyperlink fx:id="helpH" alignment="TOP_LEFT" layoutX="710.0" layoutY="16.0" text="Pomoč" />
<Button fx:id="cancel" layoutX="540.0" layoutY="482.0" mnemonicParsing="false"
prefHeight="25.0" prefWidth="250.0" text="Prekini"/>
<ProgressBar fx:id="ngramProgressBar" layoutX="10.0" layoutY="517.0" prefHeight="16.0" prefWidth="780.0" progress="0.0"/>
<Label fx:id="progressLabel" layoutX="10.0" layoutY="541.0" prefHeight="25.0" prefWidth="780.0"/>

View File

@ -99,6 +99,10 @@
<Label fx:id="selectedFiltersLabel" alignment="TOP_LEFT" layoutX="510.0" layoutY="45.0" prefHeight="540.0" prefWidth="275.0"
text=" " wrapText="true"/>
<Hyperlink fx:id="helpH" alignment="TOP_LEFT" layoutX="710.0" layoutY="16.0" text="Pomoč" />
<Button fx:id="cancel" layoutX="540.0" layoutY="482.0" mnemonicParsing="false"
prefHeight="25.0" prefWidth="250.0" text="Prekini"/>
<ProgressBar fx:id="ngramProgressBar" layoutX="10.0" layoutY="517.0" prefHeight="16.0" prefWidth="780.0" progress="0.0"/>
<Label fx:id="progressLabel" layoutX="10.0" layoutY="541.0" prefHeight="25.0" prefWidth="780.0"/>