Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
classifier = pipeline("zero-shot-classification", model="typeform/distilbert-base-uncased-mnli")
|
| 5 |
+
|
| 6 |
+
def classify_email(text):
|
| 7 |
+
labels = ["встреча", "отказ", "уточнение"]
|
| 8 |
+
result = classifier(text, candidate_labels=labels)
|
| 9 |
+
label = result["labels"][0]
|
| 10 |
+
if label == "встреча":
|
| 11 |
+
return "1"
|
| 12 |
+
elif label == "отказ":
|
| 13 |
+
return "2"
|
| 14 |
+
elif label == "уточнение":
|
| 15 |
+
return "3"
|
| 16 |
+
else:
|
| 17 |
+
return "?"
|
| 18 |
+
|
| 19 |
+
iface = gr.Interface(fn=classify_email, inputs="text", outputs="text", title="Email Classifier")
|
| 20 |
+
iface.launch()
|