10-22-2016 04:20 PM - last edited on 10-22-2016 06:44 PM by Reeza
I have to analyize a tweet for example :
This is not good at all.
we have a table which includes words with there polarity values.
not good -3
When i pass this through code i should get a polarity of tweet as -3 and not +3.
"good" has a positive polarity but since a "not" comes before it the whole meaning changes.
Help me out with this one.
10-22-2016 07:26 PM
A data step is all you need.
1. Create a format for lookup table
2. Break a sentence into words. Since these are tweets you have a limit of words so splitting into an array should be easy enough. CountW will tell you how many words.
3a. Loop through each word for 1 gram, apply format and if found output score.
3b. Loop through again for 2 gram, apply format and if found output score
3c. 3a/3b for 3 gram.
10-22-2016 07:32 PM
ya i was able to get to the part of splitting words. bt i still didnt get how to apply the n gram logic.
It would be great if you can help me with a sample code for above example.
10-22-2016 09:16 PM
I'm not downloading a zip file. Most won't either.
Add as plain text into your post, ideally as a data step
10-22-2016 08:18 PM
The question and code here are relevant, but the techniques may be beyond your programming skills. I'm a proponent of understanding your code.
10-23-2016 06:01 AM
Does your polarity table contains priority of checking words ?
Which columns do you have in this polarity table ? Can you add columns to it ?
Using a simple data step with indexw() function can do the work,
here, without using a polarity table, but just coding your example:
text = 'This is not good at all. ';
if indexw(text, 'not good') > 0 then polarity=-3; else /* priority 1 */
if indexw(text,'good') > 0 then polarity = 3; /* priority 2 */