|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.ie.AbstractSequenceClassifier<IN>
edu.stanford.nlp.ie.ClassifierCombiner<IN>
public class ClassifierCombiner<IN extends CoreMap & HasWord>
Merges the outputs of two or more AbstractSequenceClassifiers according to a simple precedence scheme: any given base classifier contributes only classifications of labels that do not exist in the base classifiers specified before, and that do not have any token overlap with labels assigned by higher priority classifiers.
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.
Field Summary |
---|
Fields inherited from class edu.stanford.nlp.ie.AbstractSequenceClassifier |
---|
classIndex, featureFactory, flags, knownLCWords, pad, windowSize |
Constructor Summary | |
---|---|
ClassifierCombiner(AbstractSequenceClassifier<IN>... classifiers)
Combines a series of base classifiers |
|
ClassifierCombiner(Properties p)
|
|
ClassifierCombiner(String... loadPaths)
Loads a series of base classifiers from the paths specified. |
Method Summary | ||
---|---|---|
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)
Classify a List of something that extends CoreMap using as
additional information whatever is stored in the document and sentence. |
|
Set<String> |
labels()
|
|
void |
loadClassifier(ObjectInputStream in,
Properties props)
Load a classifier from the specified input stream. |
|
static
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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(String... loadPaths) throws FileNotFoundException
loadPaths
- Paths to the base classifiers
FileNotFoundException
- If classifier files not foundpublic ClassifierCombiner(AbstractSequenceClassifier<IN>... classifiers)
classifiers
- The base classifiersMethod Detail |
---|
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 IN
public 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 classifier
IOException
- If there are problems accessing the input stream
ClassCastException
- If there are problems interpreting the serialized data
ClassNotFoundException
- 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>
public static void main(String[] args) throws Exception
args
- Command-line arguments as properties: -loadClassifier1 serializedFile -loadClassifier2 serializedFile
Exception
- If IO or serialization error loading classifiers
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |