1 回答
TA贡献1804条经验 获得超7个赞
你的函数sentLabelreturn None。因此,当您使用时print(sentLabel(b1)),它会打印None.
这应该适合你。
from textblob import TextBlob
def sentLabel(blob):
label = blob.sentiment.polarity
if(label == 0.0):
print('Neutral')
elif(label > 0.0):
print('Positive')
else:
print('Negative')
Feedback1 = "The food in the canteen was awesome"
Feedback2 = "The food in the canteen was awful"
Feedback3 = "The canteen has food"
b1 = TextBlob(Feedback1)
b2 = TextBlob(Feedback2)
b3 = TextBlob(Feedback3)
print(b1.sentiment_assessments)
sentLabel(b1)
print(b2.sentiment_assessments)
sentLabel(b2)
print(b3.sentiment_assessments)
sentLabel(b3)
添加回答
举报
