no-plagiarism / pymorphy3

Morphological analyzer / inflection engine for Russian and Ukrainian languages.
https://pymorphy2.readthedocs.io/
MIT License
66 stars 7 forks source link

Error in converting patronymic to nominative case #12

Open DimIsaev opened 1 year ago

DimIsaev commented 1 year ago

Describe the bug error in converting patronymic to nominative case

Intalled package

pymorphy2             0.9.1
pymorphy2-dicts-ru    2.4.417127.4579844
pymorphy3             1.1.1
pymorphy3-dicts-ru    2.4.417150.4580142

To Reproduce

import pymorphy3
morph = pymorphy3.MorphAnalyzer()

def get_gent(text):
    result = []

    for word in text.split():
        try:
            p = next(filter(lambda x: {'accs', 'sing'} in x.tag, morph.parse(word)))
            #result.append(p.inflect({'nomn'}).word)
            result.append(p.normal_form)
        except Exception as e:
            result.append(word)

    return ' '.join(result).title()

fio = 'Шелестова Дмитрия Юрьевича'
get_gent(fio)

Шелестов Дмитрий Юриевич

Expected behavior Шелестов Дмитрий Юрьевич

insolor commented 1 year ago

It seems that for normal form of "юрьевич" was used form with V-ie tag, see: http://opencorpora.org/dict.php?act=edit&id=387111

Probably this can be fixed in dictionary generator. As a workaround, you can just use p.inflect({'nomn'}).word instead of p.normal_form.