Search in sources :

Example 1 with LexiconMerger

use of com.joliciel.jochre.lexicon.LexiconMerger 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

FakeLexicon (com.joliciel.jochre.lexicon.FakeLexicon)1 Lexicon (com.joliciel.jochre.lexicon.Lexicon)1 LexiconMerger (com.joliciel.jochre.lexicon.LexiconMerger)1 TextFileLexicon (com.joliciel.jochre.lexicon.TextFileLexicon)1 File (java.io.File)1