Added hevristics (time predictions for calculations)
This commit is contained in:
@@ -27,7 +27,8 @@ public class Corpus {
|
||||
private File chosenCorpusLocation;
|
||||
private Collection<File> detectedCorpusFiles;
|
||||
boolean headerRead;
|
||||
private ObservableList<String> taxonomy; // if gigafida or gos
|
||||
private ArrayList<Taxonomy> taxonomy; // if gigafida or gos
|
||||
private Taxonomy taxonomyTotal;
|
||||
private HashMap<String, ObservableList<String>> solarFilters; // if solar
|
||||
private HashMap<String, HashSet<String>> solarFiltersForXML; // if solar - used while parsing xml
|
||||
private boolean gosOrthMode;
|
||||
@@ -36,6 +37,7 @@ public class Corpus {
|
||||
|
||||
public Corpus() {
|
||||
validationErrors = new ArrayList<>();
|
||||
setTotal();
|
||||
}
|
||||
|
||||
public CorpusType getCorpusType() {
|
||||
@@ -82,9 +84,25 @@ public class Corpus {
|
||||
this.headerRead = headerRead;
|
||||
}
|
||||
|
||||
public ObservableList<String> getTaxonomy() {
|
||||
public Taxonomy getTotal() {
|
||||
return taxonomyTotal;
|
||||
}
|
||||
|
||||
public void setTotal() {
|
||||
taxonomyTotal = new Taxonomy("Total", false);
|
||||
}
|
||||
|
||||
public ArrayList<Taxonomy> getTaxonomy() {
|
||||
return taxonomy;
|
||||
}
|
||||
|
||||
public ObservableList<String> getObservableListTaxonomy() {
|
||||
ArrayList<String> al = new ArrayList<>();
|
||||
for (Taxonomy t : this.taxonomy){
|
||||
al.add(t.toLongNameString());
|
||||
}
|
||||
return FXCollections.observableArrayList(al);
|
||||
}
|
||||
//
|
||||
// public ObservableList<String> getFormattedTaxonomy() {
|
||||
// ArrayList<String> al = Tax.getTaxonomyFormatted(new ArrayList<>(taxonomy), corpusType);
|
||||
@@ -92,7 +110,10 @@ public class Corpus {
|
||||
// }
|
||||
|
||||
public void setTaxonomy(ObservableList<String> taxonomy) {
|
||||
this.taxonomy = taxonomy;
|
||||
this.taxonomy = new ArrayList<>();
|
||||
for(String t : taxonomy){
|
||||
this.taxonomy.add(new Taxonomy(t, true));
|
||||
}
|
||||
logger.info("Corpus.set: ", taxonomy);
|
||||
}
|
||||
|
||||
@@ -151,7 +172,8 @@ public class Corpus {
|
||||
if (!headerRead && corpusType != null) {
|
||||
// if user didn't opt into reading the headers, set default taxonomy or solar filters
|
||||
if (Tax.getCorpusTypesWithTaxonomy().contains(corpusType)) {
|
||||
taxonomy = Tax.getTaxonomyForComboBox(corpusType);
|
||||
Tax.getTaxonomyForComboBox(corpusType);
|
||||
setTaxonomy(Tax.getTaxonomyForComboBox(corpusType));
|
||||
} else if (corpusType == CorpusType.SOLAR && solarFilters == null) {
|
||||
setSolarFilters(SolarFilters.getFiltersForComboBoxes());
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package data;
|
||||
|
||||
public enum CorpusType {
|
||||
GIGAFIDA("Gigafida", "gigafida"),
|
||||
GIGAFIDA2("Gigafida2.0", "gigafida2.0"),
|
||||
CCKRES("ccKres ", "cckres"),
|
||||
SOLAR("Šolar", "šolar"),
|
||||
GOS("GOS", "gos"),
|
||||
|
||||
@@ -10,7 +10,6 @@ import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import gui.I18N;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -51,17 +50,17 @@ public class StatisticsNew {
|
||||
this.corpus = corpus;
|
||||
this.filter = filter;
|
||||
this.taxonomyResult = new ConcurrentHashMap<>();
|
||||
this.taxonomyResult.put(Taxonomy.TOTAL, new ConcurrentHashMap<>());
|
||||
this.taxonomyResult.put(corpus.getTotal(), new ConcurrentHashMap<>());
|
||||
this.collocability = new ConcurrentHashMap<>();
|
||||
this.uniGramTaxonomyOccurrences = new ConcurrentHashMap<>();
|
||||
this.uniGramTaxonomyOccurrences.put(Taxonomy.TOTAL, new AtomicLong(0L));
|
||||
this.uniGramTaxonomyOccurrences.put(corpus.getTotal(), new AtomicLong(0L));
|
||||
|
||||
|
||||
// create table for counting word occurrences per taxonomies
|
||||
if (this.corpus.getTaxonomy() != null && filter.getDisplayTaxonomy()) {
|
||||
if (this.corpus.getObservableListTaxonomy() != null && filter.getDisplayTaxonomy()) {
|
||||
if (this.filter.getTaxonomy().isEmpty()) {
|
||||
for (int i = 0; i < this.corpus.getTaxonomy().size(); i++) {
|
||||
this.taxonomyResult.put(Taxonomy.factoryLongName(this.corpus.getTaxonomy().get(i)), new ConcurrentHashMap<>());
|
||||
for (int i = 0; i < this.corpus.getObservableListTaxonomy().size(); i++) {
|
||||
this.taxonomyResult.put(Taxonomy.factoryLongName(this.corpus.getObservableListTaxonomy().get(i), corpus), new ConcurrentHashMap<>());
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < this.filter.getTaxonomy().size(); i++) {
|
||||
@@ -234,14 +233,14 @@ public class StatisticsNew {
|
||||
removeMinimalTaxonomy(taxonomyResult, filter.getMinimalTaxonomy());
|
||||
|
||||
// if no results and nothing to save, return false
|
||||
if (!(taxonomyResult.get(Taxonomy.TOTAL).size() > 0)) {
|
||||
if (!(taxonomyResult.get(corpus.getTotal()).size() > 0)) {
|
||||
analysisProducedResults = false;
|
||||
return false;
|
||||
} else {
|
||||
analysisProducedResults = true;
|
||||
}
|
||||
|
||||
stats.add(ImmutablePair.of(resultTitle, getSortedResult(taxonomyResult.get(Taxonomy.TOTAL), Util.getValidInt(limit))));
|
||||
stats.add(ImmutablePair.of(resultTitle, getSortedResult(taxonomyResult.get(corpus.getTotal()), Util.getValidInt(limit))));
|
||||
Export.SetToCSV(stats, corpus.getChosenResultsLocation(), headerInfoBlock(), this, filter);
|
||||
return true;
|
||||
}
|
||||
@@ -253,14 +252,14 @@ public class StatisticsNew {
|
||||
if (minimalTaxonomy == 1)
|
||||
return;
|
||||
int occurances;
|
||||
for (MultipleHMKeys key : taxonomyResult.get(Taxonomy.TOTAL).keySet()){
|
||||
for (MultipleHMKeys key : taxonomyResult.get(corpus.getTotal()).keySet()){
|
||||
occurances = 0;
|
||||
for (Taxonomy columnNameKey : taxonomyResult.keySet()){
|
||||
if(!columnNameKey.equals(Taxonomy.TOTAL) && taxonomyResult.get(columnNameKey).get(key).intValue() >= 1)
|
||||
if(!columnNameKey.equals(corpus.getTotal()) && taxonomyResult.get(columnNameKey).get(key).intValue() >= 1)
|
||||
occurances++;
|
||||
}
|
||||
if(occurances < minimalTaxonomy){
|
||||
taxonomyResult.get(Taxonomy.TOTAL).remove(key);
|
||||
taxonomyResult.get(corpus.getTotal()).remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -271,8 +270,8 @@ public class StatisticsNew {
|
||||
private void removeMinimalOccurrences(Integer minimalOccurrences) {
|
||||
if (minimalOccurrences == 0)
|
||||
return;
|
||||
for (MultipleHMKeys key : taxonomyResult.get(Taxonomy.TOTAL).keySet()){
|
||||
if(taxonomyResult.get(Taxonomy.TOTAL).get(key).intValue() < minimalOccurrences){
|
||||
for (MultipleHMKeys key : taxonomyResult.get(corpus.getTotal()).keySet()){
|
||||
if(taxonomyResult.get(corpus.getTotal()).get(key).intValue() < minimalOccurrences){
|
||||
for (Taxonomy t : taxonomyResult.keySet()){
|
||||
taxonomyResult.get(t).remove(key);
|
||||
}
|
||||
@@ -349,7 +348,7 @@ public class StatisticsNew {
|
||||
}
|
||||
|
||||
public void updateUniGramOccurrences(int amount, ArrayList<Taxonomy> taxonomy){
|
||||
uniGramTaxonomyOccurrences.get(Taxonomy.TOTAL).set(uniGramTaxonomyOccurrences.get(Taxonomy.TOTAL).longValue() + amount);
|
||||
uniGramTaxonomyOccurrences.get(corpus.getTotal()).set(uniGramTaxonomyOccurrences.get(corpus.getTotal()).longValue() + amount);
|
||||
for (Taxonomy t : taxonomy){
|
||||
if (uniGramTaxonomyOccurrences.get(t) != null){
|
||||
uniGramTaxonomyOccurrences.get(t).set(uniGramTaxonomyOccurrences.get(t).longValue() + amount);
|
||||
@@ -360,15 +359,15 @@ public class StatisticsNew {
|
||||
}
|
||||
|
||||
public Map<Taxonomy, AtomicLong> getUniGramOccurrences(){
|
||||
// return uniGramTaxonomyOccurrences.get(Taxonomy.TOTAL).longValue();
|
||||
// return uniGramTaxonomyOccurrences.get(corpus.getTotal()).longValue();
|
||||
return uniGramTaxonomyOccurrences;
|
||||
}
|
||||
|
||||
public void updateTaxonomyResults(MultipleHMKeys o, List<Taxonomy> taxonomy) {
|
||||
for (Taxonomy key : taxonomyResult.keySet()) {
|
||||
// first word should have the same taxonomy as others
|
||||
if (key.equals(Taxonomy.TOTAL) || taxonomy.contains(key)) {
|
||||
// if (key.equals(Taxonomy.TOTAL) || taxonomy != null && taxonomy.contains(key)) {
|
||||
if (key.equals(corpus.getTotal()) || taxonomy.contains(key)) {
|
||||
// if (key.equals(corpus.getTotal()) || taxonomy != null && taxonomy.contains(key)) {
|
||||
// if taxonomy not in map and in this word
|
||||
AtomicLong r = taxonomyResult.get(key).putIfAbsent(o, new AtomicLong(1));
|
||||
|
||||
@@ -607,7 +606,7 @@ public class StatisticsNew {
|
||||
// sortedTaxonomyString.add(t);
|
||||
// }
|
||||
// getTaxonomyForTaxonomyResult
|
||||
tax = Tax.getTaxonomyForTaxonomyResult(corpus.getCorpusType(), taxonomyResult.keySet());
|
||||
tax = Tax.getTaxonomyForTaxonomyResult(corpus, taxonomyResult.keySet());
|
||||
}
|
||||
|
||||
// String sep = "";
|
||||
@@ -618,11 +617,11 @@ public class StatisticsNew {
|
||||
}
|
||||
|
||||
// info.put(sep = sep + " ", s);
|
||||
if (uniGramTaxonomyOccurrences.get(Taxonomy.factoryLongName(s)) == null) {
|
||||
if (uniGramTaxonomyOccurrences.get(Taxonomy.factoryLongName(s, corpus)) == null) {
|
||||
info.put(s, "");
|
||||
continue;
|
||||
}
|
||||
int n = uniGramTaxonomyOccurrences.get(Taxonomy.factoryLongName(s)).intValue();
|
||||
int n = uniGramTaxonomyOccurrences.get(Taxonomy.factoryLongName(s, corpus)).intValue();
|
||||
if (n == 0) {
|
||||
info.put(s, "");
|
||||
} else {
|
||||
@@ -662,11 +661,11 @@ public class StatisticsNew {
|
||||
|
||||
// count number of all words
|
||||
long N = 0;
|
||||
for(AtomicLong a : oneWordTaxonomyResult.get(Taxonomy.TOTAL).values()){
|
||||
for(AtomicLong a : oneWordTaxonomyResult.get(corpus.getTotal()).values()){
|
||||
N += a.longValue();
|
||||
}
|
||||
|
||||
for(MultipleHMKeys hmKey : taxonomyResult.get(Taxonomy.TOTAL).keySet()) {
|
||||
for(MultipleHMKeys hmKey : taxonomyResult.get(corpus.getTotal()).keySet()) {
|
||||
// String[] splitedString = hmKey.getK1().split("\\s+");
|
||||
|
||||
long sum_fwi =0L;
|
||||
@@ -674,15 +673,15 @@ public class StatisticsNew {
|
||||
|
||||
for(MultipleHMKeys smallHmKey : hmKey.getSplittedMultipleHMKeys()){
|
||||
// System.out.println(smallHmKey.getK1());
|
||||
sum_fwi += oneWordTaxonomyResult.get(Taxonomy.TOTAL).get(smallHmKey).longValue();
|
||||
mul_fwi *= oneWordTaxonomyResult.get(Taxonomy.TOTAL).get(smallHmKey).longValue();
|
||||
sum_fwi += oneWordTaxonomyResult.get(corpus.getTotal()).get(smallHmKey).longValue();
|
||||
mul_fwi *= oneWordTaxonomyResult.get(corpus.getTotal()).get(smallHmKey).longValue();
|
||||
}
|
||||
// String t = hmKey.getK1();
|
||||
// if(hmKey.getK1().equals("v Slovenija")){
|
||||
// System.out.println("TEST");
|
||||
//
|
||||
// }
|
||||
double O = (double)taxonomyResult.get(Taxonomy.TOTAL).get(hmKey).longValue();
|
||||
double O = (double)taxonomyResult.get(corpus.getTotal()).get(hmKey).longValue();
|
||||
double n = (double)filter.getNgramValue();
|
||||
double E = (double)mul_fwi / Math.pow(N, n - 1);
|
||||
if (collocabilityMap.keySet().contains(Collocability.DICE)){
|
||||
|
||||
@@ -10,7 +10,7 @@ import javafx.collections.ObservableList;
|
||||
public class Tax {
|
||||
private static LinkedHashMap<String, String> GIGAFIDA_TAXONOMY;
|
||||
private static LinkedHashMap<String, String> GOS_TAXONOMY;
|
||||
private static final HashSet<CorpusType> corpusTypesWithTaxonomy = new HashSet<>(Arrays.asList(CorpusType.GIGAFIDA, CorpusType.GOS, CorpusType.CCKRES, CorpusType.SSJ500K, CorpusType.VERT));
|
||||
private static final HashSet<CorpusType> corpusTypesWithTaxonomy = new HashSet<>(Arrays.asList(CorpusType.GIGAFIDA, CorpusType.GOS, CorpusType.CCKRES, CorpusType.SSJ500K, CorpusType.GIGAFIDA2, CorpusType.VERT));
|
||||
|
||||
static {
|
||||
// GIGAFIDA ----------------------------
|
||||
@@ -104,7 +104,7 @@ public class Tax {
|
||||
public static ObservableList<String> getTaxonomyForComboBox(CorpusType corpusType, HashSet<String> foundTax) {
|
||||
LinkedHashMap<String, String> tax = new LinkedHashMap<>();
|
||||
|
||||
if (corpusType == CorpusType.GIGAFIDA || corpusType == CorpusType.CCKRES || corpusType == CorpusType.SSJ500K) {
|
||||
if (corpusType == CorpusType.GIGAFIDA || corpusType == CorpusType.CCKRES || corpusType == CorpusType.SSJ500K || corpusType == CorpusType.GIGAFIDA2) {
|
||||
tax = GIGAFIDA_TAXONOMY;
|
||||
} else if (corpusType == CorpusType.GOS) {
|
||||
tax = GOS_TAXONOMY;
|
||||
@@ -143,13 +143,13 @@ public class Tax {
|
||||
/**
|
||||
* Returns taxonomy names only for items found in headers
|
||||
*/
|
||||
public static ArrayList<String> getTaxonomyForTaxonomyResult(CorpusType corpusType, Set<Taxonomy> foundTax) {
|
||||
public static ArrayList<String> getTaxonomyForTaxonomyResult(Corpus corpus, Set<Taxonomy> foundTax) {
|
||||
LinkedHashMap<String, String> tax = new LinkedHashMap<>();
|
||||
Set<Taxonomy> foundTaxHS= new HashSet<>(foundTax);
|
||||
|
||||
if (corpusType == CorpusType.GIGAFIDA || corpusType == CorpusType.CCKRES || corpusType == CorpusType.SSJ500K) {
|
||||
if (corpus.getCorpusType() == CorpusType.GIGAFIDA || corpus.getCorpusType() == CorpusType.CCKRES || corpus.getCorpusType() == CorpusType.SSJ500K || corpus.getCorpusType() == CorpusType.GIGAFIDA2) {
|
||||
tax = GIGAFIDA_TAXONOMY;
|
||||
} else if (corpusType == CorpusType.GOS) {
|
||||
} else if (corpus.getCorpusType() == CorpusType.GOS) {
|
||||
tax = GOS_TAXONOMY;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ public class Tax {
|
||||
for(Taxonomy e : foundTaxHS){
|
||||
String[] elList = e.toString().split("\\.");
|
||||
for(int i = 1; i < elList.length - 1; i++){
|
||||
Taxonomy candidate = Taxonomy.factory(String.join(".", Arrays.copyOfRange(elList, 0, elList.length - i)));
|
||||
Taxonomy candidate = Taxonomy.factory(String.join(".", Arrays.copyOfRange(elList, 0, elList.length - i)), corpus);
|
||||
genFoundTax.add(candidate);
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,7 @@ public class Tax {
|
||||
|
||||
// assures same relative order
|
||||
for (String t : tax.keySet()) {
|
||||
if (foundTaxHS.contains(Taxonomy.factory(t))) {
|
||||
if (foundTaxHS.contains(Taxonomy.factory(t, corpus))) {
|
||||
taxForCombo.add(tax.get(t));
|
||||
}
|
||||
}
|
||||
@@ -263,13 +263,19 @@ public class Tax {
|
||||
public static ArrayList<String> getTaxonomyForInfo(CorpusType corpusType, ArrayList<Taxonomy> taxonomy) {
|
||||
LinkedHashMap<String, String> tax = new LinkedHashMap<>();
|
||||
|
||||
if (corpusType == CorpusType.GIGAFIDA || corpusType == CorpusType.CCKRES || corpusType == CorpusType.SSJ500K) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
if (corpusType == CorpusType.GIGAFIDA || corpusType == CorpusType.CCKRES || corpusType == CorpusType.SSJ500K || corpusType == CorpusType.GIGAFIDA2) {
|
||||
tax = GIGAFIDA_TAXONOMY;
|
||||
} else if (corpusType == CorpusType.GOS) {
|
||||
tax = GOS_TAXONOMY;
|
||||
} else if (corpusType == CorpusType.VERT) {
|
||||
for (Taxonomy t : taxonomy) {
|
||||
result.add(t.toLongNameString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
|
||||
|
||||
for (Taxonomy t : taxonomy) {
|
||||
result.add(tax.get(t.toString()));
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
public enum Taxonomy {
|
||||
enum TaxonomyEnum {
|
||||
TOTAL("Total", "Total"),
|
||||
|
||||
// GOS
|
||||
@@ -85,7 +85,7 @@ public enum Taxonomy {
|
||||
private final String name;
|
||||
private final String longName;
|
||||
|
||||
Taxonomy(String name, String longName) {
|
||||
TaxonomyEnum(String name, String longName) {
|
||||
this.name = name;
|
||||
this.longName = longName;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public enum Taxonomy {
|
||||
return this.longName;
|
||||
}
|
||||
|
||||
public static Taxonomy factory(String tax) {
|
||||
public static TaxonomyEnum factory(String tax) {
|
||||
if (tax != null) {
|
||||
// GOS
|
||||
if (DISKURZ.toString().equals(tax)) {
|
||||
@@ -289,7 +289,7 @@ public enum Taxonomy {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Taxonomy factoryLongName(String tax) {
|
||||
public static TaxonomyEnum factoryLongName(String tax) {
|
||||
if (tax != null) {
|
||||
// GOS
|
||||
if (DISKURZ.toLongNameString().equals(tax)) {
|
||||
@@ -477,11 +477,15 @@ public enum Taxonomy {
|
||||
}
|
||||
|
||||
}
|
||||
// return new Taxonomy(tax, tax);
|
||||
System.out.println("2.");
|
||||
System.out.println(tax);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ArrayList<Taxonomy> taxonomySelected(Taxonomy disjointTaxonomy) {
|
||||
ArrayList<Taxonomy> r = new ArrayList<>();
|
||||
public static ArrayList<TaxonomyEnum> taxonomySelected(TaxonomyEnum disjointTaxonomy) {
|
||||
ArrayList<TaxonomyEnum> r = new ArrayList<>();
|
||||
|
||||
System.out.println(disjointTaxonomy);
|
||||
if(disjointTaxonomy.equals(DISKURZ)){
|
||||
@@ -628,9 +632,9 @@ public enum Taxonomy {
|
||||
return r;
|
||||
}
|
||||
|
||||
public static ArrayList<Taxonomy> taxonomyDeselected(Taxonomy disjointTaxonomy){
|
||||
ArrayList<Taxonomy> r = new ArrayList<>();
|
||||
Map<Taxonomy, Taxonomy> connections = new ConcurrentHashMap<>();
|
||||
public static ArrayList<TaxonomyEnum> taxonomyDeselected(TaxonomyEnum disjointTaxonomy){
|
||||
ArrayList<TaxonomyEnum> r = new ArrayList<>();
|
||||
Map<TaxonomyEnum, TaxonomyEnum> connections = new ConcurrentHashMap<>();
|
||||
connections.put(DISKURZ_JAVNI, DISKURZ);
|
||||
connections.put(DISKURZ_INFORMATIVNO_IZOBRAZEVALNI, DISKURZ_JAVNI);
|
||||
connections.put(DISKURZ_RAZVEDRILNI, DISKURZ_JAVNI);
|
||||
@@ -685,7 +689,7 @@ public enum Taxonomy {
|
||||
connections.put(FT_DA, FT_LEKTORIRANO);
|
||||
connections.put(FT_NE, FT_LEKTORIRANO);
|
||||
|
||||
Taxonomy currentTaxonomy = disjointTaxonomy;
|
||||
TaxonomyEnum currentTaxonomy = disjointTaxonomy;
|
||||
r.add(currentTaxonomy);
|
||||
while(connections.containsKey(currentTaxonomy)){
|
||||
currentTaxonomy = connections.get(currentTaxonomy);
|
||||
@@ -695,29 +699,36 @@ public enum Taxonomy {
|
||||
return r;
|
||||
}
|
||||
|
||||
public static ArrayList<Taxonomy> convertStringListToTaxonomyList(ObservableList<String> stringList){
|
||||
public static ArrayList<TaxonomyEnum> convertStringListToTaxonomyList(ObservableList<String> stringList, Corpus corpus){
|
||||
System.out.println("1.");
|
||||
System.out.println(stringList);
|
||||
ArrayList<Taxonomy> taxonomyList = new ArrayList<>();
|
||||
ArrayList<TaxonomyEnum> taxonomyList = new ArrayList<>();
|
||||
|
||||
// System.out.println("INTERESTING STUFF");
|
||||
// System.out.println(stringList);
|
||||
for (String e : stringList) {
|
||||
taxonomyList.add(factoryLongName(e));
|
||||
for (Taxonomy t : corpus.getTaxonomy()){
|
||||
if (t.toLongNameString().equals(e)) {
|
||||
taxonomyList.add(t.getTaxonomyEnum());
|
||||
}
|
||||
}
|
||||
}
|
||||
// System.out.println(taxonomyList);
|
||||
// System.out.println("-----------------");
|
||||
return taxonomyList;
|
||||
}
|
||||
|
||||
public static void modifyingTaxonomy(ArrayList<Taxonomy> taxonomy, ArrayList<Taxonomy> checkedItemsTaxonomy, Corpus corpus){
|
||||
public static void modifyingTaxonomy(ArrayList<TaxonomyEnum> taxonomy, ArrayList<TaxonomyEnum> checkedItemsTaxonomy, Corpus corpus){
|
||||
// get taxonomies that were selected/deselected by user
|
||||
// System.out.println(taxonomy);
|
||||
// System.out.println(checkedItemsTaxonomy);
|
||||
System.out.println("Print here:");
|
||||
System.out.println(taxonomy);
|
||||
System.out.println(checkedItemsTaxonomy);
|
||||
System.out.println("-------------");
|
||||
|
||||
Set<Taxonomy> disjointTaxonomies = new HashSet<>(checkedItemsTaxonomy);
|
||||
Set<TaxonomyEnum> disjointTaxonomies = new HashSet<>(checkedItemsTaxonomy);
|
||||
if (taxonomy != null) {
|
||||
disjointTaxonomies.addAll(taxonomy);
|
||||
for (Taxonomy s : checkedItemsTaxonomy) {
|
||||
for (TaxonomyEnum s : checkedItemsTaxonomy) {
|
||||
if (taxonomy.contains(s)) {
|
||||
disjointTaxonomies.remove(s);
|
||||
}
|
||||
@@ -725,11 +736,11 @@ public enum Taxonomy {
|
||||
}
|
||||
|
||||
// remove previously selected items plus remove taxonomies that are not presented in current setup
|
||||
ArrayList<Taxonomy> disArr = new ArrayList<>(disjointTaxonomies);
|
||||
ArrayList<TaxonomyEnum> disArr = new ArrayList<>(disjointTaxonomies);
|
||||
int i = 0;
|
||||
while(i < disArr.size()){
|
||||
Taxonomy s = disArr.get(i);
|
||||
if(!Taxonomy.convertStringListToTaxonomyList(corpus.getTaxonomy()).contains(s)){
|
||||
TaxonomyEnum s = disArr.get(i);
|
||||
if(!TaxonomyEnum.convertStringListToTaxonomyList(corpus.getObservableListTaxonomy(), corpus).contains(s)){
|
||||
disjointTaxonomies.remove(s);
|
||||
disArr.remove(s);
|
||||
// taxonomy.remove(s);
|
||||
@@ -740,14 +751,14 @@ public enum Taxonomy {
|
||||
|
||||
|
||||
if (disjointTaxonomies.size() > 0) {
|
||||
Taxonomy disjointTaxonomy = disjointTaxonomies.iterator().next();
|
||||
TaxonomyEnum disjointTaxonomy = disjointTaxonomies.iterator().next();
|
||||
|
||||
// taxonomy was selected
|
||||
if (checkedItemsTaxonomy.contains(disjointTaxonomy)) {
|
||||
ArrayList<Taxonomy> addTaxonomies = Taxonomy.taxonomySelected(disjointTaxonomy);
|
||||
ArrayList<TaxonomyEnum> addTaxonomies = TaxonomyEnum.taxonomySelected(disjointTaxonomy);
|
||||
checkedItemsTaxonomy.addAll(addTaxonomies);
|
||||
} else if (taxonomy.contains(disjointTaxonomy)) {
|
||||
ArrayList<Taxonomy> removeTaxonomies = Taxonomy.taxonomyDeselected(disjointTaxonomy);
|
||||
ArrayList<TaxonomyEnum> removeTaxonomies = TaxonomyEnum.taxonomyDeselected(disjointTaxonomy);
|
||||
checkedItemsTaxonomy.removeAll(removeTaxonomies);
|
||||
}
|
||||
}
|
||||
@@ -755,3 +766,203 @@ public enum Taxonomy {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class Taxonomy {
|
||||
private String name;
|
||||
private String longName;
|
||||
private TaxonomyEnum taxonomyEnum;
|
||||
|
||||
public Taxonomy(String tax, boolean longName) {
|
||||
if (!longName) {
|
||||
this.taxonomyEnum = TaxonomyEnum.factory(tax);
|
||||
} else {
|
||||
this.taxonomyEnum = TaxonomyEnum.factoryLongName(tax);
|
||||
}
|
||||
if (taxonomyEnum != null){
|
||||
this.name = this.taxonomyEnum.toString();
|
||||
this.longName = this.taxonomyEnum.toLongNameString();
|
||||
} else {
|
||||
this.name = tax;
|
||||
this.longName = tax;
|
||||
}
|
||||
}
|
||||
|
||||
public Taxonomy(TaxonomyEnum taxonomyEnum) {
|
||||
this.taxonomyEnum = taxonomyEnum;
|
||||
this.name = this.taxonomyEnum.toString();
|
||||
this.longName = this.taxonomyEnum.toLongNameString();
|
||||
|
||||
}
|
||||
|
||||
// public Taxonomy(String name, String longName) {
|
||||
// this.name = name;
|
||||
// this.longName = longName;
|
||||
// }
|
||||
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String toLongNameString() {
|
||||
return this.longName;
|
||||
}
|
||||
|
||||
public TaxonomyEnum getTaxonomyEnum() {
|
||||
return this.taxonomyEnum;
|
||||
}
|
||||
|
||||
public static Taxonomy factory(String tax, Corpus corpus) {
|
||||
for (Taxonomy t : corpus.getTaxonomy()){
|
||||
if(tax.equals(t.toString()))
|
||||
return t;
|
||||
}
|
||||
return null;
|
||||
// return new Taxonomy(tax, false);
|
||||
}
|
||||
|
||||
public static Taxonomy factoryLongName(String tax, Corpus corpus) {
|
||||
for (Taxonomy t : corpus.getTaxonomy()){
|
||||
if(tax.equals(t.toLongNameString()))
|
||||
return t;
|
||||
}
|
||||
return null;
|
||||
// return new Taxonomy(tax, true);
|
||||
}
|
||||
|
||||
// public static ArrayList<Taxonomy> taxonomySelected(Taxonomy disjointTaxonomy) {
|
||||
// ArrayList<TaxonomyEnum> rTaxonomyEnum = TaxonomyEnum.taxonomySelected(disjointTaxonomy.getTaxonomyEnum());
|
||||
//
|
||||
// ArrayList<Taxonomy> r = new ArrayList<>();
|
||||
//
|
||||
// for(TaxonomyEnum t : rTaxonomyEnum){
|
||||
// r.add(new Taxonomy(t.toString(), false));
|
||||
// }
|
||||
//
|
||||
// return r;
|
||||
// }
|
||||
|
||||
public static ArrayList<Taxonomy> taxonomyDeselected(Taxonomy disjointTaxonomy){
|
||||
// ArrayList<TaxonomyEnum> r = new ArrayList<>();
|
||||
// Map<TaxonomyEnum, TaxonomyEnum> connections = new ConcurrentHashMap<>();
|
||||
// connections.put(DISKURZ_JAVNI, DISKURZ);
|
||||
// connections.put(DISKURZ_INFORMATIVNO_IZOBRAZEVALNI, DISKURZ_JAVNI);
|
||||
// connections.put(DISKURZ_RAZVEDRILNI, DISKURZ_JAVNI);
|
||||
// connections.put(DISKURZ_NEJAVNI, DISKURZ);
|
||||
// connections.put(DISKURZ_NEZASEBNI, DISKURZ_NEJAVNI);
|
||||
// connections.put(DISKURZ_ZASEBNI, DISKURZ_NEJAVNI);
|
||||
// connections.put(SITUACIJA_RADIO, SITUACIJA);
|
||||
// connections.put(SITUACIJA_TELEVIZIJA, SITUACIJA);
|
||||
// connections.put(KANAL_OSEBNI_STIK, KANAL);
|
||||
// connections.put(KANAL_TELEFON, KANAL);
|
||||
// connections.put(KANAL_RADIO, KANAL);
|
||||
// connections.put(KANAL_TELEVIZIJA, KANAL);
|
||||
//
|
||||
// connections.put(SSJ_KNJIZNO, SSJ_TISK);
|
||||
// connections.put(SSJ_LEPOSLOVNO, SSJ_KNJIZNO);
|
||||
// connections.put(SSJ_STROKOVNO, SSJ_KNJIZNO);
|
||||
// connections.put(SSJ_PERIODICNO, SSJ_TISK);
|
||||
// connections.put(SSJ_CASOPIS, SSJ_PERIODICNO);
|
||||
// connections.put(SSJ_REVIJA, SSJ_PERIODICNO);
|
||||
// connections.put(SSJ_DRUGO, SSJ_TISK);
|
||||
//
|
||||
// connections.put(FT_P_GOVORNI, FT_P_PRENOSNIK);
|
||||
// connections.put(FT_P_ELEKTRONSKI, FT_P_PRENOSNIK);
|
||||
// connections.put(FT_P_PISNI, FT_P_PRENOSNIK);
|
||||
// connections.put(FT_P_OBJAVLJENO, FT_P_PISNI);
|
||||
// connections.put(FT_P_KNJIZNO, FT_P_OBJAVLJENO);
|
||||
// connections.put(FT_P_PERIODICNO, FT_P_OBJAVLJENO);
|
||||
// connections.put(FT_P_CASOPISNO, FT_P_OBJAVLJENO);
|
||||
// connections.put(FT_P_DNEVNO, FT_P_CASOPISNO);
|
||||
// connections.put(FT_P_VECKRAT_TEDENSKO, FT_P_CASOPISNO);
|
||||
// connections.put(FT_P_CASOPISNO_TEDENSKO, FT_P_CASOPISNO);
|
||||
// connections.put(FT_P_REVIALNO, FT_P_PERIODICNO);
|
||||
// connections.put(FT_P_TEDENSKO, FT_P_REVIALNO);
|
||||
// connections.put(FT_P_STIRINAJSTDNEVNO, FT_P_REVIALNO);
|
||||
// connections.put(FT_P_MESECNO, FT_P_REVIALNO);
|
||||
// connections.put(FT_P_REDKEJE_KOT_MESECNO, FT_P_REVIALNO);
|
||||
// connections.put(FT_P_OBCASNO, FT_P_REVIALNO);
|
||||
// connections.put(FT_P_NEOBJAVLJENO, FT_P_PISNI);
|
||||
// connections.put(FT_P_JAVNO, FT_P_NEOBJAVLJENO);
|
||||
// connections.put(FT_P_INTERNO, FT_P_NEOBJAVLJENO);
|
||||
// connections.put(FT_P_ZASEBNO, FT_P_NEOBJAVLJENO);
|
||||
// connections.put(FT_UMETNOSTNA, FT_ZVRST);
|
||||
// connections.put(FT_PESNISKA, FT_UMETNOSTNA);
|
||||
// connections.put(FT_PROZNA, FT_UMETNOSTNA);
|
||||
// connections.put(FT_DRAMSKA, FT_UMETNOSTNA);
|
||||
// connections.put(FT_NEUMETNOSTNA, FT_ZVRST);
|
||||
// connections.put(FT_STROKOVNA, FT_NEUMETNOSTNA);
|
||||
// connections.put(FT_HID, FT_STROKOVNA);
|
||||
// connections.put(FT_NIT, FT_STROKOVNA);
|
||||
// connections.put(FT_NESTROKOVNA, FT_NEUMETNOSTNA);
|
||||
// connections.put(FT_PRAVNA, FT_NEUMETNOSTNA);
|
||||
// connections.put(FT_DA, FT_LEKTORIRANO);
|
||||
// connections.put(FT_NE, FT_LEKTORIRANO);
|
||||
//
|
||||
// TaxonomyEnum currentTaxonomy = disjointTaxonomy;
|
||||
// r.add(currentTaxonomy);
|
||||
// while(connections.containsKey(currentTaxonomy)){
|
||||
// currentTaxonomy = connections.get(currentTaxonomy);
|
||||
// r.add(currentTaxonomy);
|
||||
// }
|
||||
// Collections.reverse(r);
|
||||
// return r;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ArrayList<Taxonomy> convertStringListToTaxonomyList(ObservableList<String> stringList, Corpus corpus){
|
||||
ArrayList<Taxonomy> taxonomyList = new ArrayList<>();
|
||||
|
||||
for (String e : stringList) {
|
||||
for (Taxonomy t : corpus.getTaxonomy()){
|
||||
if (t.toLongNameString().equals(e)) {
|
||||
taxonomyList.add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
return taxonomyList;
|
||||
}
|
||||
|
||||
public static ArrayList<TaxonomyEnum> taxonomyToTaxonomyEnum(ArrayList<Taxonomy> taxonomy){
|
||||
System.out.println(taxonomy);
|
||||
if (taxonomy == null) {
|
||||
return null;
|
||||
}
|
||||
ArrayList<TaxonomyEnum> r = new ArrayList<>();
|
||||
for (Taxonomy t : taxonomy){
|
||||
if (t.taxonomyEnum == null){
|
||||
return null;
|
||||
}
|
||||
r.add(t.taxonomyEnum);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
public static ArrayList<Taxonomy> taxonomyEnumToTaxonomy(ArrayList<TaxonomyEnum> taxonomy, Corpus corpus){
|
||||
// ArrayList<Taxonomy> r = new ArrayList<>();
|
||||
// for (TaxonomyEnum t : taxonomy){
|
||||
// r.add(new Taxonomy(t));
|
||||
// }
|
||||
// return r;
|
||||
ArrayList<Taxonomy> r = new ArrayList<>();
|
||||
for (TaxonomyEnum te : taxonomy){
|
||||
for (Taxonomy t : corpus.getTaxonomy()){
|
||||
if (t.taxonomyEnum.equals(te)) {
|
||||
r.add(t);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
public static ArrayList<Taxonomy> modifyingTaxonomy(ArrayList<Taxonomy> taxonomy, ObservableList<String> checkedItems, Corpus corpus){
|
||||
ArrayList<TaxonomyEnum> checkedItemsTaxonomy = TaxonomyEnum.convertStringListToTaxonomyList(checkedItems, corpus);
|
||||
if (checkedItemsTaxonomy != null && corpus.getCorpusType() != CorpusType.VERT) {
|
||||
TaxonomyEnum.modifyingTaxonomy(Taxonomy.taxonomyToTaxonomyEnum(taxonomy), checkedItemsTaxonomy, corpus);
|
||||
return taxonomyEnumToTaxonomy(checkedItemsTaxonomy, corpus);
|
||||
} else {
|
||||
return convertStringListToTaxonomyList(checkedItems, corpus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user