Spaces:
Sleeping
Sleeping
Hendra Wijaya Djiono
commited on
Commit
•
253f433
1
Parent(s):
ce632e6
Add app.py
Browse files
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# samples = [
|
2 |
+
# "The service at the restaurant was really impressive",
|
3 |
+
# "What is the status of my order number #1234?",
|
4 |
+
# "I have a proposal for a new feature in your app",
|
5 |
+
# "My package arrived late and the item was damaged",
|
6 |
+
# "Your team is doing an excellent job",
|
7 |
+
# "Could you help clarify the specifications of this product?",
|
8 |
+
# "I'm extremely dissatisfied with the customer service",
|
9 |
+
# "Have you thought about offering more plant-based options on your menu?",
|
10 |
+
# "I really appreciate the speedy response from your customer service team",
|
11 |
+
# "I enjoy using your application, great work"
|
12 |
+
# ]
|
13 |
+
%pip install transformers
|
14 |
+
|
15 |
+
from transformers import pipeline
|
16 |
+
import gradio as gr
|
17 |
+
|
18 |
+
classifier = pipeline(
|
19 |
+
"zero-shot-classification",
|
20 |
+
model="facebook/bart-large-mnli",
|
21 |
+
)
|
22 |
+
|
23 |
+
candidate_labels = ["opinion", "complaint", "query", "suggestion", "appreciation"]
|
24 |
+
|
25 |
+
def analyze_sentiment(text):
|
26 |
+
for text in texts:
|
27 |
+
# Classify the text
|
28 |
+
label = classifier(text, candidate_labels)
|
29 |
+
|
30 |
+
# Print the text and its corresponding label
|
31 |
+
print("Text: " + text+ ", Label: " + label)
|
32 |
+
|
33 |
+
demo = gr.Interface(fn=analyze_sentiment, inputs="text", outputs="text")
|
34 |
+
demo.launch()
|