Skip to content

Commit

Permalink
fix MorphAnalyzer.iter_known_word_parses and add a test for it
Browse files Browse the repository at this point in the history
  • Loading branch information
kmike committed Apr 22, 2014
1 parent 8141ada commit eaebe4c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pymorphy2/analyzer.py
Expand Up @@ -316,7 +316,7 @@ def iter_known_word_parses(self, prefix=""):
# XXX: this method currently assumes that
# units.DictionaryAnalyzer is the first analyzer unit.
for word, tag, normal_form, para_id, idx in self.dictionary.iter_known_words(prefix):
methods = ((self._units[0], word, para_id, idx),)
methods = ((self._units[0][0], word, para_id, idx),)
parse = (word, tag, normal_form, 1.0, methods)
if self._result_type is None:
yield parse
Expand Down
8 changes: 8 additions & 0 deletions tests/test_analyzer.py
Expand Up @@ -3,6 +3,7 @@
import pickle
import pytest
import pymorphy2
from pymorphy2.units.by_lookup import DictionaryAnalyzer
from pymorphy2.units.by_analogy import UnknownPrefixAnalyzer, KnownPrefixAnalyzer
from pymorphy2.units.by_hyphen import HyphenatedWordsAnalyzer

Expand Down Expand Up @@ -324,3 +325,10 @@ def test_normalize_patr_femn(self):
assert parse.normalized.tag.case == 'nomn'
assert parse.normalized.tag.gender == 'masc'


def test_iter_known_word_parses():
parses = list(morph.iter_known_word_parses('приве'))
assert any(
(p.word=='привет' and isinstance(p.methods_stack[0][0], DictionaryAnalyzer))
for p in parses
), parses

0 comments on commit eaebe4c

Please sign in to comment.