1 回答

TA貢獻1804條經(jīng)驗 獲得超7個贊
你的函數(shù)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)
添加回答
舉報