shevchenko 3.1.0-alpha.5 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/cjs/anthroponym-declension/anthroponym-inflector.js +1 -1
- package/dist/cjs/anthroponym-declension/bootstrap.js +1 -1
- package/dist/cjs/anthroponym-declension/family-name-classifier/artifacts/model.bundle.json.js +1 -1
- package/dist/cjs/anthroponym-declension/family-name-classifier/cache/incorrect-predictions.json.js +1 -1
- package/dist/cjs/anthroponym-declension/family-name-classifier/family-name-class-transformer.js +1 -1
- package/dist/cjs/anthroponym-declension/family-name-classifier/family-name-classifer.js +1 -1
- package/dist/cjs/anthroponym-declension/family-name-classifier/model-bundle-loader.js +1 -1
- package/dist/cjs/anthroponym-declension/family-name-classifier/model-config.js +1 -1
- package/dist/cjs/anthroponym-declension/family-name-classifier/word-transformer.js +1 -1
- package/dist/cjs/anthroponym-declension/family-name-inflector.js +1 -1
- package/dist/cjs/anthroponym-declension/given-name-inflector.js +1 -1
- package/dist/cjs/anthroponym-declension/name-inflector.js +1 -1
- package/dist/cjs/anthroponym-declension/patronymic-name-inflector.js +1 -1
- package/dist/cjs/extension.js +9 -1
- package/dist/cjs/gender-detection/detect-gender.js +1 -1
- package/dist/cjs/gender-detection/given-names-genders.json.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/input-validation.js +27 -41
- package/dist/cjs/language/alphabet.js +1 -1
- package/dist/cjs/language/grammatical-case.js +1 -1
- package/dist/cjs/language/grammatical-gender.js +1 -1
- package/dist/cjs/language/letter-case.js +1 -1
- package/dist/cjs/language/linguistics.js +1 -1
- package/dist/cjs/language/word-class.js +1 -1
- package/dist/cjs/shevchenko.js +1 -1
- package/dist/cjs/word-declension/append-command-runner.js +1 -1
- package/dist/cjs/word-declension/bootstrap.js +1 -1
- package/dist/cjs/word-declension/command-runner-factory.js +1 -1
- package/dist/cjs/word-declension/declension-rule-inflector.js +1 -1
- package/dist/cjs/word-declension/declension-types.js +1 -1
- package/dist/cjs/word-declension/replace-command-runner.js +1 -1
- package/dist/cjs/word-declension/rules/artifacts/declension-rules.json.js +1 -1
- package/dist/cjs/word-declension/word-inflector.js +1 -1
- package/dist/es/anthroponym-declension/anthroponym-inflector.js +1 -1
- package/dist/es/anthroponym-declension/bootstrap.js +1 -1
- package/dist/es/anthroponym-declension/family-name-classifier/artifacts/model.bundle.json.js +1 -1
- package/dist/es/anthroponym-declension/family-name-classifier/cache/incorrect-predictions.json.js +1 -1
- package/dist/es/anthroponym-declension/family-name-classifier/family-name-class-transformer.js +1 -1
- package/dist/es/anthroponym-declension/family-name-classifier/family-name-classifer.js +1 -1
- package/dist/es/anthroponym-declension/family-name-classifier/model-bundle-loader.js +1 -1
- package/dist/es/anthroponym-declension/family-name-classifier/model-config.js +1 -1
- package/dist/es/anthroponym-declension/family-name-classifier/word-transformer.js +1 -1
- package/dist/es/anthroponym-declension/family-name-inflector.js +1 -1
- package/dist/es/anthroponym-declension/given-name-inflector.js +1 -1
- package/dist/es/anthroponym-declension/name-inflector.js +1 -1
- package/dist/es/anthroponym-declension/patronymic-name-inflector.js +1 -1
- package/dist/es/extension.d.ts +2 -2
- package/dist/es/extension.js +9 -2
- package/dist/es/gender-detection/detect-gender.js +1 -1
- package/dist/es/gender-detection/given-names-genders.json.js +1 -1
- package/dist/es/index.js +1 -1
- package/dist/es/input-validation.d.ts +2 -2
- package/dist/es/input-validation.js +27 -41
- package/dist/es/language/alphabet.js +1 -1
- package/dist/es/language/grammatical-case.js +1 -1
- package/dist/es/language/grammatical-gender.js +1 -1
- package/dist/es/language/letter-case.js +1 -1
- package/dist/es/language/linguistics.js +1 -1
- package/dist/es/language/word-class.js +1 -1
- package/dist/es/shevchenko.js +1 -1
- package/dist/es/word-declension/append-command-runner.js +1 -1
- package/dist/es/word-declension/bootstrap.js +1 -1
- package/dist/es/word-declension/command-runner-factory.js +1 -1
- package/dist/es/word-declension/declension-rule-inflector.js +1 -1
- package/dist/es/word-declension/declension-types.js +1 -1
- package/dist/es/word-declension/replace-command-runner.js +1 -1
- package/dist/es/word-declension/rules/artifacts/declension-rules.json.js +1 -1
- package/dist/es/word-declension/word-inflector.js +1 -1
- package/dist/umd/shevchenko.min.js +89 -89
- package/package.json +3 -2
package/dist/es/extension.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
@@ -14,6 +14,13 @@ function registerExtension(extensionFactory) {
|
|
|
14
14
|
const extension = extensionFactory({ wordInflector });
|
|
15
15
|
registeredExtensions.push(extension);
|
|
16
16
|
}
|
|
17
|
+
function getCustomFieldNames() {
|
|
18
|
+
const fieldNames = [];
|
|
19
|
+
for (const extension of registeredExtensions) {
|
|
20
|
+
fieldNames.push(...extension.fieldNames);
|
|
21
|
+
}
|
|
22
|
+
return fieldNames;
|
|
23
|
+
}
|
|
17
24
|
async function afterInflect(grammaticalCase, input) {
|
|
18
25
|
var _a;
|
|
19
26
|
const output = {};
|
|
@@ -26,4 +33,4 @@ async function afterInflect(grammaticalCase, input) {
|
|
|
26
33
|
return output;
|
|
27
34
|
}
|
|
28
35
|
|
|
29
|
-
export { afterInflect, registerExtension };
|
|
36
|
+
export { afterInflect, getCustomFieldNames, registerExtension };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
package/dist/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
@@ -6,10 +6,10 @@ export declare class InputValidationError extends TypeError {
|
|
|
6
6
|
*
|
|
7
7
|
* @throws {InputValidationError}
|
|
8
8
|
*/
|
|
9
|
-
export declare function validateDeclensionInput(
|
|
9
|
+
export declare function validateDeclensionInput(input: unknown): asserts input is DeclensionInput;
|
|
10
10
|
/**
|
|
11
11
|
* Validates if a given value is a valid input for gender detection.
|
|
12
12
|
*
|
|
13
13
|
* @throws {InputValidationError}
|
|
14
14
|
*/
|
|
15
|
-
export declare function validateGenderDetectionInput(
|
|
15
|
+
export declare function validateGenderDetectionInput(input: unknown): asserts input is GenderDetectionInput;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
8
8
|
* @see {@link git+https://github.com/tooleks/shevchenko-js.git}
|
|
9
9
|
*/
|
|
10
|
+
import { getCustomFieldNames } from './extension.js';
|
|
10
11
|
import './language/alphabet.js';
|
|
11
12
|
import './language/word-class.js';
|
|
12
13
|
import './language/grammatical-case.js';
|
|
@@ -14,31 +15,30 @@ import { GrammaticalGender } from './language/grammatical-gender.js';
|
|
|
14
15
|
|
|
15
16
|
class InputValidationError extends TypeError {
|
|
16
17
|
}
|
|
18
|
+
const fieldNames = ['givenName', 'patronymicName', 'familyName'];
|
|
17
19
|
/**
|
|
18
20
|
* Validates if a given value is a valid input for declension.
|
|
19
21
|
*
|
|
20
22
|
* @throws {InputValidationError}
|
|
21
23
|
*/
|
|
22
|
-
function validateDeclensionInput(
|
|
23
|
-
if (!isObject(
|
|
24
|
+
function validateDeclensionInput(input) {
|
|
25
|
+
if (!isObject(input)) {
|
|
24
26
|
throw new InputValidationError('The input type must be an object.');
|
|
25
27
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
const isGenderValid = Object.values(GrammaticalGender).includes(input.gender);
|
|
29
|
+
if (!isGenderValid) {
|
|
30
|
+
throw new InputValidationError(`The "gender" parameter must be one of the following:` +
|
|
31
|
+
` "${Object.values(GrammaticalGender).join('", "')}".`);
|
|
28
32
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
throw new InputValidationError(
|
|
33
|
+
const mergedFieldNames = [...fieldNames, ...getCustomFieldNames()];
|
|
34
|
+
const hasFields = mergedFieldNames.some((fieldName) => fieldName in input && typeof input[fieldName] !== 'undefined');
|
|
35
|
+
if (!hasFields) {
|
|
36
|
+
throw new InputValidationError(`At least one of the following parameters must present: "${mergedFieldNames.join('", "')}".`);
|
|
33
37
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
throw new InputValidationError('The "patronymicName" parameter must be a string.');
|
|
39
|
-
}
|
|
40
|
-
if (isDefined(value.familyName) && !isString(value.familyName)) {
|
|
41
|
-
throw new InputValidationError('The "familyName" parameter must be a string.');
|
|
38
|
+
for (const fieldName of mergedFieldNames) {
|
|
39
|
+
if (typeof input[fieldName] !== 'undefined' && typeof input[fieldName] !== 'string') {
|
|
40
|
+
throw new InputValidationError(`The "${fieldName}" parameter must be a string.`);
|
|
41
|
+
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
@@ -46,36 +46,22 @@ function validateDeclensionInput(value) {
|
|
|
46
46
|
*
|
|
47
47
|
* @throws {InputValidationError}
|
|
48
48
|
*/
|
|
49
|
-
function validateGenderDetectionInput(
|
|
50
|
-
if (!isObject(
|
|
49
|
+
function validateGenderDetectionInput(input) {
|
|
50
|
+
if (!isObject(input)) {
|
|
51
51
|
throw new InputValidationError('The input type must be an object.');
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
throw new InputValidationError('At least one of the following parameters must present: "givenName", "patronymicName", "familyName".');
|
|
57
|
-
}
|
|
58
|
-
if (isDefined(value.givenName) && !isString(value.givenName)) {
|
|
59
|
-
throw new InputValidationError('The "givenName" parameter must be a string.');
|
|
60
|
-
}
|
|
61
|
-
if (isDefined(value.patronymicName) && !isString(value.patronymicName)) {
|
|
62
|
-
throw new InputValidationError('The "patronymicName" parameter must be a string.');
|
|
53
|
+
const hasFields = fieldNames.some((fieldName) => fieldName in input && typeof input[fieldName] !== 'undefined');
|
|
54
|
+
if (!hasFields) {
|
|
55
|
+
throw new InputValidationError(`At least one of the following parameters must present: "${fieldNames.join('", "')}".`);
|
|
63
56
|
}
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
for (const fieldName of fieldNames) {
|
|
58
|
+
if (typeof input[fieldName] !== 'undefined' && typeof input[fieldName] !== 'string') {
|
|
59
|
+
throw new InputValidationError(`The "${fieldName}" parameter must be a string.`);
|
|
60
|
+
}
|
|
66
61
|
}
|
|
67
62
|
}
|
|
68
|
-
function isDefined(value) {
|
|
69
|
-
return typeof value !== 'undefined';
|
|
70
|
-
}
|
|
71
63
|
function isObject(value) {
|
|
72
|
-
return value
|
|
73
|
-
}
|
|
74
|
-
function isString(value) {
|
|
75
|
-
return typeof value === 'string';
|
|
76
|
-
}
|
|
77
|
-
function isIn(value, values) {
|
|
78
|
-
return values.includes(value);
|
|
64
|
+
return typeof value === 'object' && value != null;
|
|
79
65
|
}
|
|
80
66
|
|
|
81
67
|
export { InputValidationError, validateDeclensionInput, validateGenderDetectionInput };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
package/dist/es/shevchenko.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 3.1.0
|
|
4
|
+
* @version 3.1.0
|
|
5
5
|
* @author Oleksandr Tolochko <shevchenko-js@tooleks.com>
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @copyright 2017-2024 Oleksandr Tolochko <shevchenko-js@tooleks.com>
|