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