genaibeauty's picture
Create sentiment.py
5e5e6b2 verified
raw
history blame contribute delete
299 Bytes
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