Old Rules for Declining Russian Names in .NET Tested on 275,000 Forms: 99.90% Correct for Surnames
Declining Russian full names in code is hard: "Shevchenko" does not change, and the Kazakh "Ermek" must not become "Ermka." The MIA-Padezh author for .NET ran the old Petrovich rules against 275,000 reference word forms: surnames were declined correctly in 99.90% of cases, given names in 99.47%. He grouped the errors by word endings and fixed five groups. The takeaway: the accuracy of a declension tool has to be measured on a large corpus, not on a couple dozen examples.
AI-processed from Хабр: Машинное обучение; edited by Hamidun News
Declining Russian full names sounds like a minor task until you try to solve it head-on. "Shevchenko" does not decline. "Kuchma" does not decline in the feminine but does in the masculine. "Beria" declines in the masculine and does not in the feminine. The Kazakh name "Ermek" must not be turned into "Ermka." A mistake in an accounting document or a letter to a client is no longer a linguistic question but an incident. The developer of the MIA-Padezh project published an open-source full-name declension library for .NET and described on Habr how they approached the task: measure first, then write the rules.
The numbers in the headline mean the following. The author took a reference set of roughly 275,000 words with correct case forms and checked how accurately the old Petrovich rules decline against it. Surnames came out correct in 99.90% of cases, given names in 99.47%. That looks nearly perfect, but across 250,000 forms it comes to about 400 errors, and each one could end up in a contract or a mailing.
Why Not Petrovich
All the free full-name declension tools in the .NET world (NPetrovich, NPetrovichLite, NameCaseLib) descend from a single source: the Ruby gem Petrovich and its rules file petrovich-rules, frozen around 2015. The author stresses that this is not a criticism: the project solved its task. But the legacy has problems:
- the rules contain known bugs: feminine surnames ending in "-ia," Kazakh names ending in "-ek," surnames ending in "-nok" with a mobile vowel;
- the last meaningful commit to the .NET port dates from 2024, while issues from a decade ago remain open;
- each port stores the rules in JSON and parses them at runtime;
- nobody measures accuracy: the tests usually cover a couple dozen surnames and a feeling that "it seems to work."
The Exam First, Then the Fixes
The Petrovich project had an underrated artifact: petrovich-eval. It is a corpus of word forms from a morphological dictionary, about 275,000 forms of surnames, given names, and patronymics in a simple tabular format: the base form of the word, the declined form, and the grammatical features. In effect, it is a ready-made exam: feed in the base form and compare the answer with the reference.
The author wrote a tool that runs the entire corpus in seconds. Its key feature is that discrepancies are grouped by word ending. The output is not "error on line 100500" but "the rule for -nok is wrong on these 15 lines, here they are." Once errors are collected into patterns, the fixes become almost mechanical. The author lists five corrections, each confirmed against the corpus:
- feminine given names ending in "-n" no longer decline: Aigyun, not "AigyuNi";
- feminine surnames ending in "-ia" no longer decline: Beria (f), Danelia (f);
- names ending in "-ek" decline in the usual way, without a mobile vowel: Ermek → Ermeka, not Ermka;
- surnames ending in "-ei" now decline: Hemingueya;
- surnames ending in "-nok" received a mobile vowel: Kashenka.
Rules Plus a Small Neural Network
The library is described as deterministic: the same word always gives the same result, and its behavior can be explained by a specific rule. For document workflows this matters: "sometimes gets it wrong" is not acceptable there. At the same time, the author admits that at some point they did attach a tiny neural network in ONNX format to the rules, although for five years they had rejected that idea.
Everything described is open: the sources live on GitHub, the MIA.Padezh package is available on NuGet, and the license is MIT.
What to Take from This in Practice
The lesson is broader than declension. If you adopt a ready-made library of rules or a dictionary, find or build a set of reference examples and measure accuracy on it. Then errors stop being a "feeling" and each fix gets a number: you can see how many forms became correct and whether anything nearby broke. Grouping errors by shared traits turns hundreds of cases into a dozen clear rules.
There is also an honest limitation. A corpus drawn from a morphological dictionary covers known words, and rare and new surnames may be missing from it, and those are usually the most troublesome. So 99.90% on the corpus does not equal 99.90% on the real data in your CRM. But a team with measurement at least has a baseline. For those who work with Russian names in .NET (accounting, document management, mailings), the project is worth trying on your own customer database.
- Nov 2, 2026Eight LLMs Lose 35–46% of Strategy Calibration in Free-Form Generation
- Feb 3, 2026The AI Bubble and $38 Trillion in Debt: Why the Great Depression Could Look Like a Warm-Up
- Nov 21, 2026UNESCO: AI models caved to wrong answers in 80% of cases after a single pushback
- Apr 29, 2026Saiga Llama 3 8B on 10 GB of VRAM: How Habr Reached 93% Accuracy on War and Peace
Key Questions Answered
Why Not Petrovich?
All the free full-name declension tools in the .NET world (NPetrovich, NPetrovichLite, NameCaseLib) descend from a single source: the Ruby gem Petrovich and its rules file petrovich-rules, frozen around 2015. The author stresses that this is not a criticism: the project solved its task.
What are the key details on The Exam First, Then the Fixes?
The Petrovich project had an underrated artifact: petrovich-eval. It is a corpus of word forms from a morphological dictionary, about 275,000 forms of surnames, given names, and patronymics in a simple tabular format: the base form of the word, the declined form, and the grammatical features. In effect, it is a ready-made exam: feed in the base form and compare the answer with the reference. The author wrote a tool that runs the entire corpus in seconds.
What are the key details on Rules Plus a Small Neural Network?
The library is described as deterministic: the same word always gives the same result, and its behavior can be explained by a specific rule. For document workflows this matters: "sometimes gets it wrong" is not acceptable there. At the same time, the author admits that at some point they did attach a tiny neural network in ONNX format to the rules, although for five years they had rejected that idea.
Test Frontier LLMs & Autonomous Agents in One Workspace
Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.
The AI world, distilled — once a week
Seven stories that actually mattered, hand-picked. No noise, no reposts, no press releases.
Done! Check your inbox for a confirmation.