|
|
|
@ -211,8 +211,49 @@ public class CorpusTab {
|
|
|
|
|
|
|
|
|
|
// make sure there are corpus files in selected directory or notify the user about it
|
|
|
|
|
if (corpusFiles.size() == 0) {
|
|
|
|
|
logger.info("alert: ", I18N.get("message.WARNING_CORPUS_NOT_FOUND"));
|
|
|
|
|
showAlert(Alert.AlertType.ERROR, I18N.get("message.WARNING_CORPUS_NOT_FOUND"), null);
|
|
|
|
|
// try .vert
|
|
|
|
|
corpusFiles = FileUtils.listFiles(selectedDirectory, FileFilterUtils.suffixFileFilter("vert", IOCase.INSENSITIVE), TrueFileFilter.INSTANCE);
|
|
|
|
|
Collection<File> corpusFilesRegi = FileUtils.listFiles(selectedDirectory, FileFilterUtils.suffixFileFilter("regi", IOCase.INSENSITIVE), TrueFileFilter.INSTANCE);
|
|
|
|
|
|
|
|
|
|
if (corpusFiles.size() == 0){
|
|
|
|
|
logger.info("alert: ", I18N.get("message.WARNING_CORPUS_NOT_FOUND"));
|
|
|
|
|
showAlert(Alert.AlertType.ERROR, I18N.get("message.WARNING_CORPUS_NOT_FOUND"), null);
|
|
|
|
|
} else {
|
|
|
|
|
corpusType = VERT;
|
|
|
|
|
|
|
|
|
|
corpus.setCorpusType(corpusType);
|
|
|
|
|
|
|
|
|
|
Messages.setChooseCorpusProperties(corpusLocation, corpusFilesSize, corpusType.toString());
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.append(corpusLocation)
|
|
|
|
|
.append("\n")
|
|
|
|
|
.append(String.format(I18N.get("message.NOTIFICATION_FOUND_X_FILES"), corpusFiles.size()))
|
|
|
|
|
.append("\n")
|
|
|
|
|
.append(String.format(I18N.get("message.NOTIFICATION_CORPUS"), corpusType.toString()));
|
|
|
|
|
|
|
|
|
|
String result = sb.toString();
|
|
|
|
|
|
|
|
|
|
logger.debug(result);
|
|
|
|
|
|
|
|
|
|
initNewCorpus(selectedDirectory, corpusFiles);
|
|
|
|
|
Messages.setChooseCorpusProperties(corpusLocation, corpusFilesSize, corpusType.toString());
|
|
|
|
|
|
|
|
|
|
corpus.setChosenCorpusLocation(selectedDirectory);
|
|
|
|
|
corpus.setDetectedCorpusFiles(corpusFiles);
|
|
|
|
|
|
|
|
|
|
chooseCorpusLabelContent = result;
|
|
|
|
|
if (readHeaderInfo) {
|
|
|
|
|
logger.info("reading header info...");
|
|
|
|
|
readHeaderInfo();
|
|
|
|
|
} else {
|
|
|
|
|
setResults();
|
|
|
|
|
|
|
|
|
|
setCorpusForAnalysis();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
String chooseCorpusLabelContentTmp = detectCorpusType(corpusFiles);
|
|
|
|
|
|
|
|
|
@ -420,6 +461,70 @@ public class CorpusTab {
|
|
|
|
|
task.setOnCancelled(e -> togglePiAndSetCorpusWrapper(false));
|
|
|
|
|
task.setOnFailed(e -> togglePiAndSetCorpusWrapper(false));
|
|
|
|
|
|
|
|
|
|
final Thread thread = new Thread(task, "task");
|
|
|
|
|
thread.setDaemon(true);
|
|
|
|
|
thread.start();
|
|
|
|
|
} else if (corpusType == CorpusType.VERT) {
|
|
|
|
|
// many many fields
|
|
|
|
|
boolean corpusIsSplit = corpusFiles.size() > 1;
|
|
|
|
|
|
|
|
|
|
final Task<HashSet<String>> task = new Task<HashSet<String>>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected HashSet<String> call() throws Exception {
|
|
|
|
|
HashSet<String> values = new HashSet<>();
|
|
|
|
|
long i = 0;
|
|
|
|
|
|
|
|
|
|
if (!corpusIsSplit) {
|
|
|
|
|
updateProgress(-1.0f, -1.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (File file : corpusFiles) {
|
|
|
|
|
HashSet<String> tmpvalues = XML_processing.readVertHeaderTaxonomyAndFilters(file.getAbsolutePath(), corpusIsSplit, corpusType);
|
|
|
|
|
|
|
|
|
|
// update final results
|
|
|
|
|
for (String entry : tmpvalues) {
|
|
|
|
|
if (!entry.equals("-")) {
|
|
|
|
|
values.add(entry);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
|
|
if (corpusIsSplit) {
|
|
|
|
|
updateProgress(i, corpusFiles.size());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateProgress(1.0f, 1.0f);
|
|
|
|
|
return values;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
locationScanPI.progressProperty().bind(task.progressProperty());
|
|
|
|
|
|
|
|
|
|
task.setOnSucceeded(e -> {
|
|
|
|
|
ObservableList<String> readTaxonomy = Tax.getTaxonomyForComboBox(corpusType, task.getValue());
|
|
|
|
|
|
|
|
|
|
if (ValidationUtil.isEmpty(readTaxonomy)) {
|
|
|
|
|
// if no taxonomy found alert the user and keep other tabs disabled
|
|
|
|
|
logger.info("No vert filters found in headers.");
|
|
|
|
|
GUIController.showAlert(Alert.AlertType.ERROR, I18N.get("message.WARNING_NO_SOLAR_FILTERS_FOUND"));
|
|
|
|
|
} else {
|
|
|
|
|
// set taxonomy, update label
|
|
|
|
|
corpus.setTaxonomy(readTaxonomy);
|
|
|
|
|
corpus.setHeaderRead(true);
|
|
|
|
|
Messages.setChooseCorpusL(chooseCorpusL, chooseCorpusLabelContent);
|
|
|
|
|
setResults();
|
|
|
|
|
setCorpusForAnalysis();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
togglePiAndSetCorpusWrapper(false);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
task.setOnCancelled(e -> togglePiAndSetCorpusWrapper(false));
|
|
|
|
|
task.setOnFailed(e -> togglePiAndSetCorpusWrapper(false));
|
|
|
|
|
|
|
|
|
|
final Thread thread = new Thread(task, "task");
|
|
|
|
|
thread.setDaemon(true);
|
|
|
|
|
thread.start();
|
|
|
|
|