Added functionality for n-grams (comma separation), minimal occurances etc.

This commit is contained in:
2018-07-31 08:58:17 +02:00
parent 681eb4f949
commit 179f09c4bd
27 changed files with 405 additions and 4962 deletions

View File

@@ -51,6 +51,14 @@ public class CharacterAnalysisTab {
private TextField stringLengthTF;
private Integer stringLength;
@FXML
private TextField minimalOccurrencesTF;
private Integer minimalOccurrences;
@FXML
private TextField minimalTaxonomyTF;
private Integer minimalTaxonomy;
@FXML
private ToggleGroup calculateForRB;
private CalculateFor calculateFor;
@@ -189,6 +197,49 @@ public class CharacterAnalysisTab {
}
});
// set default values
minimalOccurrencesTF.setText("1");
minimalOccurrences = 1;
minimalTaxonomyTF.setText("1");
minimalTaxonomy = 1;
minimalOccurrencesTF.focusedProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue) {
// focus lost
String value = minimalOccurrencesTF.getText();
if (!ValidationUtil.isEmpty(value)) {
if (!ValidationUtil.isNumber(value)) {
logAlert("minimalOccurrencesTF: " + WARNING_ONLY_NUMBERS_ALLOWED);
GUIController.showAlert(Alert.AlertType.ERROR, WARNING_ONLY_NUMBERS_ALLOWED);
} else {
minimalOccurrences = Integer.parseInt(value);
}
} else {
minimalOccurrencesTF.setText("1");
minimalOccurrences = 1;
}
}
});
minimalTaxonomyTF.focusedProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue) {
// focus lost
String value = minimalTaxonomyTF.getText();
if (!ValidationUtil.isEmpty(value)) {
if (!ValidationUtil.isNumber(value)) {
logAlert("minimalTaxonomyTF: " + WARNING_ONLY_NUMBERS_ALLOWED);
GUIController.showAlert(Alert.AlertType.ERROR, WARNING_ONLY_NUMBERS_ALLOWED);
} else {
minimalTaxonomy = Integer.parseInt(value);
}
} else {
minimalTaxonomyTF.setText("1");
minimalTaxonomy = 1;
}
}
});
computeNgramsB.setOnAction(e -> {
compute();
logger.info("compute button");
@@ -344,6 +395,8 @@ public class CharacterAnalysisTab {
filter.setIsCvv(calculateCvv);
filter.setSolarFilters(solarFiltersMap);
filter.setStringLength(stringLength);
filter.setMinimalOccurrences(minimalOccurrences);
filter.setMinimalTaxonomy(minimalTaxonomy);
String message = Validation.validateForStringLevel(filter);
if (message == null) {

View File

@@ -105,7 +105,7 @@ public class CorpusTab {
gosUseOrthChB.selectedProperty().addListener((observable, oldValue, newValue) -> {
gosUseOrth = newValue;
corpus.setGosOrthMode(gosUseOrth);
wordFormationTab.setDisable(gosUseOrth);
// wordFormationTab.setDisable(gosUseOrth);
satNew2Controller.toggleMode(null);
oneWordTabController.toggleMode(null);
catController.toggleMode(null);

View File

@@ -80,6 +80,7 @@ public class GUIController extends Application {
@Override
public void start(Stage primaryStage) throws IOException {
Parent root = FXMLLoader.load(getClass().getResource("/GUI.fxml"));
// Parent root = FXMLLoader.load(ResourceLookup.resources.url("GUI.fxml"));
primaryStage.setTitle("GUI");
Scene scene = new Scene(root, 800, 600);
// https://github.com/dicolar/jbootx

View File

@@ -15,6 +15,7 @@ public class Messages {
public static final String WARNING_DIFFERING_NGRAM_LEVEL_AND_FILTER_TOKENS_INFO = "Izberite drugo število ali popravite filter.";
public static final String WARNING_WORD_OR_LEMMA = "Izberite, če želite statistiko izračunati za besede ali leme.";
public static final String WARNING_ONLY_NUMBERS_ALLOWED = "Prosim vnesite veljavno število.";
public static final String WARNING_NUMBER_TOO_BIG = "Vnešeno število je večje od števila taksonomij.";
public static final String WARNING_MISMATCHED_NGRAM_AND_TOKENS_VALUES = "Število za ngram (%d) in število msd oznak (%d) se morata ujemati.";
public static final String WARNING_MISSING_STRING_LENGTH = "Dolžina niza mora biti večja od 0. Vstavljena je privzeta vrednost (1).";
public static final String WARNING_NO_TAXONOMY_FOUND = "Iz korpusnih datotek ni bilo moč razbrati taksonomije. Prosim izberite drugo lokacijo ali korpus.";

View File

@@ -49,6 +49,13 @@ public class OneWordAnalysisTab {
private ComboBox<String> calculateForCB;
private CalculateFor calculateFor;
@FXML
private TextField minimalOccurrencesTF;
private Integer minimalOccurrences;
@FXML
private TextField minimalTaxonomyTF;
private Integer minimalTaxonomy;
@FXML
private Button computeNgramsB;
@@ -191,6 +198,49 @@ public class OneWordAnalysisTab {
taxonomyCCB.setDisable(true);
}
// set default values
minimalOccurrencesTF.setText("1");
minimalOccurrences = 1;
minimalTaxonomyTF.setText("1");
minimalTaxonomy = 1;
minimalOccurrencesTF.focusedProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue) {
// focus lost
String value = minimalOccurrencesTF.getText();
if (!ValidationUtil.isEmpty(value)) {
if (!ValidationUtil.isNumber(value)) {
logAlert("minimalOccurrencesTF: " + WARNING_ONLY_NUMBERS_ALLOWED);
GUIController.showAlert(Alert.AlertType.ERROR, WARNING_ONLY_NUMBERS_ALLOWED);
} else {
minimalOccurrences = Integer.parseInt(value);
}
} else {
minimalOccurrencesTF.setText("1");
minimalOccurrences = 1;
}
}
});
minimalTaxonomyTF.focusedProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue) {
// focus lost
String value = minimalTaxonomyTF.getText();
if (!ValidationUtil.isEmpty(value)) {
if (!ValidationUtil.isNumber(value)) {
logAlert("minimalTaxonomyTF: " + WARNING_ONLY_NUMBERS_ALLOWED);
GUIController.showAlert(Alert.AlertType.ERROR, WARNING_ONLY_NUMBERS_ALLOWED);
} else {
minimalTaxonomy = Integer.parseInt(value);
}
} else {
minimalTaxonomyTF.setText("1");
minimalTaxonomy = 1;
}
}
});
computeNgramsB.setOnAction(e -> {
compute();
logger.info("compute button");
@@ -313,6 +363,7 @@ public class OneWordAnalysisTab {
} else {
msdTF.setDisable(false);
}
calculateFor = CalculateFor.factory(calculateForCB.getItems().get(0));
}
private void compute() {
@@ -327,6 +378,8 @@ public class OneWordAnalysisTab {
filter.setSolarFilters(solarFiltersMap);
filter.setStringLength(1);
filter.setMultipleKeys(alsoVisualize);
filter.setMinimalOccurrences(minimalOccurrences);
filter.setMinimalTaxonomy(minimalTaxonomy);
String message = Validation.validateForStringLevel(filter);
if (message == null) {

View File

@@ -66,6 +66,14 @@ public class StringAnalysisTabNew2 {
private CheckBox notePunctuationsChB;
private boolean notePunctuations;
@FXML
private TextField minimalOccurrencesTF;
private Integer minimalOccurrences;
@FXML
private TextField minimalTaxonomyTF;
private Integer minimalTaxonomy;
@FXML
private Pane paneWords;
@@ -139,6 +147,13 @@ public class StringAnalysisTabNew2 {
ngramValueCB.getSelectionModel().select(0); // selected index
ngramValue = 2; // actual value at that index
// set default values
minimalOccurrencesTF.setText("1");
minimalOccurrences = 1;
minimalTaxonomyTF.setText("1");
minimalTaxonomy = 1;
notePunctuations = true;
// set
notePunctuationsChB.selectedProperty().addListener((observable, oldValue, newValue) -> {
@@ -240,6 +255,42 @@ public class StringAnalysisTabNew2 {
}
});
minimalOccurrencesTF.focusedProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue) {
// focus lost
String value = minimalOccurrencesTF.getText();
if (!ValidationUtil.isEmpty(value)) {
if (!ValidationUtil.isNumber(value)) {
logAlert("minimalOccurrencesTF: " + WARNING_ONLY_NUMBERS_ALLOWED);
GUIController.showAlert(Alert.AlertType.ERROR, WARNING_ONLY_NUMBERS_ALLOWED);
} else {
minimalOccurrences = Integer.parseInt(value);
}
} else {
minimalOccurrencesTF.setText("1");
minimalOccurrences = 1;
}
}
});
minimalTaxonomyTF.focusedProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue) {
// focus lost
String value = minimalTaxonomyTF.getText();
if (!ValidationUtil.isEmpty(value)) {
if (!ValidationUtil.isNumber(value)) {
logAlert("minimalTaxonomyTF: " + WARNING_ONLY_NUMBERS_ALLOWED);
GUIController.showAlert(Alert.AlertType.ERROR, WARNING_ONLY_NUMBERS_ALLOWED);
} else {
minimalTaxonomy = Integer.parseInt(value);
}
} else {
minimalTaxonomyTF.setText("1");
minimalTaxonomy = 1;
}
}
});
computeNgramsB.setOnAction(e -> {
compute();
logger.info("compute button");
@@ -411,6 +462,8 @@ public class StringAnalysisTabNew2 {
filter.setIsCvv(calculateCvv);
filter.setSolarFilters(solarFiltersMap);
filter.setNotePunctuations(notePunctuations);
filter.setMinimalOccurrences(minimalOccurrences);
filter.setMinimalTaxonomy(minimalTaxonomy);
if (ngramValue != null && ngramValue == 0) {
filter.setStringLength(stringLength);

View File

@@ -40,6 +40,14 @@ public class WordFormationTab {
private CheckComboBox<String> taxonomyCCB;
private ArrayList<String> taxonomy;
@FXML
private TextField minimalOccurrencesTF;
private Integer minimalOccurrences;
@FXML
private TextField minimalTaxonomyTF;
private Integer minimalTaxonomy;
@FXML
private Button computeB;
@@ -77,6 +85,49 @@ public class WordFormationTab {
taxonomyCCB.setDisable(true);
}
// set default values
minimalOccurrencesTF.setText("1");
minimalOccurrences = 1;
minimalTaxonomyTF.setText("1");
minimalTaxonomy = 1;
minimalOccurrencesTF.focusedProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue) {
// focus lost
String value = minimalOccurrencesTF.getText();
if (!ValidationUtil.isEmpty(value)) {
if (!ValidationUtil.isNumber(value)) {
logAlert("minimalOccurrencesTF: " + WARNING_ONLY_NUMBERS_ALLOWED);
GUIController.showAlert(Alert.AlertType.ERROR, WARNING_ONLY_NUMBERS_ALLOWED);
} else {
minimalOccurrences = Integer.parseInt(value);
}
} else {
minimalOccurrencesTF.setText("1");
minimalOccurrences = 1;
}
}
});
minimalTaxonomyTF.focusedProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue) {
// focus lost
String value = minimalTaxonomyTF.getText();
if (!ValidationUtil.isEmpty(value)) {
if (!ValidationUtil.isNumber(value)) {
logAlert("minimalTaxonomyTF: " + WARNING_ONLY_NUMBERS_ALLOWED);
GUIController.showAlert(Alert.AlertType.ERROR, WARNING_ONLY_NUMBERS_ALLOWED);
} else {
minimalTaxonomy = Integer.parseInt(value);
}
} else {
minimalTaxonomyTF.setText("1");
minimalTaxonomy = 1;
}
}
});
computeB.setOnAction(e -> {
compute();
logger.info("compute button");
@@ -95,6 +146,8 @@ public class WordFormationTab {
filter.setMsd(new ArrayList<>());
filter.setIsCvv(false);
filter.setSolarFilters(solarFiltersMap);
filter.setMinimalOccurrences(minimalOccurrences);
filter.setMinimalTaxonomy(minimalTaxonomy);
String message = Validation.validateForStringLevel(filter);
if (message == null) {

View File

@@ -40,6 +40,14 @@ public class WordLevelTab {
private CheckComboBox<String> taxonomyCCB;
private ArrayList<String> taxonomy;
@FXML
private TextField minimalOccurrencesTF;
private Integer minimalOccurrences;
@FXML
private TextField minimalTaxonomyTF;
private Integer minimalTaxonomy;
@FXML
private Button computeB;
@@ -77,6 +85,49 @@ public class WordLevelTab {
taxonomyCCB.setDisable(true);
}
// set default values
minimalOccurrencesTF.setText("1");
minimalOccurrences = 1;
minimalTaxonomyTF.setText("1");
minimalTaxonomy = 1;
minimalOccurrencesTF.focusedProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue) {
// focus lost
String value = minimalOccurrencesTF.getText();
if (!ValidationUtil.isEmpty(value)) {
if (!ValidationUtil.isNumber(value)) {
logAlert("minimalOccurrencesTF: " + WARNING_ONLY_NUMBERS_ALLOWED);
GUIController.showAlert(Alert.AlertType.ERROR, WARNING_ONLY_NUMBERS_ALLOWED);
} else {
minimalOccurrences = Integer.parseInt(value);
}
} else {
minimalOccurrencesTF.setText("1");
minimalOccurrences = 1;
}
}
});
minimalTaxonomyTF.focusedProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue) {
// focus lost
String value = minimalTaxonomyTF.getText();
if (!ValidationUtil.isEmpty(value)) {
if (!ValidationUtil.isNumber(value)) {
logAlert("minimalTaxonomyTF: " + WARNING_ONLY_NUMBERS_ALLOWED);
GUIController.showAlert(Alert.AlertType.ERROR, WARNING_ONLY_NUMBERS_ALLOWED);
} else {
minimalTaxonomy = Integer.parseInt(value);
}
} else {
minimalTaxonomyTF.setText("1");
minimalTaxonomy = 1;
}
}
});
computeB.setOnAction(e -> {
compute();
logger.info("compute button");
@@ -98,6 +149,8 @@ public class WordLevelTab {
filter.setMsd(new ArrayList<>());
filter.setIsCvv(false);
filter.setSolarFilters(solarFiltersMap);
filter.setMinimalOccurrences(minimalOccurrences);
filter.setMinimalTaxonomy(minimalTaxonomy);
String message = Validation.validateForStringLevel(filter);
if (message == null) {