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 MultipleHMKeys1 implements MultipleHMKeys {
    private final String k1;

    public MultipleHMKeys1(String k1) {
        this.k1 = k1;
    }

    public String getK1() {
        return k1;
    }

    public ArrayList<MultipleHMKeys> getSplittedMultipleHMKeys(){
        ArrayList<MultipleHMKeys> r = new ArrayList<>();
        String[] splitedK1 = k1.split("\\s+");
        for(int i = 0; i < splitedK1.length; i ++){
            MultipleHMKeys search = new MultipleHMKeys1(splitedK1[i]);
            r.add(search);
        }
        return r;
    }

    @Override
    public int hashCode() {
        return k1.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        return (obj instanceof MultipleHMKeys1) && ((MultipleHMKeys1) obj).k1.equals(k1);
    }

    public MultipleHMKeys[] splitNgramTo1grams(){
        String[] k1 = getK1().split(" ");
        MultipleHMKeys[] res = new MultipleHMKeys[k1.length];
        for(int i = 0; i < k1.length; i++){
            res[i] = new MultipleHMKeys1(k1[i]);
        }
        return res;
    }
}
