Search in sources :

Example 1 with SuffixProvider

use of zemberek.morphology.lexicon.SuffixProvider in project lucene-solr-analysis-turkish by iorixxx.

the class Zemberek3StemFilterFactory method inform.

@Override
public void inform(ResourceLoader loader) throws IOException {
    if (dictionaryFiles == null || dictionaryFiles.trim().isEmpty()) {
        this.parser = TurkishWordParserGenerator.createWithDefaults().getParser();
        // Use default dictionaries shipped with Zemberek3.
        return;
    }
    List<String> lines = new ArrayList<>();
    List<String> files = splitFileNames(dictionaryFiles);
    if (files.size() > 0) {
        for (String file : files) {
            List<String> wlist = getLines(loader, file.trim());
            lines.addAll(wlist);
        }
    }
    if (lines.isEmpty()) {
        this.parser = TurkishWordParserGenerator.createWithDefaults().getParser();
        // Use default dictionaries shipped with Zemberek3.
        return;
    }
    SuffixProvider suffixProvider = new TurkishSuffixes();
    RootLexicon lexicon = new TurkishDictionaryLoader(suffixProvider).load(lines);
    DynamicLexiconGraph graph = new DynamicLexiconGraph(suffixProvider);
    graph.addDictionaryItems(lexicon);
    parser = new WordParser(graph);
}
Also used : SuffixProvider(zemberek.morphology.lexicon.SuffixProvider) TurkishDictionaryLoader(zemberek.morphology.lexicon.tr.TurkishDictionaryLoader) TurkishSuffixes(zemberek.morphology.lexicon.tr.TurkishSuffixes) ArrayList(java.util.ArrayList) RootLexicon(zemberek.morphology.lexicon.RootLexicon) DynamicLexiconGraph(zemberek.morphology.lexicon.graph.DynamicLexiconGraph) WordParser(zemberek.morphology.parser.WordParser)

Example 2 with SuffixProvider

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

the class WordAnalyzerFunctionalTest method getLexiconGraph.

private DynamicLexiconGraph getLexiconGraph(File... dictionaries) throws IOException {
    SuffixProvider suffixProvider = suffixes;
    RootLexicon lexicon = new RootLexicon();
    for (File dictionary : dictionaries) {
        new TurkishDictionaryLoader().loadInto(lexicon, dictionary);
    }
    DynamicLexiconGraph graph = new DynamicLexiconGraph(suffixProvider);
    graph.addDictionaryItems(lexicon);
    return graph;
}
Also used : SuffixProvider(zemberek.morphology.lexicon.SuffixProvider) TurkishDictionaryLoader(zemberek.morphology.lexicon.tr.TurkishDictionaryLoader) RootLexicon(zemberek.morphology.lexicon.RootLexicon) File(java.io.File) DynamicLexiconGraph(zemberek.morphology.lexicon.graph.DynamicLexiconGraph)

Example 3 with SuffixProvider

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

the class WordAnalyzerTest method getLexiconGraph.

private DynamicLexiconGraph getLexiconGraph(String... words) {
    SuffixProvider suffixProvider = new NounSuffixes();
    List<DictionaryItem> items = getItems(words);
    DynamicLexiconGraph graph = new DynamicLexiconGraph(suffixProvider);
    graph.addDictionaryItems(items);
    return graph;
}
Also used : DynamicSuffixProvider(zemberek.morphology.lexicon.graph.DynamicSuffixProvider) SuffixProvider(zemberek.morphology.lexicon.SuffixProvider) DictionaryItem(zemberek.morphology.lexicon.DictionaryItem) DynamicLexiconGraph(zemberek.morphology.lexicon.graph.DynamicLexiconGraph)

Aggregations

SuffixProvider (zemberek.morphology.lexicon.SuffixProvider)3 DynamicLexiconGraph (zemberek.morphology.lexicon.graph.DynamicLexiconGraph)3 RootLexicon (zemberek.morphology.lexicon.RootLexicon)2 TurkishDictionaryLoader (zemberek.morphology.lexicon.tr.TurkishDictionaryLoader)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 DictionaryItem (zemberek.morphology.lexicon.DictionaryItem)1 DynamicSuffixProvider (zemberek.morphology.lexicon.graph.DynamicSuffixProvider)1 TurkishSuffixes (zemberek.morphology.lexicon.tr.TurkishSuffixes)1 WordParser (zemberek.morphology.parser.WordParser)1