package data; import java.util.ArrayList; 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 ArrayList getSplittedMultipleHMKeys(){ ArrayList r = new ArrayList<>(); String[] splitedK1 = k1.split("\\s+"); String[] splitedK2 = k2.split("\\s+"); for(int i = 0; i < splitedK1.length; i ++){ // in GOS words and normalized words may not both have specific word due to anon if(!(i < splitedK2.length)){ continue; } MultipleHMKeys search = new MultipleHMKeys2(splitedK1[i], splitedK2[i]); r.add(search); } return r; } @Override public int hashCode() { return Objects.hash(k1, k2); } @Override public boolean equals(Object obj) { return (obj instanceof MultipleHMKeys2) && ((MultipleHMKeys2) obj).k1.equals(k1) && ((MultipleHMKeys2) obj).k2.equals(k2); } public MultipleHMKeys[] splitNgramTo1grams(){ String[] k1 = getK1().split(" "); String[] k2 = getK2().split(" "); MultipleHMKeys[] res = new MultipleHMKeys[k1.length]; for(int i = 0; i < k1.length; i++){ res[i] = new MultipleHMKeys2(k1[i], k2[i]); } return res; } }