Spaces:
Runtime error
Runtime error
Add POS tagging
Browse files
app.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from deepthulac import LacModel
|
| 3 |
# import jieba
|
| 4 |
-
|
|
|
|
| 5 |
examples=["他在衬衫外套了件外套,出门去了。",
|
| 6 |
"这件和服务必在今天裁剪完毕。",
|
| 7 |
"把手抬起来",
|
|
@@ -30,8 +31,13 @@ def infer(
|
|
| 30 |
input_text,
|
| 31 |
**kwargs,
|
| 32 |
):
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
# https://discuss.huggingface.co/t/connection-errored-out/25329
|
| 37 |
# https://discuss.huggingface.co/t/error-connection-errored-out-during-processing/23439
|
|
@@ -49,6 +55,10 @@ gr.Interface(
|
|
| 49 |
lines=5,
|
| 50 |
label="分词结果",
|
| 51 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
# gr.inputs.Textbox(
|
| 53 |
# lines=5,
|
| 54 |
# label="jieba(对照)",
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from deepthulac import LacModel, SEG_MODEL, POS_MODEL
|
| 3 |
# import jieba
|
| 4 |
+
lac_seg = LacModel.load(path=SEG_MODEL, device='cpu')
|
| 5 |
+
lac_pos = LacModel.load(path=POS_MODEL, device='cpu')
|
| 6 |
examples=["他在衬衫外套了件外套,出门去了。",
|
| 7 |
"这件和服务必在今天裁剪完毕。",
|
| 8 |
"把手抬起来",
|
|
|
|
| 31 |
input_text,
|
| 32 |
**kwargs,
|
| 33 |
):
|
| 34 |
+
seg_res = lac_seg.seg(input_text.split('\n'), split_long=False)['seg']['res']
|
| 35 |
+
seg_res = '\n'.join([' / '.join(r) for r in seg_res])
|
| 36 |
+
pos_res = lac_pos.seg(input_text.split('\n'), split_long=False)['pos']['res']
|
| 37 |
+
pos_res = '\n'.join([' '.join(r) for r in pos_res])
|
| 38 |
+
# return '\n'.join([' / '.join(r) for r in res]) # , '\n'.join([' / '.join(jieba.cut(sent)) for sent in input_text.split('\n')])
|
| 39 |
+
# return '\n'.join([' / '.join(r) for r in res]),
|
| 40 |
+
return seg_res, pos_res
|
| 41 |
|
| 42 |
# https://discuss.huggingface.co/t/connection-errored-out/25329
|
| 43 |
# https://discuss.huggingface.co/t/error-connection-errored-out-during-processing/23439
|
|
|
|
| 55 |
lines=5,
|
| 56 |
label="分词结果",
|
| 57 |
),
|
| 58 |
+
gr.components.Textbox(
|
| 59 |
+
lines=5,
|
| 60 |
+
label="分词+词性标注结果",
|
| 61 |
+
),
|
| 62 |
# gr.inputs.Textbox(
|
| 63 |
# lines=5,
|
| 64 |
# label="jieba(对照)",
|