Download app.py from abersbail/sentiment-analyzer-cpu: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/spaces/abersbail/sentiment-analyzer-cpu/resolve/c34bacc320d4976e8d8ae589245e2717caafb223/app.py
- Command line
-
hf download hf://spaces/abersbail/sentiment-analyzer-cpu@c34bacc320d4976e8d8ae589245e2717caafb223/app.py
-
curl -L -o app.py https://huggingface.co/spaces/abersbail/sentiment-analyzer-cpu/resolve/c34bacc320d4976e8d8ae589245e2717caafb223/app.py
1 kB
| import gradio as gr | |
| from sentiment_tool.service import SentimentService | |
| service = SentimentService() | |
| def analyze_sentiment(text): | |
| return service.analyze(text) | |
| with gr.Blocks( | |
| title="Sentiment Analyzer CPU", | |
| theme=gr.themes.Soft(primary_hue="yellow", secondary_hue="gray"), | |
| ) as demo: | |
| gr.Markdown( | |
| """ | |
| # Sentiment Analyzer CPU | |
| Paste text and get positive, neutral, and negative sentiment scores. | |
| """ | |
| ) | |
| text_input = gr.Textbox(label="Input Text", lines=8, placeholder="Write review, opinion, or message here") | |
| run_button = gr.Button("Analyze", variant="primary") | |
| label_output = gr.Textbox(label="Top Label", lines=1) | |
| score_output = gr.Textbox(label="Score Breakdown", lines=4) | |
| status_output = gr.Textbox(label="Status", lines=2) | |
| run_button.click( | |
| fn=analyze_sentiment, | |
| inputs=[text_input], | |
| outputs=[label_output, score_output, status_output], | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |