Commit 7c66ebdb5891e0f15e3cf7de2a001937e119ae28
1 parent
d7a3318a
drobne poprawki we wrapperze pythonowym
git-svn-id: svn://svn.nlp.ipipan.waw.pl/morfeusz/trunk@354 ff4e3ee1-f430-4e82-ade0-24591c43f1fd
Showing
1 changed file
with
8 additions
and
7 deletions
morfeusz/wrappers/morfeusz_python.i
... | ... | @@ -80,7 +80,7 @@ def analyse_iter(self, text): |
80 | 80 | """ |
81 | 81 | Analyse given text and return an iterator over MorphInterpretation objects as a result. |
82 | 82 | """ |
83 | - return $action(self, text) | |
83 | + return $action(self, text.encode('utf-8')) | |
84 | 84 | %} |
85 | 85 | |
86 | 86 | %feature("shadow") morfeusz::Morfeusz::analyse %{ |
... | ... | @@ -171,6 +171,7 @@ def generate(self, lemma, tagId=None): |
171 | 171 | """ |
172 | 172 | Perform morphological synthesis on given text and return a list of MorphInterpretation objects. |
173 | 173 | """ |
174 | + lemma = lemma.encode('utf-8') | |
174 | 175 | if tagId is not None: |
175 | 176 | return self._generateByTagId(lemma, tagId) |
176 | 177 | else: |
... | ... | @@ -403,13 +404,15 @@ class Morfeusz(_object): |
403 | 404 | yield [head] + tail |
404 | 405 | return list(expand_dag(0)) |
405 | 406 | |
407 | + def _interp2tuple(self, i): | |
408 | + m = self._morfeusz_obj | |
409 | + return i.orth, i.lemma, i.getTag(m), i.getName(m), i.getLabels(m) | |
410 | + | |
406 | 411 | def analyse(self, text): |
407 | 412 | m = self._morfeusz_obj |
408 | 413 | interps = m.analyse(text) |
409 | 414 | interp_tuples = [ |
410 | - (i.startNode, i.endNode, | |
411 | - (i.lemma, i.orth, i.getTag(m), i.getName(m), i.getLabels(m))) | |
412 | - for i in interps] | |
415 | + (i.startNode, i.endNode, self._interp2tuple(i)) for i in interps] | |
413 | 416 | |
414 | 417 | def expand_interps(): |
415 | 418 | for start, end, interp in interp_tuples: |
... | ... | @@ -425,9 +428,7 @@ class Morfeusz(_object): |
425 | 428 | def generate(self, lemma, tag_id=None): |
426 | 429 | m = self._morfeusz_obj |
427 | 430 | interps = m.generate(lemma, tag_id) |
428 | - interp_tuples = [ | |
429 | - (i.orth, i.lemma, i.getTag(m), i.getName(m), i.getLabels(m)) | |
430 | - for i in interps] | |
431 | + interp_tuples = [self._interp2tuple(i) for i in interps] | |
431 | 432 | |
432 | 433 | def expand_interps(): |
433 | 434 | for interp in interp_tuples: |
... | ... |