Package opennlp.tools.doccat
Klasse DocumentCategorizerME
java.lang.Object
opennlp.tools.doccat.DocumentCategorizerME
- Alle implementierten Schnittstellen:
DocumentCategorizer
A Max-Ent based implementation of
DocumentCategorizer.-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungDocumentCategorizerME(DoccatModel model) Initializes aDocumentCategorizerMEinstance with a doccat model. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungdouble[]categorize(String[] text) Categorizes the giventext, provided in separate tokens.double[]categorize(String[] text, Map<String, Object> extraInformation) Categorize the giventextprovided as tokens along with the provided extra information.getAllResults(double[] results) Retrieves the name of the category associated with the given probabilities.getBestCategory(double[] outcome) Retrieves the best category from previously generatedoutcomeprobabilitiesgetCategory(int index) Retrieves the category at a givenindex.intRetrieves the index of a certain category.intRetrieves the number of categories.Retrieves aMapin which the key is the category name and the value is the score.sortedScoreMap(String[] text) Retrieves aSortedMapof the scores sorted in ascending order, together with their associated categories.static DoccatModeltrain(String lang, ObjectStream<DocumentSample> samples, TrainingParameters mlParams, DoccatFactory factory) Starts a training of aDoccatModelwith the given parameters.
-
Konstruktordetails
-
DocumentCategorizerME
Initializes aDocumentCategorizerMEinstance with a doccat model. Default feature generation is used.- Parameter:
model- theDoccatModelto be used for categorization.
-
-
Methodendetails
-
categorize
Categorize the giventextprovided as tokens along with the provided extra information.- Angegeben von:
categorizein SchnittstelleDocumentCategorizer- Parameter:
text- The text tokens to categorize.extraInformation- Additional information for context to be used by the feature generator.- Gibt zurück:
- The per category probabilities.
-
categorize
Beschreibung aus Schnittstelle kopiert:DocumentCategorizerCategorizes the giventext, provided in separate tokens.- Angegeben von:
categorizein SchnittstelleDocumentCategorizer- Parameter:
text- The tokens of text to categorize.- Gibt zurück:
- The per category probabilities.
-
scoreMap
Beschreibung aus Schnittstelle kopiert:DocumentCategorizerRetrieves aMapin which the key is the category name and the value is the score.- Angegeben von:
scoreMapin SchnittstelleDocumentCategorizer- Parameter:
text- The tokenized input text to classify.- Gibt zurück:
- A
Mapwith the score as a key.
-
sortedScoreMap
Beschreibung aus Schnittstelle kopiert:DocumentCategorizerRetrieves aSortedMapof the scores sorted in ascending order, together with their associated categories.Many categories can have the same score, hence the
Setas value.- Angegeben von:
sortedScoreMapin SchnittstelleDocumentCategorizer- Parameter:
text- the input text to classify- Gibt zurück:
- A
SortedMapwith the score as a key.
-
getBestCategory
Beschreibung aus Schnittstelle kopiert:DocumentCategorizerRetrieves the best category from previously generatedoutcomeprobabilities- Angegeben von:
getBestCategoryin SchnittstelleDocumentCategorizer- Parameter:
outcome- An array of computed outcome probabilities.- Gibt zurück:
- The best category represented as String.
-
getIndex
Beschreibung aus Schnittstelle kopiert:DocumentCategorizerRetrieves the index of a certain category.- Angegeben von:
getIndexin SchnittstelleDocumentCategorizer- Parameter:
category- The category for which theindexis to be found.- Gibt zurück:
- The index.
-
getCategory
Beschreibung aus Schnittstelle kopiert:DocumentCategorizerRetrieves the category at a givenindex.- Angegeben von:
getCategoryin SchnittstelleDocumentCategorizer- Parameter:
index- The index for which thecategoryshall be found.- Gibt zurück:
- The category represented as String.
-
getNumberOfCategories
public int getNumberOfCategories()Beschreibung aus Schnittstelle kopiert:DocumentCategorizerRetrieves the number of categories.- Angegeben von:
getNumberOfCategoriesin SchnittstelleDocumentCategorizer- Gibt zurück:
- The no. of categories.
-
getAllResults
Beschreibung aus Schnittstelle kopiert:DocumentCategorizerRetrieves the name of the category associated with the given probabilities.- Angegeben von:
getAllResultsin SchnittstelleDocumentCategorizer- Parameter:
results- The probabilities of each category.- Gibt zurück:
- The name of the outcome.
-
train
public static DoccatModel train(String lang, ObjectStream<DocumentSample> samples, TrainingParameters mlParams, DoccatFactory factory) throws IOException Starts a training of aDoccatModelwith the given parameters.- Parameter:
lang- The ISO conform language code.samples- TheObjectStreamofDocumentSampleused as input for training.mlParams- TheTrainingParametersfor the context of the training.factory- TheDoccatFactoryfor creating related objects defined viamlParams.- Gibt zurück:
- A valid, trained
DoccatModelinstance. - Löst aus:
IOException- Thrown if IO errors occurred.
-