Declension of Ukrainian family names, given names and patronymics

Open-source JavaScript library for the declension of Ukrainian personal names

npm install shevchenko
v3.5.0 License (opens in a new tab)

Live demo

Enter the family name, given name and patronymic in the nominative case.

Grammatical gender
Gender is detected from the given name or patronymic.

Declension results

Nominative
Шевченко Тарас Григорович
Genitive
Шевченка Тараса Григоровича
Dative
Шевченку Тарасу Григоровичу
Accusative
Шевченка Тараса Григоровича
Ablative
Шевченком Тарасом Григоровичем
Locative
Шевченкові Тарасові Григоровичу
Vocative
Шевченку Тарасе Григоровичу

How it works

More than 120 Ukrainian grammar rules combined with machine learning.

  • Gender detection

    If the grammatical gender is not specified, the library can detect it automatically from the patronymic or given name.

  • Machine learning

    Family names derived from nouns and from adjectives decline differently, even when they have the same ending. A machine learning model trained on more than 40,000 family names helps tell them apart and pick the matching rule.

  • Sound alternation

    During declension, sounds in the stem may alternate or drop out. The library applies these changes according to Ukrainian grammar.

  • Vocative case

    The vocative form depends on the word stem, so names with the same ending may still have different vocative forms. The library handles these differences.

  • Compound names

    Each part of a hyphenated given name or family name is declined on its own, and parts that should stay unchanged are left as is.

  • Indeclinable family names

    Depending on gender and ending, some family names are indeclinable and keep the same form in every case. The library recognizes them and leaves them unchanged.

Documentation

Get started in three steps.

  1. Installation

    Install the package from npm. TypeScript types are included.

    npm install shevchenko
  2. Import

    Load the library with require().

    const shevchenko = require('shevchenko');

    Load the library with an import statement.

    import * as shevchenko from 'shevchenko';

    No installation needed: load the script from a CDN and use the global shevchenko variable.

    <script type="text/javascript" src="https://unpkg.com/shevchenko"></script>
  3. Usage example

    Declines a full name in the vocative case.

    const shevchenko = require('shevchenko');
    
    async function main() {
      const name = {
        givenName: 'Тарас',
        patronymicName: 'Григорович',
        familyName: 'Шевченко'
      };
    
      const vocative = await shevchenko.inVocative({ ...name, gender: 'masculine' });
    
      console.log(vocative); // { givenName: "Тарасе", patronymicName: "Григоровичу", familyName: "Шевченку" }
    }
    
    main().catch((error) => console.error(error));

    Detects the grammatical gender before declining a name.

    const shevchenko = require('shevchenko');
    
    async function main() {
      const name = {
        givenName: 'Лариса',
        patronymicName: 'Петрівна',
        familyName: 'Косач-Квітка'
      };
    
      const gender = await shevchenko.detectGender(name); // "feminine"
      if (gender == null) {
        throw new Error('Failed to detect grammatical gender.');
      }
    
      const vocative = await shevchenko.inVocative({ ...name, gender });
    
      console.log(vocative); // { givenName: "Ларисо", patronymicName: "Петрівно", familyName: "Косач-Квітко" }
    }
    
    main().catch((error) => console.error(error));