From 181169120982c9785f4e8ab43f5bfeb6841dd093 Mon Sep 17 00:00:00 2001 From: wangjiawei04 Date: Thu, 2 Apr 2020 08:06:54 +0000 Subject: [PATCH] fix precommit --- python/examples/lac/README.md | 3 --- python/examples/lac/README_CN.md | 3 --- python/examples/lac/lac_reader.py | 10 +++------- python/examples/lac/lac_web_service.py | 3 +-- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/python/examples/lac/README.md b/python/examples/lac/README.md index 15dbd252..a0553b24 100644 --- a/python/examples/lac/README.md +++ b/python/examples/lac/README.md @@ -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 ``` - - - diff --git a/python/examples/lac/README_CN.md b/python/examples/lac/README_CN.md index 4ebeac4a..98f2d364 100644 --- a/python/examples/lac/README_CN.md +++ b/python/examples/lac/README_CN.md @@ -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 ``` - - - diff --git a/python/examples/lac/lac_reader.py b/python/examples/lac/lac_reader.py index 8094093a..0c44177c 100644 --- a/python/examples/lac/lac_reader.py +++ b/python/examples/lac/lac_reader.py @@ -101,10 +101,8 @@ class LACReader(object): return word_ids def parse_result(self, words, crf_decode): - tags = [ - self.id2label_dict[str(x)] for x in crf_decode - ] - + tags = [self.id2label_dict[str(x)] for x in crf_decode] + sent_out = [] tags_out = [] partial_word = "" @@ -119,10 +117,8 @@ class LACReader(object): partial_word = words[ind] continue partial_word += words[ind] - + if len(sent_out) < len(tags_out): sent_out.append(partial_word) return sent_out - - diff --git a/python/examples/lac/lac_web_service.py b/python/examples/lac/lac_web_service.py index fe062241..186d8bad 100644 --- a/python/examples/lac/lac_web_service.py +++ b/python/examples/lac/lac_web_service.py @@ -29,8 +29,7 @@ class LACService(WebService): return {"words": feed_data}, fetch def postprocess(self, feed={}, fetch=[], fetch_map={}): - segs = self.reader.parse_result( - feed["words"], fetch_map["crf_decode"]) + segs = self.reader.parse_result(feed["words"], fetch_map["crf_decode"]) return {"word_seg": "|".join(segs)} -- GitLab