Class SentimentME
java.lang.Object
opennlp.tools.sentiment.SentimentME
- All Implemented Interfaces:
opennlp.tools.sentiment.SentimentDetector
A
SentimentDetector implementation for creating and using
maximum-entropy-based Sentiment Analysis models.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSentimentME(SentimentModel sentModel) Instantiates aSentimentMEwith the specified model. -
Method Summary
Modifier and TypeMethodDescriptiongetBestSentiment(double[] outcome) Returns the best chosen sentiment for the given probability distribution.double[]probabilities(String[] text) Returns the probability distribution over sentiment labels for the given tokens.static SentimentModeltrain(String languageCode, opennlp.tools.util.ObjectStream<opennlp.tools.sentiment.SentimentSample> samples, opennlp.tools.util.TrainingParameters trainParams, SentimentFactory factory) Trains aSentiment Analysis model.
-
Constructor Details
-
SentimentME
Instantiates aSentimentMEwith the specified model.- Parameters:
sentModel- Thesentiment analysis modelto use. It must not benull.- Throws:
IllegalArgumentException- Thrown if parameters are invalid.
-
-
Method Details
-
train
public static SentimentModel train(String languageCode, opennlp.tools.util.ObjectStream<opennlp.tools.sentiment.SentimentSample> samples, opennlp.tools.util.TrainingParameters trainParams, SentimentFactory factory) throws IOException Trains aSentiment Analysis model.- Parameters:
languageCode- the code for the language of the text, e.g. "en"samples- the sentiment samples to be usedtrainParams- parameters for trainingfactory- a Sentiment Analysis factory- Returns:
- A valid
SentimentModel. - Throws:
IOException- Thrown if IO errors occurred during training.
-
predict
-
predict
-
getBestSentiment
Returns the best chosen sentiment for the given probability distribution.- Parameters:
outcome- the probability distribution over outcomes.- Returns:
- the best sentiment label.
-
probabilities
Returns the probability distribution over sentiment labels for the given tokens.- Parameters:
text- the tokens to classify.- Returns:
- the probability distribution over sentiment labels.
-