Search in sources :

Example 11 with TextFileLexicon

use of com.joliciel.jochre.lexicon.TextFileLexicon in project jochre by urieli.

the class JochreSession method readLexicon.

protected Lexicon readLexicon(File lexiconDir) {
    Lexicon myLexicon = null;
    if (lexiconDir.isDirectory()) {
        LexiconMerger lexiconMerger = new LexiconMerger();
        File[] lexiconFiles = lexiconDir.listFiles();
        for (File lexiconFile : lexiconFiles) {
            if (lexiconFile.getName().endsWith(".txt")) {
                TextFileLexicon textFileLexicon = new TextFileLexicon(lexiconFile, this.encoding);
                lexiconMerger.addLexicon(textFileLexicon);
            } else {
                Lexicon textFileLexicon = TextFileLexicon.deserialize(lexiconFile);
                lexiconMerger.addLexicon(textFileLexicon);
            }
        }
        myLexicon = lexiconMerger;
    } else {
        if (lexiconDir.getName().endsWith(".txt")) {
            TextFileLexicon textFileLexicon = new TextFileLexicon(lexiconDir, this.encoding);
            myLexicon = textFileLexicon;
        } else {
            Lexicon textFileLexicon = TextFileLexicon.deserialize(lexiconDir);
            myLexicon = textFileLexicon;
        }
    }
    return myLexicon;
}
Also used : LexiconMerger(com.joliciel.jochre.lexicon.LexiconMerger) FakeLexicon(com.joliciel.jochre.lexicon.FakeLexicon) TextFileLexicon(com.joliciel.jochre.lexicon.TextFileLexicon) Lexicon(com.joliciel.jochre.lexicon.Lexicon) TextFileLexicon(com.joliciel.jochre.lexicon.TextFileLexicon) File(java.io.File)

Aggregations

TextFileLexicon (com.joliciel.jochre.lexicon.TextFileLexicon)11 File (java.io.File)7 BufferedWriter (java.io.BufferedWriter)6 FileOutputStream (java.io.FileOutputStream)6 OutputStreamWriter (java.io.OutputStreamWriter)6 Writer (java.io.Writer)6 Lexicon (com.joliciel.jochre.lexicon.Lexicon)5 Scanner (java.util.Scanner)5 Date (java.util.Date)4 CorpusLexiconBuilder (com.joliciel.jochre.lexicon.CorpusLexiconBuilder)2 LexiconErrorWriter (com.joliciel.jochre.lexicon.LexiconErrorWriter)2 UnknownWordListWriter (com.joliciel.jochre.lexicon.UnknownWordListWriter)2 IOException (java.io.IOException)2 BeamSearchImageAnalyser (com.joliciel.jochre.analyser.BeamSearchImageAnalyser)1 ErrorLogger (com.joliciel.jochre.analyser.ErrorLogger)1 FScoreObserver (com.joliciel.jochre.analyser.FScoreObserver)1 ImageAnalyser (com.joliciel.jochre.analyser.ImageAnalyser)1 LetterAssigner (com.joliciel.jochre.analyser.LetterAssigner)1 LetterGuessObserver (com.joliciel.jochre.analyser.LetterGuessObserver)1 OriginalShapeLetterAssigner (com.joliciel.jochre.analyser.OriginalShapeLetterAssigner)1