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 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 ArrayList getSplittedMultipleHMKeys(){ ArrayList r = new ArrayList<>(); String[] splitedK1 = k1.split("\\s+"); String[] splitedK2 = k2.split("\\s+"); String[] splitedK3 = k3.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 && i < splitedK3.length)){ continue; } MultipleHMKeys search = new MultipleHMKeys3(splitedK1[i], splitedK2[i], splitedK3[i]); r.add(search); } return r; } @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); } public MultipleHMKeys[] splitNgramTo1grams(){ String[] k1 = getK1().split(" "); String[] k2 = getK2().split(" "); String[] k3 = getK3().split(" "); MultipleHMKeys[] res = new MultipleHMKeys[k1.length]; for(int i = 0; i < k1.length; i++){ res[i] = new MultipleHMKeys3(k1[i], k2[i], k3[i]); } return res; } }