JavaScript library for the declension of Ukrainian personal names.
- Military extension — declension of Ukrainian military ranks and appointments
Install the library with npm:
npm install shevchenkoThe library is available as a CommonJS module, an ECMAScript module and a minified UMD bundle.
const shevchenko = require('shevchenko');import * as shevchenko from 'shevchenko';Load the bundle with a <script> tag. It exposes the library as the global shevchenko variable.
<script type="text/javascript" src="https://unpkg.com/shevchenko"></script>This 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));This example detects the grammatical gender of a name before declining it.
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));The library is also available as an HTTP API. See the tooleks/shevchenko Docker image for setup instructions.