shevchenko 2.0.6 → 2.1.1
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 +6 -6
- package/dist/cjs/shevchenko.js +32 -33
- package/dist/cjs/shevchenko.js.map +1 -1
- package/dist/es/shevchenko.js +27 -27
- package/dist/es/shevchenko.js.map +1 -1
- package/dist/types/anthroponym-inflection/anthroponym-inflector.d.ts +1 -1
- package/dist/types/anthroponym-inflection/append-command-runner.d.ts +1 -1
- package/dist/types/anthroponym-inflection/command-runner-factory.d.ts +1 -1
- package/dist/types/anthroponym-inflection/name-inflector.d.ts +2 -2
- package/dist/types/anthroponym-inflection/replace-command-runner.d.ts +1 -1
- package/dist/types/anthroponym-inflection/rule-inflector.d.ts +1 -1
- package/dist/types/part-of-speech-recognition/neural-network.d.ts +3 -3
- package/dist/types/part-of-speech-recognition/part-of-speech-recognition-rule.d.ts +2 -2
- package/dist/types/part-of-speech-recognition/part-of-speech-recognizer.d.ts +2 -2
- package/dist/types/part-of-speech-recognition/word-transformer.d.ts +1 -1
- package/dist/types/shevchenko.d.ts +9 -8
- package/dist/types/shevchenko.d.ts.map +1 -1
- package/dist/types/utils/lang.utils.d.ts +1 -1
- package/dist/types/utils/regexp.utils.d.ts +1 -1
- package/dist/umd/shevchenko.min.js +5 -5
- package/dist/umd/shevchenko.min.js.map +1 -1
- package/package.json +16 -12
- package/src/anthroponym-inflection/anthroponym-inflector.ts +38 -0
- package/src/anthroponym-inflection/append-command-runner.ts +18 -0
- package/src/anthroponym-inflection/command-runner-factory.ts +23 -0
- package/src/anthroponym-inflection/first-name-inflector.ts +41 -0
- package/src/anthroponym-inflection/index.ts +5 -0
- package/src/anthroponym-inflection/inflector-command-runner.ts +3 -0
- package/src/anthroponym-inflection/inflector.types.ts +42 -0
- package/src/anthroponym-inflection/last-name-inflector.ts +54 -0
- package/src/anthroponym-inflection/middle-name-inflector.ts +29 -0
- package/src/anthroponym-inflection/name-inflector.ts +19 -0
- package/src/anthroponym-inflection/replace-command-runner.ts +18 -0
- package/src/anthroponym-inflection/rule-inflector.ts +40 -0
- package/src/bootstrap.ts +53 -0
- package/src/core/anthroponym.interface.ts +8 -0
- package/src/core/gender.enum.ts +4 -0
- package/src/core/grammatical-case.enum.ts +9 -0
- package/src/core/index.ts +4 -0
- package/src/core/validator.ts +39 -0
- package/src/internal.ts +1 -0
- package/src/part-of-speech-recognition/index.ts +5 -0
- package/src/part-of-speech-recognition/neural-network-config.ts +5 -0
- package/src/part-of-speech-recognition/neural-network-training-data.ts +5 -0
- package/src/part-of-speech-recognition/neural-network.ts +66 -0
- package/src/part-of-speech-recognition/part-of-speech-decoder.ts +26 -0
- package/src/part-of-speech-recognition/part-of-speech-encoder.ts +20 -0
- package/src/part-of-speech-recognition/part-of-speech-recognition-rule.ts +33 -0
- package/src/part-of-speech-recognition/part-of-speech-recognizer.ts +26 -0
- package/src/part-of-speech-recognition/part-of-speech.enum.ts +4 -0
- package/src/part-of-speech-recognition/word-encoder.ts +23 -0
- package/src/part-of-speech-recognition/word-transformer.ts +8 -0
- package/src/resources/inflector/rules.json +7114 -0
- package/src/resources/neural-networks/kosmii/README.md +5 -0
- package/src/resources/neural-networks/kosmii/cache.json +8 -0
- package/src/resources/neural-networks/kosmii/samples.json +9435 -0
- package/src/resources/neural-networks/kosmii/structure.json +47898 -0
- package/src/resources/neural-networks/pelykh/README.md +5 -0
- package/src/resources/neural-networks/pelykh/cache.json +1 -0
- package/src/resources/neural-networks/pelykh/samples.json +221 -0
- package/src/resources/neural-networks/pelykh/structure.json +47898 -0
- package/src/resources/neural-networks/pohorielova/README.md +5 -0
- package/src/resources/neural-networks/pohorielova/cache.json +542 -0
- package/src/resources/neural-networks/pohorielova/samples.json +32147 -0
- package/src/resources/neural-networks/pohorielova/structure.json +47898 -0
- package/src/shevchenko.ts +63 -0
- package/src/utils/lang.utils.ts +13 -0
- package/src/utils/regexp.utils.ts +11 -0
- package/src/utils/string.utils.ts +49 -0
package/dist/es/shevchenko.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file JavaScript library
|
|
2
|
+
* @file JavaScript library for declension of Ukrainian anthroponyms
|
|
3
3
|
* @module shevchenko
|
|
4
|
-
* @version 2.
|
|
4
|
+
* @version 2.1.1
|
|
5
5
|
* @author Oleksandr Tolochko <tooleks@gmail.com>
|
|
6
6
|
* @license MIT
|
|
7
|
-
* @copyright
|
|
7
|
+
* @copyright 2022 Oleksandr Tolochko <tooleks@gmail.com>
|
|
8
8
|
* @see {@link git+https://github.com/tooleks/shevchenko-js.git}
|
|
9
9
|
*/
|
|
10
10
|
import synaptic from 'synaptic';
|
|
@@ -66,7 +66,7 @@ class AnthroponymInflector {
|
|
|
66
66
|
this.lastNameInflector = lastNameInflector;
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
|
-
* Inflects
|
|
69
|
+
* Inflects the anthroponym in the given grammatical case.
|
|
70
70
|
*/
|
|
71
71
|
inflect(anthroponym, grammaticalCase) {
|
|
72
72
|
const result = { gender: anthroponym.gender };
|
|
@@ -84,7 +84,7 @@ class AnthroponymInflector {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
|
-
* Counts a number of groups in
|
|
87
|
+
* Counts a number of groups in the given regular expression.
|
|
88
88
|
*/
|
|
89
89
|
function countGroups(src) {
|
|
90
90
|
const pattern = new RegExp(`${src.toString()}|`);
|
|
@@ -155,7 +155,7 @@ class AppendCommandRunner {
|
|
|
155
155
|
this.command = command;
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
|
-
* Appends the command value to
|
|
158
|
+
* Appends the command value to the given value.
|
|
159
159
|
* Returns a new value.
|
|
160
160
|
*/
|
|
161
161
|
exec(value) {
|
|
@@ -168,7 +168,7 @@ class ReplaceCommandRunner {
|
|
|
168
168
|
this.command = command;
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
171
|
-
* Replaces
|
|
171
|
+
* Replaces the given value with the command value.
|
|
172
172
|
* Returns a new value.
|
|
173
173
|
*/
|
|
174
174
|
exec(value) {
|
|
@@ -178,7 +178,7 @@ class ReplaceCommandRunner {
|
|
|
178
178
|
|
|
179
179
|
class CommandRunnerFactory {
|
|
180
180
|
/**
|
|
181
|
-
* Creates a new command runner for
|
|
181
|
+
* Creates a new command runner for the given command.
|
|
182
182
|
*/
|
|
183
183
|
make(command) {
|
|
184
184
|
switch (command.type) {
|
|
@@ -201,7 +201,7 @@ class RuleInflector {
|
|
|
201
201
|
this.commandRunnerFactory = new CommandRunnerFactory();
|
|
202
202
|
}
|
|
203
203
|
/**
|
|
204
|
-
* Inflects
|
|
204
|
+
* Inflects the given word in the given grammatical case using the rule.
|
|
205
205
|
*/
|
|
206
206
|
inflect(word, grammaticalCase) {
|
|
207
207
|
const [commands] = this.rule.grammaticalCases[grammaticalCase];
|
|
@@ -228,7 +228,7 @@ class RuleInflector {
|
|
|
228
228
|
|
|
229
229
|
class NameInflector {
|
|
230
230
|
/**
|
|
231
|
-
* Inflects
|
|
231
|
+
* Inflects the name in the given grammatical case.
|
|
232
232
|
*/
|
|
233
233
|
inflect(name, gender, grammaticalCase) {
|
|
234
234
|
const words = name.split('-');
|
|
@@ -292,7 +292,7 @@ class MiddleNameInflector extends NameInflector {
|
|
|
292
292
|
|
|
293
293
|
const PATTERN_VOWELS = /[аоуеиіяюєї]/gi;
|
|
294
294
|
/**
|
|
295
|
-
* Counts vowel sounds in
|
|
295
|
+
* Counts vowel sounds in the given word.
|
|
296
296
|
* Returns a number of vowels.
|
|
297
297
|
*/
|
|
298
298
|
function countVowels(word) {
|
|
@@ -438,7 +438,7 @@ class NeuralNetwork {
|
|
|
438
438
|
return JSON.stringify(this.toJSON(), null, 2);
|
|
439
439
|
}
|
|
440
440
|
/**
|
|
441
|
-
* Trains the neural network using
|
|
441
|
+
* Trains the neural network using the given training data.
|
|
442
442
|
*/
|
|
443
443
|
train(trainingData, trainingOptions) {
|
|
444
444
|
const trainingSet = Object.entries(trainingData).map(([word, partOfSpeech]) => {
|
|
@@ -451,8 +451,8 @@ class NeuralNetwork {
|
|
|
451
451
|
return this;
|
|
452
452
|
}
|
|
453
453
|
/**
|
|
454
|
-
* Activates the neural network for
|
|
455
|
-
* Returns a part of speech of
|
|
454
|
+
* Activates the neural network for the given word.
|
|
455
|
+
* Returns a part of speech of the given word.
|
|
456
456
|
*/
|
|
457
457
|
activate(word) {
|
|
458
458
|
const input = new WordEncoder().encode(word);
|
|
@@ -463,7 +463,7 @@ class NeuralNetwork {
|
|
|
463
463
|
|
|
464
464
|
class WordTransformer {
|
|
465
465
|
/**
|
|
466
|
-
* Transform
|
|
466
|
+
* Transform the given word for use in part of speech recognition process.
|
|
467
467
|
*/
|
|
468
468
|
transform(word) {
|
|
469
469
|
return word.toLowerCase();
|
|
@@ -475,8 +475,8 @@ class PartOfSpeechRecognizer {
|
|
|
475
475
|
this.rules = rules;
|
|
476
476
|
}
|
|
477
477
|
/**
|
|
478
|
-
* Recognizes the part of speech of
|
|
479
|
-
* Returns part of speech of
|
|
478
|
+
* Recognizes the part of speech of the given word.
|
|
479
|
+
* Returns part of speech of the given word.
|
|
480
480
|
* Returns null if part of speech was not recognized.
|
|
481
481
|
*/
|
|
482
482
|
recognize(word, gender) {
|
|
@@ -496,8 +496,8 @@ class PartOfSpeechRecognitionRule {
|
|
|
496
496
|
this.cache = cache;
|
|
497
497
|
}
|
|
498
498
|
/**
|
|
499
|
-
* Applies the part of speech recognizer rule to
|
|
500
|
-
* Returns a part of speech of
|
|
499
|
+
* Applies the part of speech recognizer rule to the given word.
|
|
500
|
+
* Returns a part of speech of the given word.
|
|
501
501
|
*/
|
|
502
502
|
apply(word) {
|
|
503
503
|
const transformedWord = new WordTransformer().transform(word);
|
|
@@ -154371,54 +154371,54 @@ var internal = /*#__PURE__*/Object.freeze({
|
|
|
154371
154371
|
});
|
|
154372
154372
|
|
|
154373
154373
|
/**
|
|
154374
|
-
* Inflects
|
|
154374
|
+
* Inflects the anthroponym in nominative grammatical case.
|
|
154375
154375
|
*/
|
|
154376
154376
|
function inNominative(anthroponym) {
|
|
154377
154377
|
validateAnthroponym(anthroponym);
|
|
154378
154378
|
return anthroponymInflector.inflect(anthroponym, GrammaticalCase.Nominative);
|
|
154379
154379
|
}
|
|
154380
154380
|
/**
|
|
154381
|
-
* Inflects
|
|
154381
|
+
* Inflects the anthroponym in genitive grammatical case.
|
|
154382
154382
|
*/
|
|
154383
154383
|
function inGenitive(anthroponym) {
|
|
154384
154384
|
validateAnthroponym(anthroponym);
|
|
154385
154385
|
return anthroponymInflector.inflect(anthroponym, GrammaticalCase.Genitive);
|
|
154386
154386
|
}
|
|
154387
154387
|
/**
|
|
154388
|
-
* Inflects
|
|
154388
|
+
* Inflects the anthroponym in dative grammatical case.
|
|
154389
154389
|
*/
|
|
154390
154390
|
function inDative(anthroponym) {
|
|
154391
154391
|
validateAnthroponym(anthroponym);
|
|
154392
154392
|
return anthroponymInflector.inflect(anthroponym, GrammaticalCase.Dative);
|
|
154393
154393
|
}
|
|
154394
154394
|
/**
|
|
154395
|
-
* Inflects
|
|
154395
|
+
* Inflects the anthroponym in accusative grammatical case.
|
|
154396
154396
|
*/
|
|
154397
154397
|
function inAccusative(anthroponym) {
|
|
154398
154398
|
validateAnthroponym(anthroponym);
|
|
154399
154399
|
return anthroponymInflector.inflect(anthroponym, GrammaticalCase.Accusative);
|
|
154400
154400
|
}
|
|
154401
154401
|
/**
|
|
154402
|
-
* Inflects
|
|
154402
|
+
* Inflects the anthroponym in ablative grammatical case.
|
|
154403
154403
|
*/
|
|
154404
154404
|
function inAblative(anthroponym) {
|
|
154405
154405
|
validateAnthroponym(anthroponym);
|
|
154406
154406
|
return anthroponymInflector.inflect(anthroponym, GrammaticalCase.Ablative);
|
|
154407
154407
|
}
|
|
154408
154408
|
/**
|
|
154409
|
-
* Inflects
|
|
154409
|
+
* Inflects the anthroponym in locative grammatical case.
|
|
154410
154410
|
*/
|
|
154411
154411
|
function inLocative(anthroponym) {
|
|
154412
154412
|
validateAnthroponym(anthroponym);
|
|
154413
154413
|
return anthroponymInflector.inflect(anthroponym, GrammaticalCase.Locative);
|
|
154414
154414
|
}
|
|
154415
154415
|
/**
|
|
154416
|
-
* Inflects
|
|
154416
|
+
* Inflects the anthroponym in vocative grammatical case.
|
|
154417
154417
|
*/
|
|
154418
154418
|
function inVocative(anthroponym) {
|
|
154419
154419
|
validateAnthroponym(anthroponym);
|
|
154420
154420
|
return anthroponymInflector.inflect(anthroponym, GrammaticalCase.Vocative);
|
|
154421
154421
|
}
|
|
154422
154422
|
|
|
154423
|
-
export { internal as Internal, inAblative, inAccusative, inDative, inGenitive, inLocative, inNominative, inVocative };
|
|
154423
|
+
export { Gender, internal as Internal, inAblative, inAccusative, inDative, inGenitive, inLocative, inNominative, inVocative };
|
|
154424
154424
|
//# sourceMappingURL=shevchenko.js.map
|