Spaces:
Running
Running
File size: 1,508 Bytes
1843ae2 c52adb8 0065a7e e66f4f9 |
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
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) |