com.johnsnowlabs.nlp.annotators.sda.pragmatic
internal types to show Rows as a relevant StructType Should be deleted once Spark releases UserDefinedTypes to @developerAPI
internal types to show Rows as a relevant StructType Should be deleted once Spark releases UserDefinedTypes to @developerAPI
Tokens are needed to identify each word in a sentence boundary POS tags are optionally submitted to the model in case they are needed Lemmas are another optional annotator for some models Bounds of sentiment are hardcoded to 0 as they render useless
Tokens are needed to identify each word in a sentence boundary POS tags are optionally submitted to the model in case they are needed Lemmas are another optional annotator for some models Bounds of sentiment are hardcoded to 0 as they render useless
Annotations that correspond to inputAnnotationCols generated by previous annotators if any
any number of annotations processed for every input annotation. Not necessary one to one relationship
requirement for annotators copies
requirement for annotators copies
Multiplier for decrement sentiments (Default: -2.0
)
Wraps annotate to happen inside SparkSQL user defined functions in order to act with org.apache.spark.sql.Column
Wraps annotate to happen inside SparkSQL user defined functions in order to act with org.apache.spark.sql.Column
udf function to be applied to inputCols using this annotator's annotate function as part of ML transformation
if true, score will show as a string type containing a double value, else will output string "positive"
or "negative"
(Default: false
)
Override for additional custom schema checks
Override for additional custom schema checks
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
)
Sentiment dict
Multiplier for decrement sentiments (Default: -2.0
)
If true, score will show as a string type containing a 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
)
Path to file with list of inputs and their content, with such delimiter, readAs LINE_BY_LINE or as SPARK_DATASET.
Path to file with list of inputs and their content, with such delimiter, readAs LINE_BY_LINE or as SPARK_DATASET. If latter is set, options is passed to spark reader.
Given requirements are met, this applies ML transformation within a Pipeline or stand-alone Output annotation will be generated as a new column, previous annotations are still available separately metadata is built at schema level to record annotations structural information outside its content
Given requirements are met, this applies ML transformation within a Pipeline or stand-alone Output annotation will be generated as a new column, previous annotations are still available separately metadata is built at schema level to record annotations structural information outside its content
Dataset[Row]
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
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 (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.
ViveknSentimentApproach for an alternative approach to sentiment extraction