Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
1f60d56f
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看板
提交
1f60d56f
编写于
4月 30, 2020
作者:
B
barrierye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix lac web service
上级
bb01d56b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
10 deletion
+13
-10
python/examples/lac/lac_reader.py
python/examples/lac/lac_reader.py
+3
-3
python/examples/lac/lac_web_service.py
python/examples/lac/lac_web_service.py
+10
-7
未找到文件。
python/examples/lac/lac_reader.py
浏览文件 @
1f60d56f
...
...
@@ -108,15 +108,15 @@ class LACReader(object):
partial_word
=
""
for
ind
,
tag
in
enumerate
(
tags
):
if
partial_word
==
""
:
partial_word
=
words
[
ind
]
partial_word
=
self
.
id2word_dict
[
str
(
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
]
partial_word
=
self
.
id2word_dict
[
str
(
words
[
ind
])
]
continue
partial_word
+=
words
[
ind
]
partial_word
+=
self
.
id2word_dict
[
str
(
words
[
ind
])
]
if
len
(
sent_out
)
<
len
(
tags_out
):
sent_out
.
append
(
partial_word
)
...
...
python/examples/lac/lac_web_service.py
浏览文件 @
1f60d56f
...
...
@@ -22,22 +22,24 @@ class LACService(WebService):
self
.
reader
=
LACReader
(
"lac_dict"
)
def
preprocess
(
self
,
feed
=
{},
fetch
=
[]):
batch_feed
=
[]
feed_batch
=
[]
for
ins
in
feed
:
if
"words"
not
in
ins
:
raise
(
"feed data error!"
)
feed_data
=
self
.
reader
.
process
(
ins
[
"words"
])
batch_feed
.
append
({
"words"
:
feed_data
})
feed_batch
.
append
({
"words"
:
feed_data
})
fetch
=
[
"crf_decode"
]
return
batch_feed
,
fetch
return
feed_batch
,
fetch
def
postprocess
(
self
,
feed
=
{},
fetch
=
[],
fetch_map
=
{}):
ret
=
[]
batch_
ret
=
[]
for
idx
,
ins
in
enumerate
(
feed
):
begin
=
fetch_map
[
'crf_decode.lod'
][
idx
]
end
=
fetch_map
[
'crf_decode.lod'
][
idx
+
1
]
segs
=
self
.
reader
.
parse_result
(
ins
[
"words"
],
fetch_map
[
idx
][
"crf_decode"
])
ret
.
append
({
"word_seg"
:
"|"
.
join
(
segs
)})
return
ret
fetch_map
[
"crf_decode"
][
begin
:
end
])
batch_
ret
.
append
({
"word_seg"
:
"|"
.
join
(
segs
)})
return
batch_
ret
lac_service
=
LACService
(
name
=
"lac"
)
...
...
@@ -46,3 +48,4 @@ lac_service.load_reader()
lac_service
.
prepare_server
(
workdir
=
sys
.
argv
[
2
],
port
=
int
(
sys
.
argv
[
3
]),
device
=
"cpu"
)
lac_service
.
run_server
()
lac_service
.
run_flask
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录