unifierConfig.setEquivalence("gender", "neutral",
preparePOSElement(".*[\\.:]n([\\.:].*)?"));
final Unifier uni = unifierConfig.createUnifier();
final AnalyzedToken sing1 = new AnalyzedToken("mały", "adj:sg:blahblah:m", "mały");
AnalyzedToken sing1a = new AnalyzedToken("mały", "adj:pl:blahblah:f", "mały");
AnalyzedToken sing1b = new AnalyzedToken("mały", "adj:pl:blahblah:f", "mały");
AnalyzedToken sing2 = new AnalyzedToken("zgarbiony", "adj:pl:blahblah:f", "zgarbiony");
final AnalyzedToken sing3 = new AnalyzedToken("człowiek", "subst:sg:blahblah:m", "człowiek");
final Map<String, List<String>> equiv = new HashMap<>();
equiv.put("number", null);
equiv.put("gender", null);
boolean satisfied = uni.isSatisfied(sing1, equiv);
satisfied |= uni.isSatisfied(sing1a, equiv);
satisfied |= uni.isSatisfied(sing1b, equiv);
uni.startUnify();
satisfied &= uni.isSatisfied(sing2, equiv);
uni.startNextToken();
satisfied &= uni.isSatisfied(sing3, equiv);
uni.startNextToken();
satisfied &= uni.getFinalUnificationValue(equiv);
assertEquals(false, satisfied);
uni.reset();
//now test the simplified interface
uni.isUnified(sing1, equiv, false);
uni.isUnified(sing1a, equiv, false);
uni.isUnified(sing1b, equiv, true);
uni.isUnified(sing2, equiv, true);
assertEquals(false, uni.isUnified(sing3, equiv, true));
uni.reset();
sing1a = new AnalyzedToken("osobiste", "adj:pl:nom.acc.voc:f.n.m2.m3:pos:aff", "osobisty");
sing1b = new AnalyzedToken("osobiste", "adj:sg:nom.acc.voc:n:pos:aff", "osobisty");
sing2 = new AnalyzedToken("godło", "subst:sg:nom.acc.voc:n", "godło");
uni.isUnified(sing1a, equiv, false);
uni.isUnified(sing1b, equiv, true);
assertEquals(true, uni.isUnified(sing2, equiv, true));
assertEquals("[osobiste[osobisty/adj:sg:nom.acc.voc:n:pos:aff*], godło[godło/subst:sg:nom.acc.voc:n*]]", Arrays.toString(uni.getFinalUnified()));
uni.reset();
//now test a case when the last reading doesn't match at all
sing1a = new AnalyzedToken("osobiste", "adj:pl:nom.acc.voc:f.n.m2.m3:pos:aff", "osobisty");
sing1b = new AnalyzedToken("osobiste", "adj:sg:nom.acc.voc:n:pos:aff", "osobisty");
final AnalyzedToken sing2a = new AnalyzedToken("godło", "subst:sg:nom.acc.voc:n", "godło");
final AnalyzedToken sing2b = new AnalyzedToken("godło", "indecl", "godło");
uni.isUnified(sing1a, equiv, false);
uni.isUnified(sing1b, equiv, true);
uni.isUnified(sing2a, equiv, false);
assertEquals(true, uni.isUnified(sing2b, equiv, true));
assertEquals("[osobiste[osobisty/adj:sg:nom.acc.voc:n:pos:aff*], godło[godło/subst:sg:nom.acc.voc:n*]]", Arrays.toString(uni.getFinalUnified()));
uni.reset();
//check if two features are left out correctly (both match)
AnalyzedToken plur1 = new AnalyzedToken("zgarbieni", "adj:pl:foobar:m", "zgarbiony");
AnalyzedToken plur2 = new AnalyzedToken("zgarbieni", "adj:pl:blabla:m", "zgarbiony");
AnalyzedToken plur3 = new AnalyzedToken("ludzie", "subst:pl:blabla:m", "człowiek");
AnalyzedToken plur4 = new AnalyzedToken("ludzie", "subst:pl:pampam:m", "człowiek");
uni.isUnified(plur1, equiv, false);
uni.isUnified(plur2, equiv, true);
uni.isUnified(plur3, equiv, false);
assertTrue(uni.isUnified(plur4, equiv, true));
assertEquals("[zgarbieni[zgarbiony/adj:pl:foobar:m*,zgarbiony/adj:pl:blabla:m*], " +
"ludzie[człowiek/subst:pl:blabla:m*,człowiek/subst:pl:pampam:m*]]", Arrays.toString(uni.getFinalUnified()));
//check with a sequence of many tokens
uni.reset();
AnalyzedToken case1a = new AnalyzedToken("xx", "abc:sg:f", "xx");
AnalyzedToken case1b = new AnalyzedToken("xx", "cde:pl:f", "xx");
AnalyzedToken case2a = new AnalyzedToken("yy", "abc:pl:f", "yy");
AnalyzedToken case2b = new AnalyzedToken("yy", "cde:as:f", "yy");
AnalyzedToken case2c = new AnalyzedToken("yy", "cde:pl:c", "yy");
AnalyzedToken case2d = new AnalyzedToken("yy", "abc:sg:f", "yy");
AnalyzedToken case2e = new AnalyzedToken("yy", "efg:aa:e", "yy");
uni.isUnified(case1a, equiv, false);
uni.isUnified(case1b, equiv, true);
uni.isUnified(case2a, equiv, false);
uni.isUnified(case2b, equiv, false);
uni.isUnified(case2c, equiv, false);
uni.isUnified(case2d, equiv, false);
assertTrue(uni.isUnified(case2e, equiv, true));
assertEquals("[xx[xx/abc:sg:f*,xx/cde:pl:f*], yy[yy/abc:pl:f*,yy/abc:sg:f*]]",
Arrays.toString(uni.getFinalUnified()));
uni.reset();
AnalyzedToken tokenComplex1_1 = new AnalyzedToken("xx", "abc:sg:f", "xx1");
AnalyzedToken tokenComplex1_2 = new AnalyzedToken("xx", "cde:pl:f", "xx2");
AnalyzedToken tokenComplex2_1 = new AnalyzedToken("yy", "abc:sg:f", "yy1");
AnalyzedToken tokenComplex2_2 = new AnalyzedToken("yy", "cde:pl:f", "yy2");
AnalyzedToken tokenComplex3 = new AnalyzedToken("zz", "cde:sg:f", "zz");
uni.isUnified(tokenComplex1_1, equiv, false);
uni.isUnified(tokenComplex1_2, equiv, true);
uni.isUnified(tokenComplex2_1, equiv, false);