PyMorphy2

0.9.1 · abandoned · verified Thu Apr 16

PyMorphy2 (version 0.9.1) is a morphological analyzer and inflection engine for the Russian and Ukrainian languages. It provides functionalities for POS tagging, word inflection, and normalization using OpenCorpora.org dictionaries and heuristic algorithms for unknown words. The project's release cadence is infrequent, with the last significant update in September 2020.

Common errors

Warnings

Install

Imports

Quickstart

Initializes the MorphAnalyzer and demonstrates basic usage: parsing a word to find its normal form and part of speech, and inflecting it to a different grammatical form. The `pymorphy2-dicts` package must be installed for dictionaries to be found.

import pymorphy2

morph = pymorphy2.MorphAnalyzer()
word = 'стекло'

# Analyze a word
parsed_word = morph.parse(word)[0]
print(f"Original word: {word}")
print(f"Normal form: {parsed_word.normal_form}")
print(f"Part of speech: {parsed_word.tag.POS}")
print(f"All tags: {parsed_word.tag}")

# Inflect a word
inflected = parsed_word.inflect({'gent'})
if inflected: # Check if inflection was successful
    print(f"Inflected to genitive: {inflected.word}")
else:
    print(f"Could not inflect '{word}' to genitive.")

view raw JSON →