Spaces:
Runtime error
Runtime error
File size: 634 Bytes
dc5b022 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | from transformers import pipeline
from utils import clean_text, generate_wordcloud
# Load Hugging Face models
sentiment_model = pipeline("sentiment-analysis")
summarizer = pipeline("summarization")
def process_comment(text):
# Clean text
cleaned = clean_text(text)
# Sentiment
sentiment = sentiment_model(cleaned)[0]
# Summary
try:
summary = summarizer(cleaned, max_length=60, min_length=10, do_sample=False)[0]["summary_text"]
except:
summary = "Summary not available (text too short)."
# Word cloud
wc_img = generate_wordcloud(cleaned)
return sentiment, summary, wc_img
|