rms / restaurant_feedback_analysis.py
iukhan's picture
Create restaurant_feedback_analysis.py
94fefab verified
raw
history blame contribute delete
711 Bytes
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()