Dum Potato
Dum Potato

Reputation: 965

Can NLTK be used to Analyse the sentiment a certain word has within a sentence?

I have a quick question and could not find the answer anywhere on the internet:

Can NLTK be used to Analyze the sentiment a certain word has within a sentence?

Like: Sentiment for iPhone: "Even though it is terrible weather outside, my iPhone makes me feel good again." = Sentiment: positive

Upvotes: 0

Views: 1209

Answers (2)

Himanshu Gahlot
Himanshu Gahlot

Reputation: 235

I do not have much experience with NLTK but I have done some concept level sentiment analysis using NLP libraries in Java. Here is how I did it. The same approach should work for you if you are able to identify dependencies in NLTK. This approach works fine for simple rules but may not work well for complicated sentences.

Upvotes: 0

alexis
alexis

Reputation: 50200

Have you thought of breaking down the text into clauses ("it is terrible weather outside", "my iphone makes me feel good again"), and evaluating them separately? You can use the NLTK's parsers for that. This will reduce the amount of text you have to analyze, though, so it might end up doing more harm than good.

This won't help you in cases like "Microsoft Surface is no iPad, it's terrible" (where your target is "iPad"), since the sentiment is negative but the iPad wins the comparison. So perhaps you'll also want to check the syntactic analysis, and only examine sentences where your target word is the subject or object. Whether these will give you better performance is anybody's guess, I think.

Upvotes: 2

Related Questions