Fixed slow combination of words and lemmas presentation
This commit is contained in:
@@ -44,11 +44,14 @@ public class Ngrams {
|
||||
|
||||
// generate proper MultipleHMKeys depending on filter data
|
||||
String key = wordToString(ngramCandidate, stats.getFilter().getCalculateFor());
|
||||
// String key = "aaaaaaaaaaaaaaaaaaaaaaa";
|
||||
|
||||
String lemma = "";
|
||||
String wordType = "";
|
||||
String msd = "";
|
||||
for (CalculateFor otherKey : stats.getFilter().getMultipleKeys()){
|
||||
if(otherKey.toString().equals("lema")){
|
||||
// lemma = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||||
lemma = wordToString(ngramCandidate, otherKey);
|
||||
} else if(otherKey.toString().equals("besedna vrsta")){
|
||||
wordType = wordToString(ngramCandidate, otherKey).substring(0, 1);
|
||||
@@ -222,7 +225,8 @@ public class Ngrams {
|
||||
private static void validateAndCountSkipgramCandidate(ArrayList<Word> skipgramCandidate, StatisticsNew stats) {
|
||||
// count if no regex is set or if it is & candidate passes it
|
||||
if (!stats.getFilter().hasMsd() || passesRegex(skipgramCandidate, stats.getFilter().getMsd())) {
|
||||
stats.updateResults(wordToString(skipgramCandidate, stats.getFilter().getCalculateFor()));
|
||||
stats.updateTaxonomyResults(new MultipleHMKeys(wordToString(skipgramCandidate, stats.getFilter().getCalculateFor()), "", "", ""),
|
||||
stats.getCorpus().getTaxonomy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
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 MultipleHMKeys {
|
||||
private final String key, lemma, wordType, msd;
|
||||
|
||||
private MultipleHMKeys actual_obj;
|
||||
public MultipleHMKeys(String key) {
|
||||
this.key = key;
|
||||
this.lemma = "";
|
||||
@@ -37,12 +40,7 @@ public final class MultipleHMKeys {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
// if(key2 == null){
|
||||
// return key1.hashCode();
|
||||
// } else if (key3 == null){
|
||||
// return key1.hashCode() ^ key2.hashCode();
|
||||
// }
|
||||
return key.hashCode() ^ lemma.hashCode() ^ wordType.hashCode() ^ msd.hashCode();
|
||||
return Objects.hash(key, lemma, wordType, msd);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -304,6 +304,10 @@ public class StatisticsNew {
|
||||
|
||||
}
|
||||
|
||||
public Map<String, Map<MultipleHMKeys, AtomicLong>> getTaxonomyResult() {
|
||||
return taxonomyResult;
|
||||
}
|
||||
|
||||
public void updateResults(String o) {
|
||||
// if not in map
|
||||
AtomicLong r = result.putIfAbsent(o, new AtomicLong(1));
|
||||
|
||||
Reference in New Issue
Block a user