public class SentimentME extends Object
| Modifier and Type | Field and Description |
|---|---|
protected SentimentContextGenerator |
contextGenerator |
static String |
CONTINUE |
static int |
DEFAULT_BEAM_SIZE |
protected opennlp.tools.ml.model.SequenceClassificationModel<String> |
model |
static String |
OTHER |
static String |
START |
| Constructor and Description |
|---|
SentimentME(SentimentModel sentModel)
Constructor, initialises
|
| Modifier and Type | Method and Description |
|---|---|
String |
getBestSentiment(double[] outcome)
Returns the best chosen sentiment for the text predicted on
|
String |
predict(String sentence)
Makes a sentiment prediction
|
opennlp.tools.util.Span[] |
predict2(String[] tokens)
Makes a sentiment prediction by calling the helper method
|
opennlp.tools.util.Span[] |
predict2(String[] tokens,
String[][] additionalContext)
Makes a sentiment prediction
|
double[] |
probabilities(String[] text)
Returns the analysis probabilities
|
static SentimentModel |
train(String languageCode,
opennlp.tools.util.ObjectStream<SentimentSample> samples,
opennlp.tools.util.TrainingParameters trainParams,
SentimentFactory factory)
Trains a Sentiment Analysis model.
|
public static final String OTHER
public static final String START
public static final String CONTINUE
public static final int DEFAULT_BEAM_SIZE
protected SentimentContextGenerator contextGenerator
protected opennlp.tools.ml.model.SequenceClassificationModel<String> model
public SentimentME(SentimentModel sentModel)
sentModel - sentiment analysis modelpublic static SentimentModel train(String languageCode, opennlp.tools.util.ObjectStream<SentimentSample> samples, opennlp.tools.util.TrainingParameters trainParams, SentimentFactory factory) throws IOException
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 factoryIOExceptionpublic String predict(String sentence)
sentence - the text to be analysed for its sentimentpublic String getBestSentiment(double[] outcome)
outcome - the outcomepublic double[] probabilities(String[] text)
text - the text to categorizepublic opennlp.tools.util.Span[] predict2(String[] tokens)
tokens - the text to be analysed for its sentimentCopyright © 2016. All rights reserved.