Spaces:
Sleeping
Sleeping
# 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" | |
# ] | |
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): | |
# Classify the text | |
label = classifier(text, candidate_labels)['labels'][0] | |
# Print the text and its corresponding label | |
print("Text: " + text + ", Label: " + label) | |
return label | |
demo = gr.Interface(fn=analyze_sentiment, inputs="text", outputs="text") | |
demo.launch() |