Added implementation of taxonomy set operations (intersection and union)

This commit is contained in:
2019-01-29 13:49:20 +01:00
parent b639e36961
commit acf2fb086b
13 changed files with 286 additions and 65 deletions

View File

@@ -858,11 +858,15 @@ public class XML_processing {
if (!ValidationUtil.isEmpty(stats.getFilter().getTaxonomy())) {
currentFiletaxonomy.retainAll(stats.getFilter().getTaxonomy()); // intersection
if (currentFiletaxonomy.isEmpty()) {
if (stats.getFilter().getTaxonomySetOperation().equals(I18N.get("taxonomySetOperation.UNION")) && currentFiletaxonomy.isEmpty()) {
// taxonomies don't match so stop
// union (select words that match any of selected taxonomy
// return false;
taxonomyMatch = false;
// System.out.println("TEST");
//
} else if(stats.getFilter().getTaxonomySetOperation().equals(I18N.get("taxonomySetOperation.INTERSECTION")) && currentFiletaxonomy.size() != stats.getFilter().getTaxonomy().size()){
// intersection (select only words that precisely match selected taxonomy
taxonomyMatch = false;
}
}
}
@@ -1114,11 +1118,15 @@ public class XML_processing {
if (!ValidationUtil.isEmpty(stats.getFilter().getTaxonomy())) {
currentFiletaxonomy.retainAll(stats.getFilter().getTaxonomy()); // intersection
if (currentFiletaxonomy.isEmpty()) {
if (stats.getFilter().getTaxonomySetOperation().equals(I18N.get("taxonomySetOperation.UNION")) && currentFiletaxonomy.isEmpty()) {
// taxonomies don't match so stop
// union (select words that match any of selected taxonomy
// return false;
taxonomyMatch = false;
// System.out.println("TEST");
//
} else if(stats.getFilter().getTaxonomySetOperation().equals(I18N.get("taxonomySetOperation.INTERSECTION")) && currentFiletaxonomy.size() != stats.getFilter().getTaxonomy().size()){
// intersection (select only words that precisely match selected taxonomy
taxonomyMatch = false;
}
}
} else if (endElement.getName().getLocalPart().equals("text")){
@@ -1400,13 +1408,29 @@ public class XML_processing {
} else if (endElement.getName().getLocalPart().equals("teiHeader")) {
// before proceeding to read this file, make sure that taxonomy filters are a match
// if (!ValidationUtil.isEmpty(stats.getFilter().getTaxonomy())) {
// currentFiletaxonomy.retainAll(stats.getFilter().getTaxonomy()); // intersection
//
// // disregard this entry if taxonomies don't match
// includeFile = !currentFiletaxonomy.isEmpty();
//
//// currentFiletaxonomy = new ArrayList<>();
// }
if (!ValidationUtil.isEmpty(stats.getFilter().getTaxonomy())) {
currentFiletaxonomy.retainAll(stats.getFilter().getTaxonomy()); // intersection
// disregard this entry if taxonomies don't match
includeFile = !currentFiletaxonomy.isEmpty();
// currentFiletaxonomy = new ArrayList<>();
if (stats.getFilter().getTaxonomySetOperation().equals(I18N.get("taxonomySetOperation.UNION")) && currentFiletaxonomy.isEmpty()) {
// taxonomies don't match so stop
// union (select words that match any of selected taxonomy
// return false;
includeFile = false;
//
} else if(stats.getFilter().getTaxonomySetOperation().equals(I18N.get("taxonomySetOperation.INTERSECTION")) && currentFiletaxonomy.size() != stats.getFilter().getTaxonomy().size()){
// intersection (select only words that precisely match selected taxonomy
includeFile = false;
} else {
includeFile = true;
}
}
}
@@ -1580,8 +1604,14 @@ public class XML_processing {
if (!ValidationUtil.isEmpty(stats.getFilter().getTaxonomy())) {
currentFiletaxonomy.retainAll(stats.getFilter().getTaxonomy()); // intersection
if (currentFiletaxonomy.isEmpty()) {
// taxonomies don't match so don't save
if (stats.getFilter().getTaxonomySetOperation().equals(I18N.get("taxonomySetOperation.UNION")) && currentFiletaxonomy.isEmpty()) {
// taxonomies don't match so stop
// union (select words that match any of selected taxonomy
// return false;
taxonomyMatch = false;
//
} else if(stats.getFilter().getTaxonomySetOperation().equals(I18N.get("taxonomySetOperation.INTERSECTION")) && currentFiletaxonomy.size() != stats.getFilter().getTaxonomy().size()){
// intersection (select only words that precisely match selected taxonomy
taxonomyMatch = false;
}
}