Analyzing the Sentiment of Specific Authors

You can use the white_list feature of SentimentAnalysis() to filter the attributes so only the white_list terms are returned. You can combine the white_list with a query for a list of specific authors to narrow down the results to a specific subset of authors.

Using the same tweet_samples table in Analyzing Comments for a Company or Product, add the following sample tweets:

INSERT INTO tweets_sample VALUES('123', 'bcook', 
'The hyperdrive is a great machine.'); INSERT INTO tweets_sample VALUES('124', 'sprock',
'The hyperdrive is a pinnacle of technology.'); INSERT INTO tweets_sample VALUES('125', 'tgates',
'What is a hyperdrive?'); INSERT INTO tweets_sample VALUES('126', 'bcook', 'Roses are red.'); INSERT INTO tweets_sample VALUES('127', 'sprock',
'Energy equals mass times the speed of light squared.'); INSERT INTO tweets_sample VALUES('128', 'tgates', 'Violets are blue.');
commit;

Create an authors table to hold the names of the authors whose sentiment you want to analyze:

CREATE TABLE authors (name VARCHAR, screenname VARCHAR);

Then insert the following authors:

INSERT INTO authors VALUES('Brian Cook','bcook');
INSERT INTO authors VALUES('Tom Gates', 'tgates');
INSERT INTO authors VALUES('Jim Sprock', 'sprock');
commit;

Add the word 'hyperdrive' to your existing white_list and reload the white_list user-dictionary:

INSERT INTO pulse.white_list_en VALUES('hyperdrive');

SELECT LoadDictionary(standard USING PARAMETERS
listName='white_list') OVER() FROM pulse.white_list_en;

Then, you can run a query that filters on authors and the white_list and provides you with a sentiment score and the content of the analyzed text:

SELECT t1.id, t1.author, t1.attribute, t1.sentiment_score, t2.text from (SELECT id, author, SentimentAnalysis(text USING PARAMETERS 
whitelistonly=true) OVER (PARTITION BY id, author) FROM tweets_sample
WHERE author IN (SELECT screenname FROM authors)) AS t1 JOIN (SELECT id,
text FROM tweets_sample) AS t2 ON t1.id = t2.id ; id | author | attribute | sentiment_score | text -----+--------+-----------+-----------------+--------------------------- 123 | bcook | hyperdrive | 1 | The hyperdrive is a great 124 | sprock | hyperdrive | 1 | The hyperdrive is a pinnacle 125 | tgates | hyperdrive | 0 | What is a hyperdrive? (3 rows)