UNPKG

shevchenko

Version:

JavaScript library for declension of Ukrainian anthroponyms

172 lines (169 loc) 5.46 kB
/** * @file JavaScript library for declension of Ukrainian anthroponyms * @module shevchenko * @version 3.1.4 * @author Oleksandr Tolochko <shevchenko-js@tooleks.com> * @license MIT * @copyright 2017-2025 Oleksandr Tolochko <shevchenko-js@tooleks.com> * @see {@link git+https://github.com/tooleks/shevchenko-js.git} */ import { anthroponymInflector } from './anthroponym-declension/bootstrap.js'; import { afterInflect } from './extension.js'; export { registerExtension } from './extension.js'; import { detectGender as detectGender$1 } from './gender-detection/detect-gender.js'; import { validateGenderDetectionInput, validateDeclensionInput } from './input-validation.js'; export { InputValidationError } from './input-validation.js'; import './language/alphabet.js'; export { WordClass } from './language/word-class.js'; import { GrammaticalCase } from './language/grammatical-case.js'; export { GrammaticalGender } from './language/grammatical-gender.js'; import './word-declension/declension-types.js'; /** * Inflects an anthroponym in the given grammatical case. * * @throws {InputValidationError} Input validation error. */ async function inGrammaticalCase(grammaticalCase, input) { validateDeclensionInput(input); const output = await anthroponymInflector.inflect(input, input.gender, grammaticalCase); const afterOutput = await afterInflect(grammaticalCase, input); return Object.assign(Object.assign({}, output), afterOutput); } /** * Inflects an anthroponym in nominative grammatical case. * * @example * ```ts * const anthroponym = await shevchenko.inNominative({ * gender: shevchenko.GrammaticalGender.MASCULINE, * givenName: 'Тарас', * patronymicName: 'Григорович', * familyName: 'Шевченко', * }); * ``` * @throws {InputValidationError} Input validation error. */ async function inNominative(input) { return inGrammaticalCase(GrammaticalCase.NOMINATIVE, input); } /** * Inflects an anthroponym in genitive grammatical case. * * @example * ```ts * const anthroponym = await shevchenko.inGenitive({ * gender: shevchenko.GrammaticalGender.MASCULINE, * givenName: 'Тарас', * patronymicName: 'Григорович', * familyName: 'Шевченко', * }); * ``` * @throws {InputValidationError} Input validation error. */ async function inGenitive(input) { return inGrammaticalCase(GrammaticalCase.GENITIVE, input); } /** * Inflects an anthroponym in dative grammatical case. * * @example * ```ts * const anthroponym = await shevchenko.inDative({ * gender: shevchenko.GrammaticalGender.MASCULINE, * givenName: 'Тарас', * patronymicName: 'Григорович', * familyName: 'Шевченко', * }); * ``` * @throws {InputValidationError} Input validation error. */ async function inDative(input) { return inGrammaticalCase(GrammaticalCase.DATIVE, input); } /** * Inflects an anthroponym in accusative grammatical case. * * @example * ```ts * const anthroponym = await shevchenko.inAccusative({ * gender: shevchenko.GrammaticalGender.MASCULINE, * givenName: 'Тарас', * patronymicName: 'Григорович', * familyName: 'Шевченко', * }); * ``` * @throws {InputValidationError} Input validation error. */ async function inAccusative(input) { return inGrammaticalCase(GrammaticalCase.ACCUSATIVE, input); } /** * Inflects an anthroponym in ablative grammatical case. * * @example * ```ts * const anthroponym = await shevchenko.inAblative({ * gender: shevchenko.GrammaticalGender.MASCULINE, * givenName: 'Тарас', * patronymicName: 'Григорович', * familyName: 'Шевченко', * }); * ``` * @throws {InputValidationError} Input validation error. */ async function inAblative(input) { return inGrammaticalCase(GrammaticalCase.ABLATIVE, input); } /** * Inflects an anthroponym in locative grammatical case. * * @example * ```ts * const anthroponym = await shevchenko.inLocative({ * gender: shevchenko.GrammaticalGender.MASCULINE, * givenName: 'Тарас', * patronymicName: 'Григорович', * familyName: 'Шевченко', * }); * ``` * @throws {InputValidationError} Input validation error. */ async function inLocative(input) { return inGrammaticalCase(GrammaticalCase.LOCATIVE, input); } /** * Inflects an anthroponym in vocative grammatical case. * * @example * ```ts * const anthroponym = await shevchenko.inVocative({ * gender: shevchenko.GrammaticalGender.MASCULINE, * givenName: 'Тарас', * patronymicName: 'Григорович', * familyName: 'Шевченко', * }); * ``` * @throws {InputValidationError} Input validation error. */ async function inVocative(input) { return inGrammaticalCase(GrammaticalCase.VOCATIVE, input); } /** * Returns the grammatical gender of an anthroponym. * Returns null if the grammatical gender cannot be detected. * * @example * ```ts * const gender = await shevchenko.detectGender({ * givenName: 'Тарас', * patronymicName: 'Григорович', * familyName: 'Шевченко', * }); * ``` * @throws {InputValidationError} Input validation error. */ async function detectGender(input) { validateGenderDetectionInput(input); return detectGender$1(input); } export { GrammaticalCase, detectGender, inAblative, inAccusative, inDative, inGenitive, inLocative, inNominative, inVocative };