Scorer is a rule based implementation inspired on http://fjavieralba.com/basic-sentiment-analysis-with-python.html Its strategy is to tag words by a dictionary in a sentence context, and later identify such context to get amplifiers
Trains a rule based sentiment detector, which calculates a score based on predefined keywords.
Rule based sentiment detector, which calculates a score based on predefined keywords.
Rule based sentiment detector, which calculates a score based on predefined keywords.
This is the instantiated model of the SentimentDetector. For training your own model, please see the documentation of that class.
A dictionary of predefined sentiment keywords must be provided with setDictionary
, where each line is a word
delimited to its class (either positive
or negative
).
The dictionary can be set in either in the form of a delimited text file or directly as an
ExternalResource.
By default, the sentiment score will be assigned labels "positive"
if the score is >= 0
, else "negative"
.
To retrieve the raw sentiment scores, enableScore
needs to be set to true
.
For extended examples of usage, see the Spark NLP Workshop and the SentimentTestSpec.
ViveknSentimentApproach for an alternative approach to sentiment extraction
This is the companion object of SentimentDetector.
This is the companion object of SentimentDetector. Please refer to that class for the documentation.
Trains a rule based sentiment detector, which calculates a score based on predefined keywords.
A dictionary of predefined sentiment keywords must be provided with
setDictionary
, where each line is a word delimited to its class (eitherpositive
ornegative
). The dictionary can be set in either in the form of a delimited text file or directly as an ExternalResource.By default, the sentiment score will be assigned labels
"positive"
if the score is>= 0
, else"negative"
. To retrieve the raw sentiment scores,enableScore
needs to be set totrue
.For extended examples of usage, see the Spark NLP Workshop and the SentimentTestSpec.
Example
In this example, the dictionary
default-sentiment-dict.txt
has the form ofwhere each sentiment keyword is delimited by
","
.ViveknSentimentApproach for an alternative approach to sentiment extraction