genaibeauty commited on
Commit
5e5e6b2
Β·
verified Β·
1 Parent(s): 0ef0ab3

Create sentiment.py

Browse files
Files changed (1) hide show
  1. sentiment.py +8 -0
sentiment.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+
3
+ # Load Hugging Face sentiment analysis model
4
+ sentiment_analyzer = pipeline("sentiment-analysis")
5
+
6
+ def analyze_sentiment(text):
7
+ """Analyze sentiment of extracted text."""
8
+ return sentiment_analyzer(text[:512]) # Limit to 512 characters for model efficiency