Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,18 @@
|
|
1 |
import gradio as gr
|
2 |
from simpletransformers.ner import NERModel
|
3 |
import string
|
4 |
-
|
5 |
-
"B-FOOD_QUANTITY",
|
6 |
-
|
7 |
-
"B-FOOD",
|
8 |
-
"I-FOOD",
|
9 |
-
"B-FOOD_INGREDIENTS",
|
10 |
-
"I-FOOD_INGREDIENTS",
|
11 |
-
"B-DRINK_SIZE",
|
12 |
-
"B-DRINK_QUANTITY",
|
13 |
-
"B-DRINK",
|
14 |
-
"B-PAYMENT",
|
15 |
-
"I-PAYMENT",
|
16 |
-
"B-DELIVERY_ADDRESS",
|
17 |
-
"I-DRINK_SIZE",
|
18 |
-
"I-DRINK",
|
19 |
-
"I-FOOD_SIZE",
|
20 |
-
"I-ING",
|
21 |
-
"I-DELIVERY_ADDRESS"]
|
22 |
model = NERModel(
|
23 |
-
"
|
24 |
-
"bgk/
|
25 |
use_cuda=False,
|
26 |
ignore_mismatched_sizes=True
|
27 |
)
|
28 |
-
|
|
|
|
|
29 |
def ner(text):
|
30 |
trans_table = text.maketrans('', '', string.punctuation)
|
31 |
text = text.translate(trans_table)
|
@@ -42,8 +29,10 @@ def ner(text):
|
|
42 |
entities.extend([(label, v)])
|
43 |
|
44 |
return entities # prediction
|
|
|
45 |
demo = gr.Interface(ner,
|
46 |
gr.Textbox(placeholder="Enter sentence here..."),
|
47 |
gr.HighlightedText(),
|
48 |
examples=examples)
|
|
|
49 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from simpletransformers.ner import NERModel
|
3 |
import string
|
4 |
+
|
5 |
+
labels = ["O", "B-FOOD_QUANTITY", "B-FOOD_SIZE", "B-FOOD", "I-FOOD", "B-FOOD_INGREDIENTS", "I-FOOD_INGREDIENTS", "B-DRINK_SIZE", "B-DRINK_QUANTITY", "B-DRINK", "B-PAYMENT", "I-PAYMENT", "B-DELIVERY_ADDRESS", "I-DRINK_SIZE", "I-DRINK", "I-FOOD_SIZE", "I-ING", "I-DELIVERY_ADDRESS"]
|
6 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
model = NERModel(
|
8 |
+
"roberta",
|
9 |
+
"bgk/berteng", labels=labels,
|
10 |
use_cuda=False,
|
11 |
ignore_mismatched_sizes=True
|
12 |
)
|
13 |
+
|
14 |
+
examples=[['I want two hamburgers and one sprite and one milkshake send it to my workplace' ], [' I want to order two large pizzas, two medium coke, send it to my home, I will pay with cash' ]]
|
15 |
+
|
16 |
def ner(text):
|
17 |
trans_table = text.maketrans('', '', string.punctuation)
|
18 |
text = text.translate(trans_table)
|
|
|
29 |
entities.extend([(label, v)])
|
30 |
|
31 |
return entities # prediction
|
32 |
+
|
33 |
demo = gr.Interface(ner,
|
34 |
gr.Textbox(placeholder="Enter sentence here..."),
|
35 |
gr.HighlightedText(),
|
36 |
examples=examples)
|
37 |
+
|
38 |
demo.launch()
|