Search in sources :

Example 6 with SuffixFormTemplate

use of zemberek.morphology.lexicon.SuffixFormTemplate in project zemberek-nlp by ahmetaa.

the class DynamicSuffixProviderTest method testSimpleFormGraph.

@Test
public void testSimpleFormGraph() {
    DynamicSuffixProvider provider = new TestSuffixProvider();
    Suffix sf1 = new Suffix("sf1");
    Suffix sf2 = new Suffix("sf2");
    Suffix sf3 = new Suffix("sf3");
    Suffix sf4 = new Suffix("sf4");
    SuffixForm set1 = new SuffixForm(1, "fs1", sf1, "abc");
    SuffixForm set2_1 = new SuffixForm(2, "fs2-1", sf2, "ali");
    SuffixForm set2_2 = new SuffixForm(3, "fs2-2", sf2, "kaan");
    SuffixForm set4 = new SuffixForm(4, "fs4", sf4, "akin");
    SuffixFormTemplate tmp1 = new SuffixFormTemplate(5, "tmp1", sf3, TerminationType.TRANSFER);
    // 
    // set4 -.........->set2_2
    // \       /
    // set1--->tmp1-/
    // |           \
    // .............-> set2_1        --- Direct link  ... indirect link.
    set1.connections.add(tmp1);
    set1.indirectConnections.add(set2_2);
    set4.connections.add(tmp1);
    set4.indirectConnections.add(set2_1);
    tmp1.connections.add(set2_1);
    tmp1.connections.add(set2_2);
    provider.registerForms(tmp1, set1, set4);
    Assert.assertEquals(1, set1.connections.size());
    Assert.assertFalse(set1.connections.contains(tmp1));
    SuffixForm nullSet1 = set1.connections.iterator().next();
    Assert.assertEquals("tmp1_1", nullSet1.getId());
    Assert.assertEquals(1, nullSet1.connections.size());
    Assert.assertTrue(nullSet1.connections.contains(set2_2));
    Assert.assertEquals(1, set4.connections.size());
    Assert.assertFalse(set4.connections.contains(tmp1));
    SuffixForm nullSet2 = set4.connections.iterator().next();
    Assert.assertEquals("tmp1_2", nullSet2.getId());
    Assert.assertEquals(1, nullSet2.connections.size());
    Assert.assertTrue(nullSet2.connections.contains(set2_1));
}
Also used : Suffix(zemberek.morphology.lexicon.Suffix) SuffixForm(zemberek.morphology.lexicon.SuffixForm) NullSuffixForm(zemberek.morphology.lexicon.NullSuffixForm) SuffixFormTemplate(zemberek.morphology.lexicon.SuffixFormTemplate) Test(org.junit.Test)

Aggregations

NullSuffixForm (zemberek.morphology.lexicon.NullSuffixForm)6 SuffixFormTemplate (zemberek.morphology.lexicon.SuffixFormTemplate)6 SuffixForm (zemberek.morphology.lexicon.SuffixForm)5 Test (org.junit.Test)4 Suffix (zemberek.morphology.lexicon.Suffix)4 ArrayList (java.util.ArrayList)1