April 2019
Beginner to intermediate
386 pages
11h 20m
English
We used the AbstractExternalizable class's static readObject method to read in the model, which was cast as an instance of the LMClassifier class:
LMClassifier lmClassifier = (LMClassifier) AbstractExternalizable .readObject(new File("langid-leipzig.classifier"));
We used the classify method to return a classification for each text entry in ArrayList. The bestCategory method was then applied to return the language code for the language identified, as shown:
for (String text : textList) { Classification classification = lmClassifier.classify(text); System.out.println("Best Language: " + classification.bestCategory());}
Read now
Unlock full access