-1

I have a data frame called Comments_Final which has one column - "Comments"

this column has different reviews like for example

1.Fit good fast shipping

2.Product as described and functioned perfectly.

3.this product doesn't fit my Remington rm1415 it is way to long and much larger chain..... looks like it would be a pain to return to Canada to sender

4.Would have given it 5 stars but it is not a sealed battery

5.Was not told I needed to sign to receive item missed delivery, made contact with carrier , then received item next day!

6.Quick delivery. Part as expected

so first i want a column called sentiment which will show that review is negative or positive?

and second i want third column as emotion that will tell you that review defines anger, sad,joy,disgust etc. emotions in that.

  • read this [blog](https://www.analyticsvidhya.com/blog/2018/02/natural-language-processing-for-beginners-using-textblob/). – vb_rises May 09 '19 at 15:53

1 Answers1

0

You can use the below code. Only thing is textblob does not provide emotion analysis, so you won't be able to extract anger, joy, happy, etc emotions from it. Text Blob provides two different methods for sentiment analysis. One is PatternAnalyzer and another is NaiveBayesAnalyzer, you can read more about it on the below link.

https://textblob.readthedocs.io/en/dev/advanced_usage.html#advanced

from textblob import TextBlob
from textblob.sentiments import NaiveBayesAnalyzer

Comments_Final["Sentiment"] = [TextBlob(k, analyzer=NaiveBayesAnalyzer()).sentiment.classification for k in Comments_Final['Comments']]
Nayan
  • 11
  • 2