Search in sources :

Example 6 with Dictionary

use of zemberek.morphology.lexicon.proto.LexiconProto.Dictionary in project zemberek-nlp by ahmetaa.

the class DictionarySerializer method save.

public static void save(RootLexicon lexicon, Path outPath) throws IOException {
    Dictionary.Builder builder = Dictionary.newBuilder();
    for (DictionaryItem item : lexicon.getAllItems()) {
        builder.addItems(convertToProto(item));
    }
    Dictionary dictionary = builder.build();
    if (outPath.toFile().exists()) {
        Files.delete(outPath);
    }
    Files.write(outPath, dictionary.toByteArray(), StandardOpenOption.CREATE);
}
Also used : Dictionary(zemberek.morphology.lexicon.proto.LexiconProto.Dictionary)

Aggregations

Dictionary (zemberek.morphology.lexicon.proto.LexiconProto.Dictionary)6 LexiconProto (zemberek.morphology.lexicon.proto.LexiconProto)4 BufferedOutputStream (java.io.BufferedOutputStream)2 FileOutputStream (java.io.FileOutputStream)2 HashMap (java.util.HashMap)2 File (java.io.File)1 Path (java.nio.file.Path)1 TurkishMorphology (zemberek.morphology.TurkishMorphology)1 TurkishMorphology (zemberek.morphology.analysis.tr.TurkishMorphology)1