iukhan commited on
Commit
94fefab
·
verified ·
1 Parent(s): 2399317

Create restaurant_feedback_analysis.py

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