Spaces:
Runtime error
Runtime error
Download pipeline.py from Pro-Coder/Sentiment_Analysis: direct link, hf CLI and curl.
- Browser
- Download file 634 Bytes
-
https://huggingface.co/spaces/Pro-Coder/Sentiment_Analysis/resolve/dc5b0227efed10285e52e776397fdcd79b4fa546/pipeline.py
- Command line
-
hf download hf://spaces/Pro-Coder/Sentiment_Analysis@dc5b0227efed10285e52e776397fdcd79b4fa546/pipeline.py
-
curl -L -o pipeline.py https://huggingface.co/spaces/Pro-Coder/Sentiment_Analysis/resolve/dc5b0227efed10285e52e776397fdcd79b4fa546/pipeline.py
634 Bytes
| 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 | |