Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit683d529

Browse files
Merge pull request#25 from crazyministr/master
added generate-all param
2 parents1d9e50f +156a8c2 commit683d529

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

‎pymystem3/mystem.py‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,27 @@ class Mystem(object):
156156
:type entire_input: bool
157157
:param weight: print context-independent lemma weight
158158
:type weight: bool
159+
:param generate_all: generate all possible hypotheses
160+
:type generate_all: bool
159161
160162
.. note:: Default value of :py:attr:`mystem_bin` can be overwritted by :envvar:`MYSTEM_BIN`.
161163
"""
162164

163-
def__init__(self,mystem_bin=None,grammar_info=True,disambiguation=True,entire_input=True,weight=True):
165+
def__init__(
166+
self,
167+
mystem_bin=None,
168+
grammar_info=True,
169+
disambiguation=True,
170+
entire_input=True,
171+
weight=True,
172+
generate_all=False
173+
):
164174
self._mystem_bin=mystem_bin
165175
self._grammar_info=grammar_info
166176
self._disambiguation=disambiguation
167177
self._entire_input=entire_input
168178
self._weight=weight
179+
self._generate_all=generate_all
169180
self._procin=None
170181
self._procout=None
171182
self._procout_no=None
@@ -192,6 +203,9 @@ def __init__(self, mystem_bin=None, grammar_info=True, disambiguation=True, enti
192203
ifself._weightisTrue:
193204
self._mystemargs.append('--weight')
194205

206+
ifself._generate_allisTrue:
207+
self._mystemargs.append('--generate-all')
208+
195209
def__del__(self):
196210
self.close()# terminate process on exit
197211

@@ -323,9 +337,7 @@ def _analyze_impl(self, text):
323337

324338
@staticmethod
325339
def_get_lemma(o):
326-
lemma=None
327340
try:
328-
lemma=o['analysis'][0]['lex']
341+
returno['analysis'][0]['lex']
329342
except (KeyError,IndexError):
330-
lemma=o['text']if'text'inoelseNone
331-
returnlemma
343+
returno['text']if'text'inoelseNone

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp