Package opennlp.dl.doccat
Class DocumentCategorizerDL
- java.lang.Object
-
- opennlp.dl.doccat.DocumentCategorizerDL
-
- All Implemented Interfaces:
DocumentCategorizer
public class DocumentCategorizerDL extends Object implements DocumentCategorizer
An implementation ofDocumentCategorizerthat performs document classification using ONNX models.
-
-
Field Summary
Fields Modifier and Type Field Description static StringATTENTION_MASKstatic StringINPUT_IDSstatic StringTOKEN_TYPE_IDS
-
Constructor Summary
Constructors Constructor Description DocumentCategorizerDL(File model, File vocab, Map<Integer,String> categories, ClassificationScoringStrategy classificationScoringStrategy, InferenceOptions inferenceOptions)Creates a new document categorizer using ONNX models.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double[]categorize(String[] strings)double[]categorize(String[] strings, Map<String,Object> map)StringgetAllResults(double[] doubles)StringgetBestCategory(double[] doubles)StringgetCategory(int i)intgetIndex(String s)intgetNumberOfCategories()Map<String,Double>scoreMap(String[] strings)SortedMap<Double,Set<String>>sortedScoreMap(String[] strings)
-
-
-
Field Detail
-
INPUT_IDS
public static final String INPUT_IDS
- See Also:
- Constant Field Values
-
ATTENTION_MASK
public static final String ATTENTION_MASK
- See Also:
- Constant Field Values
-
TOKEN_TYPE_IDS
public static final String TOKEN_TYPE_IDS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DocumentCategorizerDL
public DocumentCategorizerDL(File model, File vocab, Map<Integer,String> categories, ClassificationScoringStrategy classificationScoringStrategy, InferenceOptions inferenceOptions) throws IOException, ai.onnxruntime.OrtException
Creates a new document categorizer using ONNX models.- Parameters:
model- The ONNX model file.vocab- The model's vocabulary file.categories- The categories.classificationScoringStrategy- Implementation ofClassificationScoringStrategyused to calculate the classification scores given the score of each individual document part.inferenceOptions-InferenceOptionsto control the inference.- Throws:
IOExceptionai.onnxruntime.OrtException
-
-
Method Detail
-
categorize
public double[] categorize(String[] strings)
- Specified by:
categorizein interfaceDocumentCategorizer
-
categorize
public double[] categorize(String[] strings, Map<String,Object> map)
- Specified by:
categorizein interfaceDocumentCategorizer
-
getBestCategory
public String getBestCategory(double[] doubles)
- Specified by:
getBestCategoryin interfaceDocumentCategorizer
-
getIndex
public int getIndex(String s)
- Specified by:
getIndexin interfaceDocumentCategorizer
-
getCategory
public String getCategory(int i)
- Specified by:
getCategoryin interfaceDocumentCategorizer
-
getNumberOfCategories
public int getNumberOfCategories()
- Specified by:
getNumberOfCategoriesin interfaceDocumentCategorizer
-
getAllResults
public String getAllResults(double[] doubles)
- Specified by:
getAllResultsin interfaceDocumentCategorizer
-
scoreMap
public Map<String,Double> scoreMap(String[] strings)
- Specified by:
scoreMapin interfaceDocumentCategorizer
-
sortedScoreMap
public SortedMap<Double,Set<String>> sortedScoreMap(String[] strings)
- Specified by:
sortedScoreMapin interfaceDocumentCategorizer
-
-