Package opennlp.dl.doccat
Class DocumentCategorizerDL
java.lang.Object
opennlp.dl.AbstractDL
opennlp.dl.doccat.DocumentCategorizerDL
- All Implemented Interfaces:
DocumentCategorizer
An implementation of
DocumentCategorizer that performs document classification
using ONNX models.-
Field Summary
Fields inherited from class opennlp.dl.AbstractDL
ATTENTION_MASK, INPUT_IDS, TOKEN_TYPE_IDS -
Constructor Summary
ConstructorsConstructorDescriptionDocumentCategorizerDL(File model, File vocabulary, Map<Integer, String> categories, ClassificationScoringStrategy classificationScoringStrategy, InferenceOptions inferenceOptions) Instantiates adocument categorizerusing ONNX models. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]categorize(String[] strings) double[]categorize(String[] strings, Map<String, Object> map) getAllResults(double[] doubles) getBestCategory(double[] doubles) getCategory(int i) intintsortedScoreMap(String[] strings) Methods inherited from class opennlp.dl.AbstractDL
loadVocab
-
Constructor Details
-
DocumentCategorizerDL
public DocumentCategorizerDL(File model, File vocabulary, Map<Integer, String> categories, ClassificationScoringStrategy classificationScoringStrategy, InferenceOptions inferenceOptions) throws IOException, ai.onnxruntime.OrtExceptionInstantiates adocument categorizerusing ONNX models.- Parameters:
model- The ONNX model file.vocabulary- The model file'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:
ai.onnxruntime.OrtException- Thrown if themodelcannot be loaded.IOException- Thrown if errors occurred loading themodelorvocabulary.
-
-
Method Details
-
categorize
- Specified by:
categorizein interfaceDocumentCategorizer
-
categorize
- Specified by:
categorizein interfaceDocumentCategorizer
-
getBestCategory
- Specified by:
getBestCategoryin interfaceDocumentCategorizer
-
getIndex
- Specified by:
getIndexin interfaceDocumentCategorizer
-
getCategory
- Specified by:
getCategoryin interfaceDocumentCategorizer
-
getNumberOfCategories
public int getNumberOfCategories()- Specified by:
getNumberOfCategoriesin interfaceDocumentCategorizer
-
getAllResults
- Specified by:
getAllResultsin interfaceDocumentCategorizer
-
scoreMap
- Specified by:
scoreMapin interfaceDocumentCategorizer
-
sortedScoreMap
- Specified by:
sortedScoreMapin interfaceDocumentCategorizer
-