Added some performance measures

This commit is contained in:
2018-08-09 09:21:06 +02:00
parent 179f09c4bd
commit 9b5fa4616b
24 changed files with 734 additions and 379 deletions

View File

@@ -5,49 +5,16 @@ import java.util.Objects;
/*
Created for when words are sorted by multiple keys, i.e. not just lemmas but lemmas and msd simultaneously.
*/
public final class MultipleHMKeys {
private final String key, lemma, wordType, msd;
private MultipleHMKeys actual_obj;
public MultipleHMKeys(String key) {
this.key = key;
this.lemma = "";
this.wordType = "";
this.msd = "";
}
public MultipleHMKeys(String key, String lemma, String wordType, String msd) {
this.key = key;
this.lemma = lemma;
this.wordType = wordType;
this.msd = msd;
}
public String getKey() {
return key;
}
public String getLemma() {
return lemma;
}
public String getWordType() {
return wordType;
}
public String getMsd() {
return msd;
}
public interface MultipleHMKeys {
String getK1();
String getK2();
String getK3();
String getK4();
String getK5();
@Override
public int hashCode() {
return Objects.hash(key, lemma, wordType, msd);
}
int hashCode();
@Override
public boolean equals(Object obj) {
return (obj instanceof MultipleHMKeys) && ((MultipleHMKeys) obj).key.equals(key)
&& ((MultipleHMKeys) obj).lemma.equals(lemma)
&& ((MultipleHMKeys) obj).wordType.equals(wordType)
&& ((MultipleHMKeys) obj).msd.equals(msd);
}
boolean equals(Object obj);
}

View File

@@ -0,0 +1,44 @@
package data;
import java.util.Objects;
/*
Created for when words are sorted by multiple keys, i.e. not just lemmas but lemmas and msd simultaneously.
*/
public final class MultipleHMKeys1 implements MultipleHMKeys {
private final String k1;
public MultipleHMKeys1(String k1) {
this.k1 = k1;
}
public String getK1() {
return k1;
}
public String getK2() {
return null;
}
public String getK3() {
return null;
}
public String getK4() {
return null;
}
public String getK5() {
return null;
}
@Override
public int hashCode() {
return k1.hashCode();
}
@Override
public boolean equals(Object obj) {
return (obj instanceof MultipleHMKeys1) && ((MultipleHMKeys1) obj).k1.equals(k1);
}
}

View File

@@ -0,0 +1,49 @@
package data;
import java.util.Objects;
/*
Created for when words are sorted by multiple keys, i.e. not just lemmas but lemmas and msd simultaneously.
*/
public final class MultipleHMKeys2 implements MultipleHMKeys {
private final String k1, k2;
public MultipleHMKeys2(String k1, String k2) {
this.k1 = k1;
this.k2 = k2;
}
public String getK1() {
return k1;
}
public String getK2() {
return k2;
}
public String getK3() {
return null;
}
public String getK4() {
return null;
}
public String getK5() {
return null;
}
@Override
public int hashCode() {
return Objects.hash(k1, k2);
// return key.hashCode();
}
@Override
public boolean equals(Object obj) {
return (obj instanceof MultipleHMKeys2) && ((MultipleHMKeys2) obj).k1.equals(k1)
&& ((MultipleHMKeys2) obj).k2.equals(k2);
// return (obj instanceof MultipleHMKeys) && ((MultipleHMKeys) obj).key.equals(key);
}
}

View File

@@ -0,0 +1,48 @@
package data;
import java.util.Objects;
/*
Created for when words are sorted by multiple keys, i.e. not just lemmas but lemmas and msd simultaneously.
*/
public final class MultipleHMKeys3 implements MultipleHMKeys {
private final String k1, k2, k3;
public MultipleHMKeys3(String k1, String k2, String k3) {
this.k1 = k1;
this.k2 = k2;
this.k3 = k3;
}
public String getK1() {
return k1;
}
public String getK2() {
return k2;
}
public String getK3() {
return k3;
}
public String getK4() {
return null;
}
public String getK5() {
return null;
}
@Override
public int hashCode() {
return Objects.hash(k1, k2, k3);
}
@Override
public boolean equals(Object obj) {
return (obj instanceof MultipleHMKeys3) && ((MultipleHMKeys3) obj).k1.equals(k1)
&& ((MultipleHMKeys3) obj).k2.equals(k2)
&& ((MultipleHMKeys3) obj).k3.equals(k3);
}
}

View File

@@ -0,0 +1,50 @@
package data;
import java.util.Objects;
/*
Created for when words are sorted by multiple keys, i.e. not just lemmas but lemmas and msd simultaneously.
*/
public final class MultipleHMKeys4 implements MultipleHMKeys {
private final String k1, k2, k3, k4;
public MultipleHMKeys4(String k1, String k2, String k3, String k4) {
this.k1 = k1;
this.k2 = k2;
this.k3 = k3;
this.k4 = k4;
}
public String getK1() {
return k1;
}
public String getK2() {
return k2;
}
public String getK3() {
return k3;
}
public String getK4() {
return k4;
}
public String getK5() {
return null;
}
@Override
public int hashCode() {
return Objects.hash(k1, k2, k3, k4);
}
@Override
public boolean equals(Object obj) {
return (obj instanceof MultipleHMKeys4) && ((MultipleHMKeys4) obj).k1.equals(k1)
&& ((MultipleHMKeys4) obj).k2.equals(k2)
&& ((MultipleHMKeys4) obj).k3.equals(k3)
&& ((MultipleHMKeys4) obj).k4.equals(k4);
}
}

View File

@@ -0,0 +1,52 @@
package data;
import java.util.Objects;
/*
Created for when words are sorted by multiple keys, i.e. not just lemmas but lemmas and msd simultaneously.
*/
public final class MultipleHMKeys5 implements MultipleHMKeys {
private final String k1, k2, k3, k4, k5;
public MultipleHMKeys5(String k1, String k2, String k3, String k4, String k5) {
this.k1 = k1;
this.k2 = k2;
this.k3 = k3;
this.k4 = k4;
this.k5 = k5;
}
public String getK1() {
return k1;
}
public String getK2() {
return k2;
}
public String getK3() {
return k3;
}
public String getK4() {
return k4;
}
public String getK5() {
return k5;
}
@Override
public int hashCode() {
return Objects.hash(k1, k2, k3, k4, k5);
}
@Override
public boolean equals(Object obj) {
return (obj instanceof MultipleHMKeys5) && ((MultipleHMKeys5) obj).k1.equals(k1)
&& ((MultipleHMKeys5) obj).k2.equals(k2)
&& ((MultipleHMKeys5) obj).k3.equals(k3)
&& ((MultipleHMKeys5) obj).k4.equals(k4)
&& ((MultipleHMKeys5) obj).k5.equals(k5);
}
}

View File

@@ -7,30 +7,30 @@ public class Sentence {
private List<Word> words;
private String taksonomija;
private List<String> taxonomy;
// GOS
private String type;
private Map<String, String> properties;
public Sentence(List<Word> words, String taksonomija) {
public Sentence(List<Word> words, List<String> taxonomy) {
this.words = words;
this.taksonomija = taksonomija;
this.taxonomy = taxonomy;
}
public Sentence(List<Word> words) {
this.words = words;
}
// public Sentence(List<Word> words) {
// this.words = words;
// }
public Sentence(List<Word> words, String taksonomija, Map<String, String> properties) {
public Sentence(List<Word> words, List<String> taxonomy, Map<String, String> properties) {
this.words = words;
this.taksonomija = taksonomija;
this.taxonomy = taxonomy;
this.properties = properties;
}
public Sentence(List<Word> words, String taksonomija, String type) {
public Sentence(List<Word> words, List<String> taxonomy, String type) {
this.words = words;
this.taksonomija = taksonomija;
this.taxonomy = taxonomy;
this.type = type;
}
@@ -38,8 +38,8 @@ public class Sentence {
return words;
}
public String getTaxonomy() {
return taksonomija;
public List<String> getTaxonomy() {
return taxonomy;
}
public List<Word> getSublist(int indexFrom, int indexTo) {

View File

@@ -213,7 +213,7 @@ public class StatisticsNew {
removeMinimalOccurrences(taxonomyResult.get("Total"), filter.getMinimalOccurrences());
removeMinimalTaxonomy(taxonomyResult, filter.getMinimalTaxonomy());
stats.add(ImmutablePair.of(resultTitle, getSortedResult(taxonomyResult.get("Total"), Util.getValidInt(limit))));
Export.SetToCSV(stats, corpus.getChosenResultsLocation(), headerInfoBlock(), taxonomyResult);
Export.SetToCSV(stats, corpus.getChosenResultsLocation(), headerInfoBlock(), taxonomyResult, filter);
return true;
}
@@ -376,7 +376,7 @@ public class StatisticsNew {
}
public void updateResultsNestedSuffix(String key, String stringValue) {
MultipleHMKeys mkStringValue = new MultipleHMKeys(stringValue);
MultipleHMKeys mkStringValue = new MultipleHMKeys1(stringValue);
if (resultNestedSuffix.containsKey(key)) {
// if not in map
@@ -397,7 +397,7 @@ public class StatisticsNew {
}
public void updateResultsNestedPrefix(String key, String stringValue) {
MultipleHMKeys mkStringValue = new MultipleHMKeys(stringValue);
MultipleHMKeys mkStringValue = new MultipleHMKeys1(stringValue);
if (resultNestedPrefix.containsKey(key)) {
// if not in map

View File

@@ -16,8 +16,7 @@ public class Word implements Serializable {
private String word;
private String lemma;
private String msd;
// private String msd;
private List<String> taxonomy;
private String normalizedWord;
private final HashSet<Character> VOWELS = new HashSet<>(Arrays.asList('a', 'e', 'i', 'o', 'u'));
/**
@@ -41,7 +40,8 @@ public class Word implements Serializable {
//private char besedna_vrsta;
public Word(String word, String lemma, String msd) {
this.lemma = lemma;
this.msd = normalizeMsd(msd);
this.msd = msd; //normalizeMsd(msd);
this.normalizedWord = "";
// veliko zacetnico ohranimo samo za lastna imena
if (!ValidationUtil.isEmpty(this.msd) && !(this.msd.charAt(0) == 'S'
@@ -53,12 +53,11 @@ public class Word implements Serializable {
}
}
//private char besedna_vrsta;
public Word(String word, String lemma, String msd, List<String> taxonomy) {
public Word(String word, String lemma, String msd, String normalizedWord) {
this.lemma = lemma;
// this.msd = normalizeMsd(msd);
this.msd = msd;
this.taxonomy = taxonomy;
this.normalizedWord = normalizedWord;
// veliko zacetnico ohranimo samo za lastna imena
if (!ValidationUtil.isEmpty(this.msd) && !(this.msd.charAt(0) == 'S'
@@ -73,21 +72,21 @@ public class Word implements Serializable {
public Word() {
}
/**
* Appends a number of '-' to msds which are not properly sized.
* E.g. nouns should have 5 attributes, yet the last one isn't always defined (Somei vs. Sometd)
*
* @param msdInput
*
* @return
*/
private String normalizeMsd(String msdInput) {
if (ValidationUtil.isEmpty(msdInput)) {
return "";
} else {
return StringUtils.rightPad(msdInput, Msd.getMsdLengthForType(msdInput), PAD_CHARACTER);
}
}
// /**
// * Appends a number of '-' to msds which are not properly sized.
// * E.g. nouns should have 5 attributes, yet the last one isn't always defined (Somei vs. Sometd)
// *
// * @param msdInput
// *
// * @return
// */
// private String normalizeMsd(String msdInput) {
// if (ValidationUtil.isEmpty(msdInput)) {
// return "";
// } else {
// return StringUtils.rightPad(msdInput, Msd.getMsdLengthForType(msdInput), PAD_CHARACTER);
// }
// }
public Word(String word) {
this.word = word;
@@ -119,10 +118,6 @@ public class Word implements Serializable {
this.word = word;
}
public List<String> getTaxonomy() {
return taxonomy;
}
public String getLemma() {
return lemma;
}
@@ -139,6 +134,14 @@ public class Word implements Serializable {
this.msd = msd;
}
public String getNormalizedWord() {
return normalizedWord;
}
public void setNormalizedWord(String normalizedWord) {
this.normalizedWord = normalizedWord;
}
public String toString() {
StringBuilder sb = new StringBuilder();
@@ -150,6 +153,8 @@ public class Word implements Serializable {
.append("\n")
.append("msd:\t")
.append(getMsd())
.append("normalized word:\t")
.append(getNormalizedWord())
.append("\n");
return sb.toString();