1.1 - 8.10 - SentimentExtractor Example: Dictionary Table Instead of Model File - Teradata Vantage

Teradata Vantage™ - Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.1
8.10
Release Date
October 2019
Content Type
Programming Reference
Publication ID
B700-4003-079K
Language
English (United States)

This example uses a dictionary table, sentiment_word, instead of a model file.

Input

sentiment_word
word opinion
screwed 2
excellent 2
incredible 2
terrific 2
outstanding 2
fun 1
love 1
nice 1
big 0
update 0
constant 0
small 0
mistake -1
difficulty -1
disappointed -1
not tolerate -1
stuck -1
terrible -2
crap -2

SQL Call

SELECT * FROM SentimentExtractor (
  ON sentiment_extract_input PARTITION BY ANY
  ON sentiment_word AS Dict DIMENSION
  USING
  TextColumn ('review')
  AnalysisType ('document')
  Accumulate ('id', 'product')
) AS dt ORDER BY id;

Output

 id product      out_polarity out_strength out_sentiment_words                                                       
 -- ------------ ------------ ------------ ------------------------------------------------------------------------- 
  1 camera       POS                     2 excellent 2, excellent 2. In total, positive score:4 negative score:0    
  2 office suite POS                     2 terrific 2, terrific 2. In total, positive score:4 negative score:0      
  3 camera       POS                     2 nice 1. In total, positive score:1 negative score:0                      
  4 gps          POS                     2 outstanding 2, incredible 2. In total, positive score:4 negative score:0 
  5 gps          POS                     2 nice 1, big 0. In total, positive score:1 negative score:0               
  6 gps          NEU                     0 update 0. In total, positive score:0 negative score:0                    
  7 gps          POS                     2 screwed 2. In total, positive score:2 negative score:0                   
  8 camera       NEG                     2 stuck -1, difficulty -1. In total, positive score:0 negative score:-2    
  9 television   NEG                     2 crap -2, big 0. In total, positive score:0 negative score:-2             
 10 camera       NEG                     2 not tolerate -1, constant 0. In total, positive score:0 negative score:-1

Download a zip file of all examples and a SQL script file that creates their input tables from the attachment in the left sidebar.