Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,10 +13,7 @@ rdrsegmenter = py_vncorenlp.VnCoreNLP(annotators=["wseg"], save_dir='/home/user/
|
|
| 13 |
|
| 14 |
class MyPipeline(TokenClassificationPipeline):
|
| 15 |
def preprocess(self, sentence, offset_mapping=None):
|
| 16 |
-
truncation = True if self.tokenizer.model_max_length and self.tokenizer.model_max_length > 0 else False
|
| 17 |
-
|
| 18 |
-
sentence = " ".join(rdrsegmenter.word_segment(sentence))
|
| 19 |
-
|
| 20 |
|
| 21 |
model_inputs = self.tokenizer(
|
| 22 |
sentence,
|
|
@@ -57,10 +54,12 @@ my_classifier = pipeline(
|
|
| 57 |
import gradio as gr
|
| 58 |
|
| 59 |
def ner(text):
|
|
|
|
|
|
|
| 60 |
output = my_classifier(text)
|
| 61 |
for entity in output:
|
| 62 |
entity['entity'] = entity.pop('entity_group')
|
| 63 |
-
return {'text': text, 'entities': output}
|
| 64 |
|
| 65 |
examples = ['tôi cần thuê à tôi muốn bay một chuyến khứ_hồi từ đà_nẵng đến đà_lạt',
|
| 66 |
'giá vé một_chiều à không khứ_hồi từ đà_nẵng đến vinh dưới 2 triệu đồng giá vé khứ_hồi từ quy nhơn đến vinh dưới 3 triệu đồng giá vé khứ_hồi từ buôn_ma_thuột đến quy nhơn à đến vinh dưới 4 triệu rưỡi',
|
|
@@ -70,7 +69,7 @@ examples = ['tôi cần thuê à tôi muốn bay một chuyến khứ_hồi từ
|
|
| 70 |
|
| 71 |
demo = gr.Interface(ner,
|
| 72 |
gr.Textbox(label='Text', placeholder="Enter sentence here..."),
|
| 73 |
-
gr.HighlightedText(label='Highlighted Output'),
|
| 74 |
examples=examples,
|
| 75 |
title="Disfluency Detection",
|
| 76 |
description="This is an easy-to-use built in Gradio for desmontrating a NER System that identifies disfluency-entities in \
|
|
|
|
| 13 |
|
| 14 |
class MyPipeline(TokenClassificationPipeline):
|
| 15 |
def preprocess(self, sentence, offset_mapping=None):
|
| 16 |
+
truncation = True if self.tokenizer.model_max_length and self.tokenizer.model_max_length > 0 else False
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
model_inputs = self.tokenizer(
|
| 19 |
sentence,
|
|
|
|
| 54 |
import gradio as gr
|
| 55 |
|
| 56 |
def ner(text):
|
| 57 |
+
text = " ".join(rdrsegmenter.word_segment(text))
|
| 58 |
+
|
| 59 |
output = my_classifier(text)
|
| 60 |
for entity in output:
|
| 61 |
entity['entity'] = entity.pop('entity_group')
|
| 62 |
+
return {'text': text, 'entities': output}, text
|
| 63 |
|
| 64 |
examples = ['tôi cần thuê à tôi muốn bay một chuyến khứ_hồi từ đà_nẵng đến đà_lạt',
|
| 65 |
'giá vé một_chiều à không khứ_hồi từ đà_nẵng đến vinh dưới 2 triệu đồng giá vé khứ_hồi từ quy nhơn đến vinh dưới 3 triệu đồng giá vé khứ_hồi từ buôn_ma_thuột đến quy nhơn à đến vinh dưới 4 triệu rưỡi',
|
|
|
|
| 69 |
|
| 70 |
demo = gr.Interface(ner,
|
| 71 |
gr.Textbox(label='Text', placeholder="Enter sentence here..."),
|
| 72 |
+
outputs=[gr.HighlightedText(label='Highlighted Output'), 'text'],
|
| 73 |
examples=examples,
|
| 74 |
title="Disfluency Detection",
|
| 75 |
description="This is an easy-to-use built in Gradio for desmontrating a NER System that identifies disfluency-entities in \
|