com.johnsnowlabs.nlp.annotators.sda.pragmatic
Multiplier for decrement sentiments (Default: -2.0
)
Rule based sentiment detector
Rule based sentiment detector
Delimited file with a list sentiment tags per word (either positive
or negative
).
Delimited file with a list sentiment tags per word (either positive
or negative
).
Requires 'delimiter
' in options
.
cool,positive superb,positive bad,negative uninspired,negative
where the 'delimiter
' options was set with Map("delimiter" -> ",")
If true, score will show as the double value, else will output string "positive"
or "negative"
(Default: false
)
input annotations columns currently used
Gets annotation column name going to generate
Gets annotation column name going to generate
Multiplier for increment sentiments (Default: 2.0
)
Input annotation type : TOKEN, DOCUMENT
Input annotation type : TOKEN, DOCUMENT
columns that contain annotations necessary to run this annotator AnnotatorType is used both as input and output columns if not specified
columns that contain annotations necessary to run this annotator AnnotatorType is used both as input and output columns if not specified
Multiplier for negative sentiments (Default: -1.0
)
Output annotation type : SENTIMENT
Output annotation type : SENTIMENT
Multiplier for positive sentiments (Default: 1.0
)
Multiplier for revert sentiments (Default: -1.0
)
Multiplier for decrement sentiments (Default: -2.0
)
Delimited file with a list sentiment tags per word.
Delimited file with a list sentiment tags per word. Requires 'delimiter' in options. Dictionary needs 'delimiter' in order to separate words from sentiment tags
Delimited file with a list sentiment tags per word.
Delimited file with a list sentiment tags per word. Requires 'delimiter' in options. Dictionary needs 'delimiter' in order to separate words from sentiment tags
If true, score will show as the double value, else will output string "positive"
or "negative"
(Default: false
)
Multiplier for increment sentiments (Default: 2.0
)
Overrides required annotators column if different than default
Overrides required annotators column if different than default
Multiplier for negative sentiments (Default: -1.0
)
Overrides annotation column name when transforming
Overrides annotation column name when transforming
Multiplier for positive sentiments (Default: 1.0
)
Multiplier for revert sentiments (Default: -1.0
)
requirement for pipeline transformation validation.
requirement for pipeline transformation validation. It is called on fit()
internal uid needed for saving annotator to disk
internal uid needed for saving annotator to disk
takes a Dataset and checks to see if all the required annotation types are present.
takes a Dataset and checks to see if all the required annotation types are present.
to be validated
True if all the required types are present, else false
A list of (hyper-)parameter keys this annotator can take. Users can set and get the parameter values through setters and getters, respectively.
Required input and expected output annotator types
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