Java Reference
In-Depth Information
new Classified<>(text, classification);
classifier.handle(classified);
} catch (IOException ex) {
// Handle exceptions
}
}
Note
You can alternately use the
com.aliasi.util.Files
class instead in
java.io.File
, otherwise the
readFromFile
method will not be available.
The classifier can be serialized for later use as shown here. The
AbstractExternal-
izable
class is a utility class that supports the serialization of objects. It has a static
compileTo
method that accepts a
Compilable
instance and a
File
object. It writes
the object to the file, as follows:
try {
AbstractExternalizable.compileTo( (Compilable)
classifier,
new File("classifier.model"));
} catch (IOException ex) {
// Handle exceptions
}
The loading of the classifier will be illustrated in the
Classifying text using LingPipe
sec-
tion later in this chapter.
Using other training categories
Other newsgroups data can be found at
http://qwone.com/~jason/20Newsgroups/
. These
collections of data can be used to train other models as listed in the following table. Al-
though there are only 20 categories, they can be useful training models. Three different
downloads are available where some have been sorted and in others, duplicate data has
been removed:
Newsgroups
comp.graphics
sci.crypt