Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
33a670cd
S
Serving
项目概览
PaddlePaddle
/
Serving
1 年多 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
33a670cd
编写于
4月 02, 2020
作者:
W
wangjiawei04
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify lac python script
上级
dcb3e281
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
3 deletion
+36
-3
python/examples/lac/get_data.sh
python/examples/lac/get_data.sh
+2
-2
python/examples/lac/lac_client.py
python/examples/lac/lac_client.py
+1
-1
python/examples/lac/lac_reader.py
python/examples/lac/lac_reader.py
+27
-0
python/examples/lac/lac_web_service.py
python/examples/lac/lac_web_service.py
+6
-0
未找到文件。
python/examples/lac/get_data.sh
浏览文件 @
33a670cd
wget
--no-check-certificate
https://paddle-serving.bj.bcebos.com/lac/lac_model.tar.gz
tar
-zxvf
lac_model.tar.gz
wget
--no-check-certificate
https://paddle-serving.bj.bcebos.com/lac/lac_model
_jieba_web
.tar.gz
tar
-zxvf
lac_model
_jieba_web
.tar.gz
python/examples/lac/lac_client.py
浏览文件 @
33a670cd
...
...
@@ -22,7 +22,7 @@ import io
client
=
Client
()
client
.
load_client_config
(
sys
.
argv
[
1
])
client
.
connect
([
"127.0.0.1:92
80
"
])
client
.
connect
([
"127.0.0.1:92
92
"
])
reader
=
LACReader
(
sys
.
argv
[
2
])
for
line
in
sys
.
stdin
:
...
...
python/examples/lac/lac_reader.py
浏览文件 @
33a670cd
...
...
@@ -99,3 +99,30 @@ class LACReader(object):
words
=
sent
.
strip
()
word_ids
=
self
.
word_to_ids
(
words
)
return
word_ids
def
parse_result
(
self
,
words
,
crf_decode
):
tags
=
[
self
.
id2label_dict
[
str
(
x
)]
for
x
in
crf_decode
]
sent_out
=
[]
tags_out
=
[]
partial_word
=
""
for
ind
,
tag
in
enumerate
(
tags
):
if
partial_word
==
""
:
partial_word
=
words
[
ind
]
tags_out
.
append
(
tag
.
split
(
'-'
)[
0
])
continue
if
tag
.
endswith
(
"-B"
)
or
(
tag
==
"O"
and
tag
[
ind
-
1
]
!=
"O"
):
sent_out
.
append
(
partial_word
)
tags_out
.
append
(
tag
.
split
(
'-'
)[
0
])
partial_word
=
words
[
ind
]
continue
partial_word
+=
words
[
ind
]
if
len
(
sent_out
)
<
len
(
tags_out
):
sent_out
.
append
(
partial_word
)
return
sent_out
python/examples/lac/lac_web_service.py
浏览文件 @
33a670cd
...
...
@@ -25,8 +25,14 @@ class LACService(WebService):
if
"words"
not
in
feed
:
raise
(
"feed data error!"
)
feed_data
=
self
.
reader
.
process
(
feed
[
"words"
])
fetch
=
[
"crf_decode"
]
return
{
"words"
:
feed_data
},
fetch
def
postprocess
(
self
,
feed
=
{},
fetch
=
[],
fetch_map
=
{}):
segs
=
self
.
reader
.
parse_result
(
feed
[
"words"
],
fetch_map
[
"crf_decode"
])
return
{
"word_seg"
:
"|"
.
join
(
segs
)}
lac_service
=
LACService
(
name
=
"lac"
)
lac_service
.
load_model_config
(
sys
.
argv
[
1
])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录