public class ClassifierCombiner<IN extends CoreMap & HasWord> extends AbstractSequenceClassifier<IN>
This is a pure AbstractSequenceClassifier, i.e., it sets the AnswerAnnotation label. If you work with NER classifiers, you should use NERClassifierCombiner. This class inherits from ClassifierCombiner, and takes care that all AnswerAnnotations are also copied to NERAnnotation.
You can specify up to 10 base classifiers using the -loadClassifier1 to -loadClassifier10 properties. We also maintain the older usage when only two base classifiers were accepted, specified using -loadClassifier and -loadAuxClassifier.
ms 2009: removed all NER functionality (see NERClassifierCombiner), changed code so it accepts an arbitrary number of base classifiers, removed dead code.
classIndex, featureFactories, flags, knownLCWords, pad, windowSize
Constructor and Description |
---|
ClassifierCombiner(AbstractSequenceClassifier<IN>... classifiers)
Combines a series of base classifiers.
|
ClassifierCombiner(edu.stanford.nlp.ie.ClassifierCombiner.CombinationMode combinationMode,
String... loadPaths)
Loads a series of base classifiers from the paths specified using the
Properties specified.
|
ClassifierCombiner(ObjectInputStream ois,
Properties props) |
ClassifierCombiner(Properties p) |
ClassifierCombiner(Properties props,
edu.stanford.nlp.ie.ClassifierCombiner.CombinationMode combinationMode,
String... loadPaths)
Loads a series of base classifiers from the paths specified using the
Properties specified.
|
ClassifierCombiner(String... loadPaths)
Loads a series of base classifiers from the paths specified.
|
Modifier and Type | Method and Description |
---|---|
List<IN> |
classify(List<IN> tokens)
Generates the AnswerAnnotation labels of the combined model for the given
tokens, storing them in place in the tokens.
|
List<IN> |
classifyWithGlobalInformation(List<IN> tokenSeq,
CoreMap doc,
CoreMap sent)
|
static void |
examineCRF(ClassifierCombiner cc,
String crfNameOrIndex,
SeqClassifierFlags flags,
String testFile,
String testFiles,
DocumentReaderAndWriter<CoreLabel> readerAndWriter) |
static edu.stanford.nlp.ie.ClassifierCombiner.CombinationMode |
extractCombinationMode(Properties p)
Either finds COMBINATION_MODE_PROPERTY or returns a default value.
|
static edu.stanford.nlp.ie.ClassifierCombiner.CombinationMode |
extractCombinationModeSafe(Properties p)
Either finds COMBINATION_MODE_PROPERTY or returns a default
value.
|
static ClassifierCombiner |
getClassifier(ObjectInputStream ois,
Properties props) |
static ClassifierCombiner |
getClassifier(String loadPath,
Properties props) |
Set<String> |
labels() |
void |
loadClassifier(ObjectInputStream in,
Properties props)
Load a classifier from the specified input stream.
|
static <INN extends CoreMap & HasWord> |
loadClassifierFromPath(Properties props,
String path) |
static void |
main(String[] args)
Some basic testing of the ClassifierCombiner.
|
void |
serializeClassifier(ObjectOutputStream oos)
Serialize a sequence classifier to an object output stream
|
void |
serializeClassifier(String serializePath)
Serialize a sequence classifier to a file on the given path.
|
static void |
showCCInfo(ClassifierCombiner cc) |
void |
train(Collection<List<IN>> docs,
DocumentReaderAndWriter<IN> readerAndWriter)
Trains a classifier from a Collection of sequences.
|
apply, backgroundSymbol, classify, classifyAndWriteAnswers, classifyAndWriteAnswers, classifyAndWriteAnswers, classifyAndWriteAnswers, classifyAndWriteAnswers, classifyAndWriteAnswers, classifyAndWriteAnswers, classifyAndWriteAnswersKBest, classifyAndWriteAnswersKBest, classifyAndWriteViterbiSearchGraph, classifyFile, classifyFilesAndWriteAnswers, classifyFilesAndWriteAnswers, classifyKBest, classifyRaw, classifySentence, classifySentenceWithGlobalInformation, classifyStdin, classifyStdin, classifyToCharacterOffsets, classifyToString, classifyToString, classifyWithInlineXML, countResults, countResultsSegmenter, defaultReaderAndWriter, dumpFeatures, finalizeClassification, getKnownLCWords, getSampler, getSequenceModel, loadClassifier, loadClassifier, loadClassifier, loadClassifier, loadClassifier, loadClassifier, loadClassifierNoExceptions, loadClassifierNoExceptions, loadClassifierNoExceptions, loadClassifierNoExceptions, loadClassifierNoExceptions, makeObjectBankFromFile, makeObjectBankFromFile, makeObjectBankFromFiles, makeObjectBankFromFiles, makeObjectBankFromFiles, makeObjectBankFromReader, makeObjectBankFromString, makePlainTextReaderAndWriter, makeReaderAndWriter, plainTextReaderAndWriter, printFeatureLists, printFeatures, printProbs, printProbs, printProbsDocument, printProbsDocuments, printResults, reinit, segmentString, segmentString, train, train, train, train, train, train, windowSize, writeAnswers
public ClassifierCombiner(Properties p) throws IOException
p
- Properties File that specifies loadClassifier
and loadAuxClassifier
properties or, alternatively, loadClassifier[1-10]
properties.FileNotFoundException
- If classifier files not foundIOException
public ClassifierCombiner(Properties props, edu.stanford.nlp.ie.ClassifierCombiner.CombinationMode combinationMode, String... loadPaths) throws IOException
props
- Properties for the classifier to use (encodings, output format, etc.)combinationMode
- How to handle multiple classifiers specifying the same entity typeloadPaths
- Paths to the base classifiersIOException
- If IO errors in loading classifier filespublic ClassifierCombiner(edu.stanford.nlp.ie.ClassifierCombiner.CombinationMode combinationMode, String... loadPaths) throws IOException
combinationMode
- How to handle multiple classifiers specifying the same entity typeloadPaths
- Paths to the base classifiersIOException
- If IO errors in loading classifier filespublic ClassifierCombiner(String... loadPaths) throws IOException
loadPaths
- Paths to the base classifiersFileNotFoundException
- If classifier files not foundIOException
@SafeVarargs public ClassifierCombiner(AbstractSequenceClassifier<IN>... classifiers)
classifiers
- The base classifierspublic ClassifierCombiner(ObjectInputStream ois, Properties props) throws IOException, ClassNotFoundException, ClassCastException
public static edu.stanford.nlp.ie.ClassifierCombiner.CombinationMode extractCombinationMode(Properties p)
public static edu.stanford.nlp.ie.ClassifierCombiner.CombinationMode extractCombinationModeSafe(Properties p)
public static <INN extends CoreMap & HasWord> AbstractSequenceClassifier<INN> loadClassifierFromPath(Properties props, String path) throws IOException
IOException
public Set<String> labels()
labels
in class AbstractSequenceClassifier<IN extends CoreMap & HasWord>
public List<IN> classify(List<IN> tokens)
classify
in class AbstractSequenceClassifier<IN extends CoreMap & HasWord>
tokens
- A List of INpublic void train(Collection<List<IN>> docs, DocumentReaderAndWriter<IN> readerAndWriter)
AbstractSequenceClassifier
train
in class AbstractSequenceClassifier<IN extends CoreMap & HasWord>
docs
- An ObjectBank or a collection of sequences of INreaderAndWriter
- A DocumentReaderAndWriter to use when loading test filespublic void serializeClassifier(String serializePath)
AbstractSequenceClassifier
serializeClassifier
in class AbstractSequenceClassifier<IN extends CoreMap & HasWord>
serializePath
- The path/filename to write the classifier to.public void serializeClassifier(ObjectOutputStream oos)
AbstractSequenceClassifier
serializeClassifier
in class AbstractSequenceClassifier<IN extends CoreMap & HasWord>
public void loadClassifier(ObjectInputStream in, Properties props) throws IOException, ClassCastException, ClassNotFoundException
AbstractSequenceClassifier
loadClassifier
in class AbstractSequenceClassifier<IN extends CoreMap & HasWord>
in
- The InputStream to load the serialized classifier fromprops
- This Properties object will be used to update the
SeqClassifierFlags which are read from the serialized classifierIOException
- If there are problems accessing the input streamClassCastException
- If there are problems interpreting the serialized dataClassNotFoundException
- If there are problems interpreting the serialized datapublic List<IN> classifyWithGlobalInformation(List<IN> tokenSeq, CoreMap doc, CoreMap sent)
AbstractSequenceClassifier
List
of something that extends CoreMap
using as
additional information whatever is stored in the document and sentence.
This is needed for SUTime (NumberSequenceClassifier), which requires
the document date to resolve relative dates.classifyWithGlobalInformation
in class AbstractSequenceClassifier<IN extends CoreMap & HasWord>
tokenSeq
- A List
of something that extends CoreMap
public static ClassifierCombiner getClassifier(String loadPath, Properties props) throws IOException, ClassNotFoundException, ClassCastException
public static ClassifierCombiner getClassifier(ObjectInputStream ois, Properties props) throws IOException, ClassCastException, ClassNotFoundException
public static void examineCRF(ClassifierCombiner cc, String crfNameOrIndex, SeqClassifierFlags flags, String testFile, String testFiles, DocumentReaderAndWriter<CoreLabel> readerAndWriter) throws Exception
Exception
public static void showCCInfo(ClassifierCombiner cc)