请问大家怎么实现输入多条评论,可以输出各个评论的情感倾向呀😭
import nltk
from nltk.sentiment.vader import SentimentIntensityAnalyzer
def analyze_sentiment(comments):
analyzer = SentimentIntensityAnalyzer()
for comment in comments:
scores = analyzer.polarity_scores(comment)
print("Comment:", comment)
print("Sentiment:", scores)
# 调用函数来分析多条评论
comments = ["I love this movie!", "I hate this movie!", "This movie is OK.", "I don't know what to think of this movie."]
analyze_sentiment(comments)