use of com.joliciel.jochre.lexicon.CorpusLexiconBuilder in project jochre by urieli.
the class Jochre method doCommandBuildLexicon.
/**
* Rebuild the training corpus lexicon.
*/
public void doCommandBuildLexicon(File outputDir, CorpusSelectionCriteria criteria) {
try {
CorpusLexiconBuilder builder = new CorpusLexiconBuilder(criteria, jochreSession);
TextFileLexicon lexicon = builder.buildLexicon();
File textFile = new File(outputDir, "jochreCorpusLexicon.txt");
textFile.delete();
Writer textFileWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(textFile, true), "UTF8"));
try {
lexicon.writeFile(textFileWriter);
} finally {
textFileWriter.flush();
textFileWriter.close();
}
File lexiconFile = new File(outputDir, "jochreCorpusLexicon.zip");
lexicon.serialize(lexiconFile);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations