Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
Add space_mode argument to ner (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Nov 26, 2018
1 parent 7278e3b commit 9aaf430
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bosonnlp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def depparser(self, contents):
r = self._api_request('POST', api_endpoint, data=contents)
return r.json()

def ner(self, contents, sensitivity=None, segmented=False):
def ner(self, contents, sensitivity=None, segmented=False, space_mode='3'):
"""BosonNLP `命名实体识别接口 <http://docs.bosonnlp.com/ner.html>`_ 封装。
:param contents: 需要做命名实体识别的文本或者文本序列。
Expand All @@ -292,6 +292,9 @@ def ner(self, contents, sensitivity=None, segmented=False):
:param segmented: 输入是否为分词结果
:type segmented: boolean 默认为 False
:param space_mode: 分词空格保留选项
:type space_mode: int(整型), 0-3有效,默认为 3
:returns: 接口返回的结果列表。
:raises: :py:exc:`~bosonnlp.HTTPError` 如果 API 请求发生错误。
Expand Down Expand Up @@ -319,7 +322,7 @@ def ner(self, contents, sensitivity=None, segmented=False):
'word': ['微软', 'XP', '操作系统', '今日', '正式', '退休']}]
"""
api_endpoint = '/ner/analysis'
params = {}
params = {'space_mode': space_mode}
if sensitivity is not None:
params['sensitivity'] = sensitivity
if segmented:
Expand Down

0 comments on commit 9aaf430

Please sign in to comment.