Spaces:
Runtime error
Runtime error
Create sentiment.py
Browse files- 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
|