review_analysis / app.py
Hendra Wijaya Djiono
Add app.py
253f433
raw
history blame
1.23 kB
# samples = [
# "The service at the restaurant was really impressive",
# "What is the status of my order number #1234?",
# "I have a proposal for a new feature in your app",
# "My package arrived late and the item was damaged",
# "Your team is doing an excellent job",
# "Could you help clarify the specifications of this product?",
# "I'm extremely dissatisfied with the customer service",
# "Have you thought about offering more plant-based options on your menu?",
# "I really appreciate the speedy response from your customer service team",
# "I enjoy using your application, great work"
# ]
%pip install transformers
from transformers import pipeline
import gradio as gr
classifier = pipeline(
"zero-shot-classification",
model="facebook/bart-large-mnli",
)
candidate_labels = ["opinion", "complaint", "query", "suggestion", "appreciation"]
def analyze_sentiment(text):
for text in texts:
# Classify the text
label = classifier(text, candidate_labels)
# Print the text and its corresponding label
print("Text: " + text+ ", Label: " + label)
demo = gr.Interface(fn=analyze_sentiment, inputs="text", outputs="text")
demo.launch()