lynn-twinkl
Fixed bug preventing file with NaN responses from being processed
086b526
raw
history blame contribute delete
344 Bytes
from textblob import TextBlob
def analyze_sentiment(text):
if isinstance(text, str):
analysis = TextBlob(text)
return analysis.sentiment.polarity
def label_sentiment(score, threshold=0.2):
if score > threshold:
return 'Positive'
elif score < 0:
return 'Negative'
else:
return 'Neutral'