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

# Load Hugging Face sentiment analysis model
sentiment_analyzer = pipeline("sentiment-analysis")

def analyze_sentiment(text):
    """Analyze sentiment of extracted text."""
    return sentiment_analyzer(text[:512])  # Limit to 512 characters for model efficiency