File size: 324 Bytes
2211181
214013d
 
 
 
 
 
efb3a3f
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12

from transformers import pipeline

nlp = pipeline("sentiment-analysis")

def scoring(text):
    results = nlp(text)
    sentiment = results[0]['label']  # Get the sentiment label (e.g., 'LABEL_1' or 'LABEL_2')
    score = results[0]['score']  # Get the sentiment score
    return f"Sentiment: {sentiment}, Score: {score}"