@@ -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+ ):
164174self ._mystem_bin = mystem_bin
165175self ._grammar_info = grammar_info
166176self ._disambiguation = disambiguation
167177self ._entire_input = entire_input
168178self ._weight = weight
179+ self ._generate_all = generate_all
169180self ._procin = None
170181self ._procout = None
171182self ._procout_no = None
@@ -192,6 +203,9 @@ def __init__(self, mystem_bin=None, grammar_info=True, disambiguation=True, enti
192203if self ._weight is True :
193204self ._mystemargs .append ('--weight' )
194205
206+ if self ._generate_all is True :
207+ self ._mystemargs .append ('--generate-all' )
208+
195209def __del__ (self ):
196210self .close ()# terminate process on exit
197211
@@ -323,9 +337,7 @@ def _analyze_impl(self, text):
323337
324338@staticmethod
325339def _get_lemma (o ):
326- lemma = None
327340try :
328- lemma = o ['analysis' ][0 ]['lex' ]
341+ return o ['analysis' ][0 ]['lex' ]
329342except (KeyError ,IndexError ):
330- lemma = o ['text' ]if 'text' in o else None
331- return lemma
343+ return o ['text' ]if 'text' in o else None