Use Sentiment Extraction with Teradata Package for R - Using Sentiment Extraction with Teradata Package for R - Teradata Package for R

Teradata® Package for R User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for R
Release Number
17.20
Published
March 2024
Language
English (United States)
Last Update
2024-04-09
dita:mapPath
efv1707506846369.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
nqx1518630623256
Product Category
Teradata Vantage

This example uses the td_sentiment_extractor_mle() sentiment extraction function from the tdplyr package to evaluate and classify a set of restaurant reviews.

The input data table "restaurant_reviews" table is listed here.

id review_text
1 This restaurant was great. The food was amazing. Our waiter was excellent. The appetizers in particular were very creative and well-thought-out.
2 I really enjoyed my meal, and my daughter's steak was perfectly prepared. The chocolate torte was superb.
3 The service was terrible! The food was ok, but the bread was stale and the drinks were very weak.
4 Not a must-do. Perfectly adequate but nothing special for the price.
5 I can't recommend this place. Service was slow and unfriendly. Food so-so.
6 Definitely a good choice for a special occasion. Highly recommended!
  1. Create a tibble from the input data table "restaurant_reviews".
    tddf_restaurant_reviews <- tbl(con, "restaurant_reviews")
    This example uses the default values for many arguments of the td_sentiment_extractor_mle() function. One of those is the object argument which specifies the source used to assign sentiment values to words. The default value of object argument is a built-in dictionary based on the WordNet lexical database.
  2. Call the sentiment extraction function.
    td_sentiment_extractor_out <- td_sentiment_extractor_mle(
    	object = "dictionary",
    	newdata = tddf_restaurant_reviews,
    	level = "document",
    	text.column = "review_text",
    	accumulate = c("id")
    )
  3. Inspect the result.
    print(td_sentiment_extractor_out$result)