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, CUT_LABEL, 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.
|
ClassifierCombiner(Properties p) |
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 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.
|
Set<String> |
labels() |
void |
loadClassifier(ObjectInputStream in,
Properties props)
Load a classifier from the specified input stream.
|
static <INN extends CoreMap & HasWord> |
loadClassifierFromPath(String path) |
static void |
main(String[] args)
Some basic testing of the ClassifierCombiner.
|
void |
printProbsDocument(List<IN> document) |
void |
serializeClassifier(String serializePath)
Serialize a sequence classifier to a file on the given path.
|
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, classifyAndWriteAnswersKBest, classifyAndWriteAnswersKBest, classifyAndWriteViterbiSearchGraph, classifyFile, classifyFilesAndWriteAnswers, classifyFilesAndWriteAnswers, classifyKBest, classifyRaw, classifySentence, classifySentenceWithGlobalInformation, classifyStdin, classifyStdin, classifyToCharacterOffsets, classifyToString, classifyToString, classifyWithInlineXML, countResults, countResults, countResultsIOB, countResultsIOB2, countResultsSegmenter, defaultReaderAndWriter, dumpFeatures, finalizeClassification, getSampler, getSequenceModel, getViterbiSearchGraph, loadClassifier, loadClassifier, loadClassifier, loadClassifier, loadClassifier, loadClassifier, loadClassifierNoExceptions, loadClassifierNoExceptions, loadClassifierNoExceptions, loadClassifierNoExceptions, loadClassifierNoExceptions, loadJarClassifier, makeObjectBankFromFile, makeObjectBankFromFile, makeObjectBankFromFiles, makeObjectBankFromFiles, makeObjectBankFromFiles, makeObjectBankFromReader, makeObjectBankFromString, makePlainTextReaderAndWriter, makeReaderAndWriter, plainTextReaderAndWriter, printFeatureLists, printFeatures, printProbs, printProbsDocuments, printResults, reinit, segmentString, segmentString, tallyOneEntityIOB, train, train, train, train, train, train, windowSize, writeAnswers
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
andThen, compose, identity
public ClassifierCombiner(Properties p) throws FileNotFoundException
p
- Properties File that specifies loadClassifier
and loadAuxClassifier
properties or, alternatively, loadClassifier[1-10]
properties.FileNotFoundException
- If classifier files not foundpublic ClassifierCombiner(edu.stanford.nlp.ie.ClassifierCombiner.CombinationMode combinationMode, String... loadPaths) throws FileNotFoundException
loadPaths
- Paths to the base classifiersFileNotFoundException
- If classifier files not foundpublic ClassifierCombiner(String... loadPaths) throws FileNotFoundException
loadPaths
- Paths to the base classifiersFileNotFoundException
- If classifier files not foundpublic ClassifierCombiner(AbstractSequenceClassifier<IN>... classifiers)
classifiers
- The base classifierspublic 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(String path) throws FileNotFoundException
FileNotFoundException
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 printProbsDocument(List<IN> document)
printProbsDocument
in class AbstractSequenceClassifier<IN extends CoreMap & HasWord>
public void serializeClassifier(String serializePath)
AbstractSequenceClassifier
serializeClassifier
in class AbstractSequenceClassifier<IN extends CoreMap & HasWord>
serializePath
- The path/filename to write the classifier to.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>