package basics.collections.index;

import basics.testing.Test;
import basics.utl.SUtl;

public class MultiLangIndex extends MultiIndexList<MultiLang>
{
public MultiLangIndex(int n)
{
   super(n);
}

public void add(MultiLang ml)
{
   int x = super.enshure(ml);
   for(String l : ml.languages)
      super.addKey(x, 0, l);
   super.addKey(ml, 1, ml.scriptType);
}



public static void main(String [] args)
{
   MultiLangIndex.unittest();
}

public static void unittest()
{
   MultiLangIndex I = new MultiLangIndex(2);
   I.add(new MultiLang("hallo", SUtl.split("de,en"), "lat"));
   Test.printout("pk hallo: %", I.get("hallo"));
   I.add(new MultiLang("two", SUtl.split("en"), "lat"));
   I.add(new MultiLang("drei", SUtl.split("de"), "lat"));
   I.add(new MultiLang("salem", SUtl.split("ar"), "a"));
   I.add(new MultiLang("halem", SUtl.split("ar"), "a"));
   I.add(new MultiLang("harlem", SUtl.split("ar"), "a"));
   //   I.add(new MultiLang("chin", SUtl.split("chi"), "h"));
   //   Test.printout("pk drei: %", I.get("drei"));
   Test.printout("fk1 de: %", SUtl.join(I.get(0, "de"), " "));
   Test.printout("fk1 en: %", SUtl.join(I.get(0, "en"), " "));
   //   Test.printout("fk1 ar: %", SUtl.join(I.get(0, "ar"), " "));
   //   Test.printout("fk2 a: %", SUtl.join(I.get(1, "a"), " "));
   Test.printout("fk2 lat: %", SUtl.join(I.get(1, "lat"), " "));
   Test.printout("fk2 a: %", SUtl.join(I.get(1, "a"), " "));
   String term = "alem";
   double cutoff = 0.5;
//   for(Match<MultiLang> mml : I.retrieveFuzzy(term, cutoff, true, null))
//      Test.printout("FUZZY get(% -> %): % %", term, cutoff, mml.content, mml.quality);
//   term = "kalem";
//   cutoff = 0.6;
//   for(Match<MultiLang> mml : I.retrieveFuzzy(term, cutoff, true, null))
//      Test.printout("FUZZY get(% -> %): % %", term, cutoff, mml.content, mml.quality);
   term = "mat";
   cutoff = 0.6;
   for(Match<MultiLang> mml : I.retrieveFuzzy(term, cutoff, false, new int[]{0,1}))
      Test.printout("FUZZY get(% -> %): % %", term, cutoff, mml.content, mml.quality);
}
}
