uni.setEquivalence("gender", "masculine", mascElement);
final Element neutElement = new Element("", false, false, false);
neutElement.setPosElement(".*[\\.:]n([\\.:].*)?", true, false);
uni.setEquivalence("gender", "neutral", neutElement);
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();
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));