Description
The SentimentExtractor (td_sentiment_extractor_mle
) function extracts
the sentiment (positive, negative, or neutral) of each input document
or sentence, using either a classification model output by the
SentimentTrainer function or a dictionary model.
Usage
td_sentiment_extractor_mle ( object = NULL, newdata = NULL, dict.data = NULL, text.column = NULL, language = "en", level = "DOCUMENT", high.priority = "NONE", filter = "ALL", accumulate = NULL, newdata.sequence.column = NULL, dict.data.sequence.column = NULL )
Arguments
object |
Optional Argument. |
newdata |
Required Argument. |
dict.data |
Optional Argument. |
text.column |
Required Argument. |
language |
Optional Argument. Specifies the language of the input text: en (English), zh_CN (Simplified Chinese), zh_TW (Traditional Chinese) Default Value: "en" Permitted Values: en, zh_CN, zh_TW |
level |
Optional Argument. |
high.priority |
Optional Argument.
Default Value: "NONE" |
filter |
Optional Argument.
Default Value: "ALL" Permitted Values: POSITIVE, NEGATIVE, ALL |
accumulate |
Optional Argument. Specifies the names of the input columns to copy to the output table. |
newdata.sequence.column |
Optional Argument. |
dict.data.sequence.column |
Optional Argument. |
Value
Function returns an object of class "td_sentiment_extractor_mle" which is
a named list containing Teradata tbl object.
Named list member can be referenced directly with the "$" operator
using name: result.
Examples
# Get the current context/connection con <- td_get_context()$connection # Load example data. loadExampleData("sentimenttrainer_example", "sentiment_train") loadExampleData("sentimentextractor_example", "sentiment_extract_input", "sentiment_word") # Create remote tibble objects. sentiment_train <- tbl(con, "sentiment_train") sentiment_extract_input <- tbl(con, "sentiment_extract_input") sentiment_word <- tbl(con, "sentiment_word") # This example uses the dictionary model file and analysis level is document td_sentiment_extractor_out1 <- td_sentiment_extractor_mle(object = "dictionary", newdata = sentiment_extract_input, text.column = "review", level = "document", accumulate = c("id","product") ) # This example uses the dictionary model file and analysis level is sentence td_sentiment_extractor_out2 <- td_sentiment_extractor_mle(object = "dictionary", newdata = sentiment_extract_input, text.column = "review", level = "sentence", accumulate = c("id","product") ) # This example uses a maximum entropy classification model file td_sentiment_extractor_out3 <- td_sentiment_extractor_mle(object = "classification:default_sentiment_classification_model.bin", newdata = sentiment_extract_input, text.column = "review", level = "document", accumulate = c("id") ) # This example uses a model file output by the SentimentTrainer function td_sentiment_trainer_out <- td_sentiment_trainer_mle(data = sentiment_train, text.column = "review", sentiment.column = "category", model.file = "sentimentmodel1.bin" ) td_sentiment_extractor_out4 <- td_sentiment_extractor_mle(object = "classification:sentimentmodel1.bin", newdata = sentiment_extract_input, text.column = "review", level = "document", accumulate = c("id") ) # This example uses a dictionary instead of a model file td_sentiment_extractor_out5 <- td_sentiment_extractor_mle(newdata = sentiment_extract_input, dict.data = sentiment_word, text.column = "review", level = "document", accumulate = c("id", "product") )