shevchenko
v3.5.0
Published
JavaScript library for declension of Ukrainian anthroponyms
Downloads
10,269
Maintainers
Readme
shevchenko.js
JavaScript library for declension of Ukrainian anthroponyms.
Links
Extensions
- Military extension - declension of Ukrainian military ranks and appointments
User Guide
Installation
Install the library with npm:
npm install shevchenkoImport
The library is available as a CommonJS module, an ECMAScript module, and a minified UMD bundle.
CommonJS
const shevchenko = require('shevchenko');ECMAScript module
import * as shevchenko from 'shevchenko';UMD
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>Use Cases
Declining names
This example declines a full name in the vocative case.
const shevchenko = require('shevchenko');
async function main() {
const input = {
gender: 'masculine',
givenName: 'Тарас',
patronymicName: 'Григорович',
familyName: 'Шевченко'
};
const output = await shevchenko.inVocative(input);
console.log(output); // { givenName: "Тарасе", patronymicName: "Григоровичу", familyName: "Шевченку" }
}
main().catch((error) => console.error(error));Detecting grammatical gender
This example detects the grammatical gender of a name before declining it.
const shevchenko = require('shevchenko');
async function main() {
const anthroponym = {
givenName: 'Лариса',
patronymicName: 'Петрівна',
familyName: 'Косач-Квітка'
};
const gender = await shevchenko.detectGender(anthroponym); // "feminine"
if (gender == null) {
throw new Error('Failed to detect grammatical gender.');
}
const input = { ...anthroponym, gender };
const output = await shevchenko.inVocative(input);
console.log(output); // { givenName: "Ларисо", patronymicName: "Петрівно", familyName: "Косач-Квітко" }
}
main().catch((error) => console.error(error));Using the HTTP API
The library is also available as an HTTP API. See the shevchenko Docker image for setup instructions.
