Class CategorizerImpl
- java.lang.Object
-
- net.thexcoders.aladin_bot_backend.nlp_models.NLPModel
-
- net.thexcoders.aladin_bot_backend.nlp_models.categorizer.CategorizerImpl
-
- All Implemented Interfaces:
Categorizer
public class CategorizerImpl extends NLPModel implements Categorizer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCategorizerImpl.CategoryResultthis inner class is used to store the result of thegetCategory(String[], Language, String)method it stores the values to be stored or logged.-
Nested classes/interfaces inherited from interface net.thexcoders.aladin_bot_backend.nlp_models.categorizer.Categorizer
Categorizer.Language
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCategorizerImpl()Categorizer constructor that prepares the files needed to train the Model in the languages added to the Language Enumeration Class.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CategorizerImpl.CategoryResultgetCategory(String[] tokens, Categorizer.Language lang, String sentence)this method is used to get the category of the tokenized sentence using theTokenizerclass.static CategorizerImplgetInstance()gets the instance of the class, if the instance is null it calls the constructor to create a new instanceopennlp.tools.doccat.DoccatModeltrain(String lang)This method takes a lot of time to execute since it prepares the training Model for the categorizer based on the training Data provided in theCategorizerImpl()constructor} For optimization purposes, we Have used a singleton-
Methods inherited from class net.thexcoders.aladin_bot_backend.nlp_models.NLPModel
fileExists, generateFile
-
-
-
-
Constructor Detail
-
CategorizerImpl
protected CategorizerImpl()
Categorizer constructor that prepares the files needed to train the Model in the languages added to the Language Enumeration Class.This class is private due to the method
train(String)
-
-
Method Detail
-
getInstance
public static CategorizerImpl getInstance()
Description copied from interface:Categorizergets the instance of the class, if the instance is null it calls the constructor to create a new instance- Returns:
- Categorizer the instance of the class.
-
train
public opennlp.tools.doccat.DoccatModel train(String lang)
Description copied from interface:CategorizerThis method takes a lot of time to execute since it prepares the training Model for the categorizer based on the training Data provided in theCategorizerImpl()constructor} For optimization purposes, we Have used a singleton- Specified by:
trainin interfaceCategorizer- Parameters:
lang- a string value representing the language in which the model will be trained. It also references the file to be used to train the Model- Returns:
- instance of
DoccatModelwhich is the trained model. - See Also:
ObjectStream,DoccatModel,TrainingParameters,DoccatFactory,DocumentSampleStream,DocumentSample,DocumentCategorizerME,MarkableFileInputStreamFactory,PlainTextByLineStream
-
getCategory
public CategorizerImpl.CategoryResult getCategory(String[] tokens, Categorizer.Language lang, String sentence)
Description copied from interface:Categorizerthis method is used to get the category of the tokenized sentence using theTokenizerclass.- Specified by:
getCategoryin interfaceCategorizer- Parameters:
tokens- an array of tokens retrieved from the tokenizerlang- theCategorizer.Languagein which the tokens are insentence- the sentenced (a single sentence from the user's input) from which the tokens are retrieved.- Returns:
- an instance of
CategorizerImpl.CategoryResultrepresenting the result to be displayed to the user.
-
-