File size: 204 Bytes
a29d505
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
from transformers import pipeline

# Load the model once on import
sentiment_pipeline = pipeline("sentiment-analysis")

def get_sentiment(text):
    result = sentiment_pipeline(text)
    return result[0]