public class DocumentCategorizerME extends Object implements DocumentCategorizer
DocumentCategorizer
.Constructor and Description |
---|
DocumentCategorizerME(DoccatModel model)
Initializes the current instance with a doccat model.
|
Modifier and Type | Method and Description |
---|---|
double[] |
categorize(String[] text)
Categorizes the given text.
|
double[] |
categorize(String[] text,
Map<String,Object> extraInformation)
Categorize the given text provided as tokens along with
the provided extra information
|
String |
getAllResults(double[] results)
get the name of the category associated with the given probabilties
|
String |
getBestCategory(double[] outcome)
get the best category from previously generated outcome probabilities
|
String |
getCategory(int index)
get the category at a given index
|
int |
getIndex(String category)
get the index of a certain category
|
int |
getNumberOfCategories()
get the number of categories
|
Map<String,Double> |
scoreMap(String[] text)
Returns a map in which the key is the category name and the value is the score
|
SortedMap<Double,Set<String>> |
sortedScoreMap(String[] text)
Returns a map with the score as a key in ascending order.
|
static DoccatModel |
train(String languageCode,
ObjectStream<DocumentSample> samples,
TrainingParameters mlParams,
DoccatFactory factory) |
public DocumentCategorizerME(DoccatModel model)
model
- the doccat modelpublic double[] categorize(String[] text, Map<String,Object> extraInformation)
categorize
in interface DocumentCategorizer
text
- text tokens to categorizeextraInformation
- additional informationpublic double[] categorize(String[] text)
categorize
in interface DocumentCategorizer
text
- the text to categorizepublic Map<String,Double> scoreMap(String[] text)
scoreMap
in interface DocumentCategorizer
text
- the input text to classifypublic SortedMap<Double,Set<String>> sortedScoreMap(String[] text)
sortedScoreMap
in interface DocumentCategorizer
text
- the input text to classifypublic String getBestCategory(double[] outcome)
DocumentCategorizer
getBestCategory
in interface DocumentCategorizer
outcome
- a vector of outcome probabilitiespublic int getIndex(String category)
DocumentCategorizer
getIndex
in interface DocumentCategorizer
category
- the categorypublic String getCategory(int index)
DocumentCategorizer
getCategory
in interface DocumentCategorizer
index
- the indexpublic int getNumberOfCategories()
DocumentCategorizer
getNumberOfCategories
in interface DocumentCategorizer
public String getAllResults(double[] results)
DocumentCategorizer
getAllResults
in interface DocumentCategorizer
results
- the probabilities of each categorypublic static DoccatModel train(String languageCode, ObjectStream<DocumentSample> samples, TrainingParameters mlParams, DoccatFactory factory) throws IOException
IOException
Copyright © 2021 The Apache Software Foundation. All rights reserved.