Spaces:
Sleeping
Sleeping
File size: 643 Bytes
20d97e8 90faf8d 20d97e8 90faf8d 20d97e8 90faf8d 20d97e8 90faf8d 20d97e8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
from transformers import pipeline
# Loading a sentiment model
sentiment_model = pipeline("sentiment-analysis", model="cardiffnlp/twitter-xlm-roberta-base-sentiment")
def analyze_sentiment(text):
"""
Uses a specialized sentiment model better suited for medical text.
"""
result = sentiment_model(text)[0]["label"]
if result.lower() == "positive":
return "Positive"
elif result.lower() == "negative":
return "Concerned"
return "Neutral"
if __name__ == "__main__":
sample_text = "I've been feeling really weak for the past few days."
print(f"Sentiment: {analyze_sentiment(sample_text)}")
|