我已经使用 vader 库来标记亚马逊的评论,但它不处理这些类型的评论“它没有问题并且做得很好。将它用于 Apple TV 并且效果很好。我会再次购买没问题”。这是肯定句,但代码将其标记为否定句。我该如何处理这些类型的评论。
import nltk
nltk.download('vader_lexicon')
nltk.download('punkt')
from nltk.sentiment.vader import SentimentIntensityAnalyzer
sid = SentimentIntensityAnalyzer()
output['sentiment'] = output['review_body'].apply(lambda x: sid.polarity_scores(x))
def convert(x):
if x < 0:
return "negative"
elif x > .2:
return "positive"
else:
return "neutral"
output['result'] = output['sentiment'].apply(lambda x:convert(x['compound']))
这是示例文件:
0 No problems with it and does job well. Using it for Apple TV and works great. I would buy
again no problem
1 I don't know what happened with other buyers, but I received it today from Yakodo in a good
bubble envelope and the product is not a counterfeit: it's a genuine Apple product. It comes
into a little box with two information booklets. The adapter is genuine, I'm completely sure
because looks and feels the same compared with one from an Apple reseller. The latest iOS
(7.1.2) has no issues with it (no warnings) using it with an iPhone 5S and an iPad mini
Retina... No issues because it is genuine. Don't hesitate: it's a great deal for a fraction
of its price.
2 Keeps me smiling when listening to the music.
3 DOES THE JOB. HAPPY.
4 Don't like it