# no-plagiarism/pymorphy3 architecture

> Architecture diagram of the GitHub repository no-plagiarism/pymorphy3, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/no-plagiarism/pymorphy3
- Repository: https://github.com/no-plagiarism/pymorphy3

## Overview

pymorphy3 is a Russian and Ukrainian morphological analyzer and inflection engine. The main workflow accepts a word through the Python API or CLI, uses dictionary-backed and heuristic analyzer units to produce parses, and represents grammatical tags and results for downstream use. A separate dictionary-build workflow parses and preprocesses OpenCorpora data, compiles it into pymorphy3 structures, and saves it for loading at runtime. The graph reflects README capabilities and indexed references; unsampled implementations and call details are not inferred where the evidence does not establish them.

Main entry points: [`pymorphy3/units`](https://github.com/no-plagiarism/pymorphy3/tree/master/pymorphy3/units) (Analyzer Units), [`pymorphy3/analyzer.py`](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/analyzer.py) (Morph Analyzer), [`pymorphy3/opencorpora_dict/compile.py`](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/opencorpora_dict/compile.py) (Dictionary Compiler), [`pymorphy3/opencorpora_dict/storage.py`](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/opencorpora_dict/storage.py) (Dictionary Storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_api["Python API<br/>[__init__.py]"]
  node_cli["Command Line<br/>[cli.py]"]
end

subgraph group_analysis["Morphological Analysis"]
  node_analyzer["Morph Analyzer<br/>[analyzer.py]"]
  node_units["Analyzer Units"]
  node_lookup["Dictionary Lookup<br/>[by_lookup.py]"]
  node_analogy["Analogy Analysis<br/>[by_analogy.py]"]
  node_hyphen["Hyphen Analysis<br/>[by_hyphen.py]"]
  node_shape["Word Shapes<br/>[by_shape.py]"]
  node_tagset["Grammatical Tags<br/>[tagset.py]"]
  node_shapes["Shape Rules<br/>[shapes.py]"]
  node_ruconfig["Russian Config<br/>[config.py]"]
  node_ukconfig["Ukrainian Config<br/>[config.py]"]
  node_ukprefix["Ukrainian Prefixes<br/>[_prefixes.py]"]
end

subgraph group_dictionary["Dictionary Data"]
  node_wrapper["Dictionary Wrapper<br/>[wrapper.py]"]
  node_storage[("Dictionary Storage<br/>[storage.py]")]
  node_dawg["DAWG Indexes<br/>[dawg.py]"]
end

subgraph group_build["Dictionary Build"]
  node_parsexml["XML Parsing<br/>[parse.py]"]
  node_preprocess["Dictionary Preprocess<br/>[preprocess.py]"]
  node_compile["Dictionary Compiler<br/>[compile.py]"]
  node_probability["Probability Data<br/>[probability.py]"]
end

node_user(("User"))

node_user -->|"uses"| node_api
node_user -->|"invokes"| node_cli
node_api -->|"exports"| node_analyzer
node_cli -->|"uses"| node_analyzer
node_analyzer -->|"loads"| node_wrapper
node_wrapper -->|"loads data"| node_storage
node_storage -->|"loads indexes"| node_dawg
node_analyzer -->|"dispatches"| node_units
node_units -->|"registers"| node_lookup
node_units -->|"registers"| node_analogy
node_units -->|"registers"| node_hyphen
node_units -->|"registers"| node_shape
node_analogy -->|"delegates to"| node_lookup
node_shape -->|"uses rules"| node_shapes
node_analyzer -->|"uses tags"| node_tagset
node_ruconfig -->|"configures"| node_units
node_ukconfig -->|"configures"| node_units
node_ukconfig -->|"uses prefixes"| node_ukprefix
node_parsexml -.->|"feeds"| node_preprocess
node_compile -->|"consumes parsed data"| node_parsexml
node_compile -->|"uses"| node_preprocess
node_compile -->|"saves compiled data"| node_storage
node_probability -->|"uses"| node_preprocess
node_probability -->|"uses"| node_storage
node_compile -->|"builds indexes"| node_dawg

click node_api "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/__init__.py"
click node_cli "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/cli.py"
click node_analyzer "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/analyzer.py"
click node_units "https://github.com/no-plagiarism/pymorphy3/tree/master/pymorphy3/units"
click node_lookup "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/units/by_lookup.py"
click node_analogy "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/units/by_analogy.py"
click node_hyphen "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/units/by_hyphen.py"
click node_shape "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/units/by_shape.py"
click node_tagset "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/tagset.py"
click node_shapes "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/shapes.py"
click node_ruconfig "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/lang/ru/config.py"
click node_ukconfig "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/lang/uk/config.py"
click node_ukprefix "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/lang/uk/_prefixes.py"
click node_wrapper "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/opencorpora_dict/wrapper.py"
click node_storage "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/opencorpora_dict/storage.py"
click node_dawg "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/dawg.py"
click node_parsexml "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/opencorpora_dict/parse.py"
click node_preprocess "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/opencorpora_dict/preprocess.py"
click node_compile "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/opencorpora_dict/compile.py"
click node_probability "https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/opencorpora_dict/probability.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api,node_cli,node_user toneBlue
class node_analyzer,node_units,node_lookup,node_analogy,node_hyphen,node_shape,node_tagset,node_shapes,node_ruconfig,node_ukconfig,node_ukprefix toneAmber
class node_wrapper,node_storage,node_dawg toneMint
class node_parsexml,node_preprocess,node_compile,node_probability toneRose
```

## Components

### User Interface

- [Python API](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/__init__.py): `pymorphy3/__init__.py`
- [Command Line](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/cli.py): `pymorphy3/cli.py`

### Morphological Analysis

- [Morph Analyzer](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/analyzer.py): `pymorphy3/analyzer.py`
- [Analyzer Units](https://github.com/no-plagiarism/pymorphy3/tree/master/pymorphy3/units): `pymorphy3/units`
- [Dictionary Lookup](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/units/by_lookup.py): `pymorphy3/units/by_lookup.py`
- [Analogy Analysis](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/units/by_analogy.py): `pymorphy3/units/by_analogy.py`
- [Hyphen Analysis](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/units/by_hyphen.py): `pymorphy3/units/by_hyphen.py`
- [Word Shapes](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/units/by_shape.py): `pymorphy3/units/by_shape.py`
- [Grammatical Tags](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/tagset.py): `pymorphy3/tagset.py`
- [Shape Rules](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/shapes.py): `pymorphy3/shapes.py`
- [Russian Config](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/lang/ru/config.py): `pymorphy3/lang/ru/config.py`
- [Ukrainian Config](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/lang/uk/config.py): `pymorphy3/lang/uk/config.py`
- [Ukrainian Prefixes](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/lang/uk/_prefixes.py): `pymorphy3/lang/uk/_prefixes.py`

### Dictionary Data

- [Dictionary Wrapper](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/opencorpora_dict/wrapper.py): `pymorphy3/opencorpora_dict/wrapper.py`
- [Dictionary Storage](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/opencorpora_dict/storage.py): `pymorphy3/opencorpora_dict/storage.py`
- [DAWG Indexes](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/dawg.py): `pymorphy3/dawg.py`

### Dictionary Build

- [XML Parsing](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/opencorpora_dict/parse.py): `pymorphy3/opencorpora_dict/parse.py`
- [Dictionary Preprocess](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/opencorpora_dict/preprocess.py): `pymorphy3/opencorpora_dict/preprocess.py`
- [Dictionary Compiler](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/opencorpora_dict/compile.py): `pymorphy3/opencorpora_dict/compile.py`
- [Probability Data](https://github.com/no-plagiarism/pymorphy3/blob/master/pymorphy3/opencorpora_dict/probability.py): `pymorphy3/opencorpora_dict/probability.py`

### Other components

- **User**

## Connections

- User → Python API: uses (evidence: `pymorphy3/__init__.py`)
- User → Command Line: invokes (evidence: `pymorphy3/cli.py`)
- Python API → Morph Analyzer: exports (evidence: `pymorphy3/__init__.py`)
- Command Line → Morph Analyzer: uses (evidence: `pymorphy3/cli.py`)
- Morph Analyzer → Dictionary Wrapper: loads (evidence: `pymorphy3/analyzer.py`)
- Dictionary Wrapper → Dictionary Storage: loads data (evidence: `pymorphy3/opencorpora_dict/wrapper.py`)
- Dictionary Storage → DAWG Indexes: loads indexes (evidence: `pymorphy3/opencorpora_dict/storage.py`)
- Morph Analyzer → Analyzer Units: dispatches (evidence: `pymorphy3/analyzer.py`)
- Analyzer Units → Dictionary Lookup: registers (evidence: `pymorphy3/units/__init__.py`)
- Analyzer Units → Analogy Analysis: registers (evidence: `pymorphy3/units/__init__.py`)
- Analyzer Units → Hyphen Analysis: registers (evidence: `pymorphy3/units/__init__.py`)
- Analyzer Units → Word Shapes: registers (evidence: `pymorphy3/units/__init__.py`)
- Analogy Analysis → Dictionary Lookup: delegates to (evidence: `pymorphy3/units/by_analogy.py`)
- Word Shapes → Shape Rules: uses rules (evidence: `pymorphy3/units/by_shape.py`)
- Morph Analyzer → Grammatical Tags: uses tags (evidence: `pymorphy3/analyzer.py`)
- Russian Config → Analyzer Units: configures (evidence: `pymorphy3/lang/ru/config.py`)
- Ukrainian Config → Analyzer Units: configures (evidence: `pymorphy3/lang/uk/config.py`)
- Ukrainian Config → Ukrainian Prefixes: uses prefixes (evidence: `pymorphy3/lang/uk/config.py`)
- XML Parsing → Dictionary Preprocess: feeds
- Dictionary Compiler → XML Parsing: consumes parsed data (evidence: `pymorphy3/opencorpora_dict/compile.py`)
- Dictionary Compiler → Dictionary Preprocess: uses (evidence: `pymorphy3/opencorpora_dict/compile.py`)
- Dictionary Compiler → Dictionary Storage: saves compiled data (evidence: `pymorphy3/opencorpora_dict/compile.py`)
- Probability Data → Dictionary Preprocess: uses (evidence: `pymorphy3/opencorpora_dict/probability.py`)
- Probability Data → Dictionary Storage: uses (evidence: `pymorphy3/opencorpora_dict/probability.py`)
- Dictionary Compiler → DAWG Indexes: builds indexes (evidence: `pymorphy3/opencorpora_dict/compile.py`)
