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);
}
}
}
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);
}
}
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");
}
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");
}
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);
}
Aggregations