Spaces:
Sleeping
Sleeping
from sentiment_analysis import SentimentAnalysisTool | |
# Create an instance of the tool | |
sentiment_tool = SentimentAnalysisTool() | |
# Launch the Gradio interface | |
if __name__ == "__main__": | |
import gradio as gr | |
with gr.Blocks(title="Sentiment Analysis Tool") as demo: | |
gr.Markdown("# Sentiment Analysis Tool") | |
with gr.Row(): | |
with gr.Column(): | |
text_input = gr.Textbox( | |
label="Enter text to analyze", | |
placeholder="Type your text here...", | |
lines=5 | |
) | |
with gr.Row(): | |
analyze_btn = gr.Button("Analyze Sentiment") | |
clear_btn = gr.Button("Clear") | |
with gr.Column(): | |
output = gr.JSON(label="Sentiment Analysis Results") | |
analyze_btn.click( | |
fn=sentiment_tool, | |
inputs=text_input, | |
outputs=output | |
) | |
clear_btn.click( | |
fn=lambda: ("", None), | |
inputs=None, | |
outputs=[text_input, output] | |
) | |
gr.Examples( | |
examples=[ | |
["I love this product! It's amazing and works perfectly."], | |
["This movie was terrible. I was very disappointed."], | |
["The service was okay, but could be improved in several ways."] | |
], | |
inputs=text_input | |
) | |
demo.launch(share=True) |