File size: 474 Bytes
e7fc8a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

from transformers import pipeline

def analyze_sentiment(text):
    """
    Analyzes the sentiment of a given text using a pretrained model.
    """
    sentiment_pipeline = pipeline("sentiment-analysis")
    result = sentiment_pipeline(text)
    return result

if __name__ == '__main__':
    text_to_analyze = "I love the new AI model! It's so innovative and powerful."
    sentiment = analyze_sentiment(text_to_analyze)
    print("Sentiment analysis result:", sentiment)