Search in sources :

Example 6 with DynamicLexiconGraph

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

the class SimpleGeneratorTest method regenerateTest.

@Test
public void regenerateTest() throws IOException {
    DynamicLexiconGraph graph = getLexicon();
    WordAnalyzer parser = new WordAnalyzer(graph);
    SimpleGenerator generator = new SimpleGenerator(graph);
    List<String> parseables = SimpleTextReader.trimmingUTF8Reader(new File(Resources.getResource("parseable.txt").getFile())).asStringList();
    for (String parseable : parseables) {
        System.out.println(parseable);
        List<WordAnalysis> parseResults = parser.analyze(parseable);
        for (WordAnalysis parseResult : parseResults) {
            System.out.println(parseResult);
            String[] res = generator.generate(parseResult.dictionaryItem, parseResult.getSuffixes());
            System.out.println(Arrays.toString(res));
            boolean found = false;
            for (String re : res) {
                if (re.equals(parseable)) {
                    found = true;
                }
            }
            Assert.assertTrue("Error in:" + parseable + " with parse:" + parseResult, found);
        }
    }
}
Also used : WordAnalyzer(zemberek.morphology.analysis.WordAnalyzer) WordAnalysis(zemberek.morphology.analysis.WordAnalysis) DynamicLexiconGraph(zemberek.morphology.lexicon.graph.DynamicLexiconGraph) File(java.io.File) SimpleGenerator(zemberek.morphology.generator.SimpleGenerator) Test(org.junit.Test)

Example 7 with DynamicLexiconGraph

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

the class WordAnalyzerFunctionalTest method simpleParse.

@Test
public void simpleParse() throws IOException {
    DynamicLexiconGraph graph = getLexiconGraph(DEV_LEXICON_FILE);
    WordAnalyzer wordAnalyzer = new WordAnalyzer(graph);
    List<String> parseables = SimpleTextReader.trimmingUTF8Reader(PARSEABLES_FILE).asStringList();
    for (String parseable : parseables) {
        List<WordAnalysis> results = wordAnalyzer.analyze(parseable);
        if (results.size() > 0) {
            // System.out.print(parseable + " : ");
            for (WordAnalysis parseResult : results) {
                System.out.println(parseable + " -> " + parseResult.formatOflazer() + "   ");
            }
        // System.out.println();
        } else {
            System.out.println("ERROR:" + parseable);
            wordAnalyzer.dump(parseable);
        }
    // Assert.assertTrue("Could not parses valid word:" + parseable, parser.parses(parseable).size() > 0);
    }
}
Also used : DynamicLexiconGraph(zemberek.morphology.lexicon.graph.DynamicLexiconGraph) Test(org.junit.Test)

Example 8 with DynamicLexiconGraph

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

the class WordAnalyzerTest method testInverseHarmony.

@Test
public void testInverseHarmony() {
    DynamicLexiconGraph graph = getLexiconGraph("saat [A: NoVoicing, InverseHarmony]");
    assertHasParses(graph, "saate", "saat", "saatler", "saatlere");
    assertUnParseable(graph, "saata", "saatlar", "saada", "saade");
}
Also used : DynamicLexiconGraph(zemberek.morphology.lexicon.graph.DynamicLexiconGraph) Test(org.junit.Test)

Example 9 with DynamicLexiconGraph

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

the class WordAnalyzerTest method testMultiWordDictionary.

@Test
public void testMultiWordDictionary() {
    DynamicLexiconGraph graph = getLexiconGraph("armut", "elma", "kabak", "kek");
    assertHasParses(graph, "armuda", "armutlara", "elmacığa", "keke", "kekçiklere");
}
Also used : DynamicLexiconGraph(zemberek.morphology.lexicon.graph.DynamicLexiconGraph) Test(org.junit.Test)

Example 10 with DynamicLexiconGraph

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

the class CompoundWordsTest method getParser.

private WordAnalyzer getParser(String... lines) {
    DynamicLexiconGraph graph = new DynamicLexiconGraph(suffixProvider);
    graph.addDictionaryItems(new TurkishDictionaryLoader().load(lines));
    return new WordAnalyzer(graph);
}
Also used : TurkishDictionaryLoader(zemberek.morphology.lexicon.tr.TurkishDictionaryLoader) DynamicLexiconGraph(zemberek.morphology.lexicon.graph.DynamicLexiconGraph)

Aggregations

DynamicLexiconGraph (zemberek.morphology.lexicon.graph.DynamicLexiconGraph)20 Test (org.junit.Test)14 File (java.io.File)5 WordAnalysis (zemberek.morphology.analysis.WordAnalysis)5 WordAnalyzer (zemberek.morphology.analysis.WordAnalyzer)5 SimpleGenerator (zemberek.morphology.generator.SimpleGenerator)5 TurkishDictionaryLoader (zemberek.morphology.lexicon.tr.TurkishDictionaryLoader)5 RootLexicon (zemberek.morphology.lexicon.RootLexicon)3 SuffixProvider (zemberek.morphology.lexicon.SuffixProvider)3 ArrayList (java.util.ArrayList)2 Ignore (org.junit.Ignore)1 DictionaryItem (zemberek.morphology.lexicon.DictionaryItem)1 Suffix (zemberek.morphology.lexicon.Suffix)1 DynamicSuffixProvider (zemberek.morphology.lexicon.graph.DynamicSuffixProvider)1 TurkishSuffixes (zemberek.morphology.lexicon.tr.TurkishSuffixes)1 WordParser (zemberek.morphology.parser.WordParser)1