Hive - Project

8 / 14
Hive - Project - Sentiment Analysis - Step - 6

In this step, we will create views to calculate sentiment of each tweet.

Steps

  1. Create view l1. l1 view stores list of words from the tweet. Sample rows of view l1 are
    Run below command in Hive query editor in Hue.

    create view l1 as select id, words from tweets_raw lateral view explode(sentences(lower(text))) dummy as words;
    
  2. Create view l2. l2 view stores every word of a tweet in a new row. Sample rows of view l2 are
    Run below command in Hive query editor in Hue.

    create view l2 as select id, word from l1 lateral view explode( words ) dummy as word ;
    
  3. Create view l3. l3 view stores polarity of each word. Sample rows of view l3 are
    Run below command in Hive query editor in Hue.

    create view l3 as select 
    id, 
    l2.word,
    case d.polarity 
    when  'negative' then -1
    when 'positive' then 1 
    else 0 end as polarity 
    from l2 left outer join dictionary d on l2.word = d.word;
    

Question-

What is the polarity of word "crushes"?

  • 0
  • 1
  • 2
  • 3