How kmike/pymorphy2 works
pymorphy2 is a Russian and Ukrainian morphological analyzer and inflection engine. A caller creates an analyzer, which loads a language dictionary and applies configured analysis units to words; results support grammatical-tag handling, normalization, lexeme retrieval, and inflection. A separate dictionary-preparation branch parses and preprocesses OpenCorpora data, compiles it into compact structures, and saves it for later loading. The map reflects README capabilities and indexed references; some runtime dispatch details are unsampled, so those links are omitted or marked unverified.
Main entry points: analyzer.py Morphology API · units Analysis units · compile.py Dictionary compiler · config.py Ukrainian config
Components 19
Word analysis
- Morphology API
pymorphy2/analyzer.py - Analysis units
pymorphy2/units - Unit base behavior
pymorphy2/units/base.py - Grammatical tags
pymorphy2/tagset.py - Word shapes
pymorphy2/shapes.py - Result cache
pymorphy2/cache.py
Language behavior
- Russian config
pymorphy2/lang/ru/config.py - Ukrainian config
pymorphy2/lang/uk/config.py - Ukrainian prefixes
pymorphy2/lang/uk/_prefixes.py
Dictionary data
- Dictionary wrapper
pymorphy2/opencorpora_dict/wrapper.py - Dictionary storage
pymorphy2/opencorpora_dict/storage.py - DAWG structures
pymorphy2/dawg.py - OpenCorpora parser
pymorphy2/opencorpora_dict/parse.py - Dictionary cleanup
pymorphy2/opencorpora_dict/preprocess.py - Dictionary compiler
pymorphy2/opencorpora_dict/compile.py - Parse probabilities
pymorphy2/opencorpora_dict/probability.py
User interfaces
- Command-line interface
pymorphy2/cli.py - Tokenization
pymorphy2/tokenizers.py
Other components
- Application caller
Connections 21
- Application caller → Morphology API: calls
- Morphology API → Dictionary wrapper: loads dictionary
pymorphy2/analyzer.py - Dictionary wrapper → Dictionary storage: loads data
pymorphy2/opencorpora_dict/wrapper.py - Dictionary storage → DAWG structures: loads DAWGs
pymorphy2/opencorpora_dict/storage.py - Morphology API → Russian config: selects config
- Morphology API → Ukrainian config: selects config
- Russian config → Analysis units: configures
pymorphy2/lang/ru/config.py - Ukrainian config → Analysis units: configures
pymorphy2/lang/uk/config.py - Ukrainian config → Ukrainian prefixes: uses prefixes
pymorphy2/lang/uk/config.py - Morphology API → Analysis units: dispatches analysis
- Analysis units → Unit base behavior: extends behavior
pymorphy2/units/by_analogy.py - Analysis units → Word shapes: uses shape rules
pymorphy2/units/by_shape.py - Morphology API → Parse probabilities: estimates parses
pymorphy2/analyzer.py - Dictionary compiler → OpenCorpora parser: parses input
pymorphy2/opencorpora_dict/compile.py - Dictionary compiler → Dictionary cleanup: preprocesses data
pymorphy2/opencorpora_dict/compile.py - Dictionary compiler → DAWG structures: builds structures
pymorphy2/opencorpora_dict/compile.py - Dictionary compiler → Dictionary storage: writes dictionary
pymorphy2/opencorpora_dict/compile.py - Command-line interface → Morphology API: uses API
pymorphy2/cli.py - Command-line interface → Tokenization: tokenizes input
pymorphy2/cli.py - Analysis units → Grammatical tags: creates tags
- Morphology API → Result cache: caches results