File size: 711 Bytes
94fefab |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
from transformers import pipeline
import gradio as gr
# Hugging Face's sentiment analysis pipeline
sentiment_analysis = pipeline('sentiment-analysis')
# Function to analyze customer feedback
def analyze_feedback(feedback):
result = sentiment_analysis(feedback)
return f"Sentiment: {result[0]['label']} (Confidence: {result[0]['score']:.2f})"
# Gradio interface for feedback analysis
with gr.Blocks() as feedback_app:
feedback = gr.Textbox(label="Customer Feedback")
analyze_button = gr.Button("Analyze Feedback")
sentiment_output = gr.Textbox(label="Sentiment Analysis")
analyze_button.click(fn=analyze_feedback, inputs=feedback, outputs=sentiment_output)
feedback_app.launch()
|