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,
java.lang.String... loadPaths)
Loads a series of base classifiers from the paths specified using the
Properties specified.
|
ClassifierCombiner(java.io.ObjectInputStream ois,
java.util.Properties props) |
ClassifierCombiner(java.util.Properties p) |
ClassifierCombiner(java.util.Properties props,
edu.stanford.nlp.ie.ClassifierCombiner.CombinationMode combinationMode,
java.lang.String... loadPaths)
Loads a series of base classifiers from the paths specified using the
Properties specified.
|
ClassifierCombiner(java.lang.String... loadPaths)
Loads a series of base classifiers from the paths specified.
|
Modifier and Type | Method and Description |
---|---|
java.util.List<IN> |
classify(java.util.List<IN> tokens)
Generates the AnswerAnnotation labels of the combined model for the given
tokens, storing them in place in the tokens.
|
java.util.List<IN> |
classifyWithGlobalInformation(java.util.List<IN> tokenSeq,
CoreMap doc,
CoreMap sent)
Classify a
List of something that extends CoreMap using as
additional information whatever is stored in the document and sentence. |
static void |
examineCRF(ClassifierCombiner cc,
java.lang.String crfNameOrIndex,
SeqClassifierFlags flags,
java.lang.String testFile,
java.lang.String testFiles,
DocumentReaderAndWriter<CoreLabel> readerAndWriter) |
static edu.stanford.nlp.ie.ClassifierCombiner.CombinationMode |
extractCombinationMode(java.util.Properties p)
Either finds COMBINATION_MODE_PROPERTY or returns a default value.
|
static edu.stanford.nlp.ie.ClassifierCombiner.CombinationMode |
extractCombinationModeSafe(java.util.Properties p)
Either finds COMBINATION_MODE_PROPERTY or returns a default
value.
|
static ClassifierCombiner |
getClassifier(java.io.ObjectInputStream ois,
java.util.Properties props) |
static ClassifierCombiner |
getClassifier(java.lang.String loadPath,
java.util.Properties props) |
java.util.Set<java.lang.String> |
labels() |
void |
loadClassifier(java.io.ObjectInputStream in,
java.util.Properties props)
Load a classifier from the specified input stream.
|
static <INN extends CoreMap & HasWord> |
loadClassifierFromPath(java.util.Properties props,
java.lang.String path) |
static void |
main(java.lang.String[] args)
Some basic testing of the ClassifierCombiner.
|
void |
serializeClassifier(java.io.ObjectOutputStream oos)
Serialize a sequence classifier to an object output stream
|
void |
serializeClassifier(java.lang.String serializePath)
Serialize a sequence classifier to a file on the given path.
|
static void |
showCCInfo(ClassifierCombiner cc) |
void |
train(java.util.Collection<java.util.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, makePlainTextReaderAndWriter, makeReaderAndWriter, plainTextReaderAndWriter, printFeatureLists, printFeatures, printProbs, printProbs, printProbsDocument, printProbsDocuments, printResults, reinit, segmentString, segmentString, train, train, train, train, train, train, windowSize, writeAnswers
public ClassifierCombiner(java.util.Properties p) throws java.io.IOException
p
- Properties File that specifies loadClassifier
and loadAuxClassifier
properties or, alternatively, loadClassifier[1-10]
properties.java.io.FileNotFoundException
- If classifier files not foundjava.io.IOException
public ClassifierCombiner(java.util.Properties props, edu.stanford.nlp.ie.ClassifierCombiner.CombinationMode combinationMode, java.lang.String... loadPaths) throws java.io.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 classifiersjava.io.IOException
- If IO errors in loading classifier filespublic ClassifierCombiner(edu.stanford.nlp.ie.ClassifierCombiner.CombinationMode combinationMode, java.lang.String... loadPaths) throws java.io.IOException
combinationMode
- How to handle multiple classifiers specifying the same entity typeloadPaths
- Paths to the base classifiersjava.io.IOException
- If IO errors in loading classifier filespublic ClassifierCombiner(java.lang.String... loadPaths) throws java.io.IOException
loadPaths
- Paths to the base classifiersjava.io.FileNotFoundException
- If classifier files not foundjava.io.IOException
@SafeVarargs public ClassifierCombiner(AbstractSequenceClassifier<IN>... classifiers)
classifiers
- The base classifierspublic ClassifierCombiner(java.io.ObjectInputStream ois, java.util.Properties props) throws java.io.IOException, java.lang.ClassNotFoundException, java.lang.ClassCastException
java.io.IOException
java.lang.ClassNotFoundException
java.lang.ClassCastException
public static edu.stanford.nlp.ie.ClassifierCombiner.CombinationMode extractCombinationMode(java.util.Properties p)
public static edu.stanford.nlp.ie.ClassifierCombiner.CombinationMode extractCombinationModeSafe(java.util.Properties p)
public static <INN extends CoreMap & HasWord> AbstractSequenceClassifier<INN> loadClassifierFromPath(java.util.Properties props, java.lang.String path) throws java.io.IOException
java.io.IOException
public java.util.Set<java.lang.String> labels()
labels
in class AbstractSequenceClassifier<IN extends CoreMap & HasWord>
public java.util.List<IN> classify(java.util.List<IN> tokens)
classify
in class AbstractSequenceClassifier<IN extends CoreMap & HasWord>
tokens
- A List of INpublic void train(java.util.Collection<java.util.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(java.lang.String serializePath)
AbstractSequenceClassifier
serializeClassifier
in class AbstractSequenceClassifier<IN extends CoreMap & HasWord>
serializePath
- The path/filename to write the classifier to.public void serializeClassifier(java.io.ObjectOutputStream oos)
AbstractSequenceClassifier
serializeClassifier
in class AbstractSequenceClassifier<IN extends CoreMap & HasWord>
public void loadClassifier(java.io.ObjectInputStream in, java.util.Properties props) throws java.io.IOException, java.lang.ClassCastException, java.lang.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 classifierjava.io.IOException
- If there are problems accessing the input streamjava.lang.ClassCastException
- If there are problems interpreting the serialized datajava.lang.ClassNotFoundException
- If there are problems interpreting the serialized datapublic java.util.List<IN> classifyWithGlobalInformation(java.util.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(java.lang.String loadPath, java.util.Properties props) throws java.io.IOException, java.lang.ClassNotFoundException, java.lang.ClassCastException
java.io.IOException
java.lang.ClassNotFoundException
java.lang.ClassCastException
public static ClassifierCombiner getClassifier(java.io.ObjectInputStream ois, java.util.Properties props) throws java.io.IOException, java.lang.ClassCastException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassCastException
java.lang.ClassNotFoundException
public static void examineCRF(ClassifierCombiner cc, java.lang.String crfNameOrIndex, SeqClassifierFlags flags, java.lang.String testFile, java.lang.String testFiles, DocumentReaderAndWriter<CoreLabel> readerAndWriter) throws java.lang.Exception
java.lang.Exception
public static void showCCInfo(ClassifierCombiner cc)
public static void main(java.lang.String[] args) throws java.lang.Exception
args
- Command-line arguments as properties: -loadClassifier1 serializedFile -loadClassifier2 serializedFilejava.lang.Exception
- If IO or serialization error loading classifiers