提交 0eaa3dbe 编写于 作者: W wangjiawei04

Merge branch 'jiawei/lac_sync' into jiawei/doc_test

...@@ -30,6 +30,3 @@ python lac_web_service.py jieba_server_model/ lac_workdir 9292 ...@@ -30,6 +30,3 @@ python lac_web_service.py jieba_server_model/ lac_workdir 9292
``` ```
curl -H "Content-Type:application/json" -X POST -d '{"words": "我爱北京天安门", "fetch":["word_seg"]}' http://127.0.0.1:9292/lac/prediction curl -H "Content-Type:application/json" -X POST -d '{"words": "我爱北京天安门", "fetch":["word_seg"]}' http://127.0.0.1:9292/lac/prediction
``` ```
...@@ -30,6 +30,3 @@ python lac_web_service.py jieba_server_model/ lac_workdir 9292 ...@@ -30,6 +30,3 @@ python lac_web_service.py jieba_server_model/ lac_workdir 9292
``` ```
curl -H "Content-Type:application/json" -X POST -d '{"words": "我爱北京天安门", "fetch":["word_seg"]}' http://127.0.0.1:9292/lac/prediction curl -H "Content-Type:application/json" -X POST -d '{"words": "我爱北京天安门", "fetch":["word_seg"]}' http://127.0.0.1:9292/lac/prediction
``` ```
...@@ -101,10 +101,8 @@ class LACReader(object): ...@@ -101,10 +101,8 @@ class LACReader(object):
return word_ids return word_ids
def parse_result(self, words, crf_decode): def parse_result(self, words, crf_decode):
tags = [ tags = [self.id2label_dict[str(x)] for x in crf_decode]
self.id2label_dict[str(x)] for x in crf_decode
]
sent_out = [] sent_out = []
tags_out = [] tags_out = []
partial_word = "" partial_word = ""
...@@ -119,10 +117,8 @@ class LACReader(object): ...@@ -119,10 +117,8 @@ class LACReader(object):
partial_word = words[ind] partial_word = words[ind]
continue continue
partial_word += words[ind] partial_word += words[ind]
if len(sent_out) < len(tags_out): if len(sent_out) < len(tags_out):
sent_out.append(partial_word) sent_out.append(partial_word)
return sent_out return sent_out
...@@ -29,8 +29,7 @@ class LACService(WebService): ...@@ -29,8 +29,7 @@ class LACService(WebService):
return {"words": feed_data}, fetch return {"words": feed_data}, fetch
def postprocess(self, feed={}, fetch=[], fetch_map={}): def postprocess(self, feed={}, fetch=[], fetch_map={}):
segs = self.reader.parse_result( segs = self.reader.parse_result(feed["words"], fetch_map["crf_decode"])
feed["words"], fetch_map["crf_decode"])
return {"word_seg": "|".join(segs)} return {"word_seg": "|".join(segs)}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册