shevchenko 2.0.6 → 2.0.7
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 +26 -26
- package/dist/es/shevchenko.js +26 -26
- 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 +7 -7
- 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 +3 -3
- package/package.json +16 -12
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## shevchenko
|
|
2
2
|
|
|
3
|
-
JavaScript бібліотека для відмінювання українських
|
|
3
|
+
JavaScript бібліотека для відмінювання українських антропонімів / JavaScript library for declension of Ukrainian anthroponyms
|
|
4
4
|
|
|
5
5
|
### Документація / Documentation
|
|
6
6
|
|
|
@@ -16,13 +16,13 @@ npm install --save shevchenko
|
|
|
16
16
|
|
|
17
17
|
```JavaScript
|
|
18
18
|
const anthroponym = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
gender: 'male', // or 'female'
|
|
20
|
+
firstName: 'Тарас',
|
|
21
|
+
middleName: 'Григорович',
|
|
22
|
+
lastName: 'Шевченко'
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
const result = shevchenko.inVocative(anthroponym);
|
|
26
26
|
|
|
27
|
-
console.log(result); // { gender:
|
|
27
|
+
console.log(result); // { gender: "male", firstName: "Тарасе", middleName: "Григоровичу", lastName: "Шевченку" }
|
|
28
28
|
```
|
package/dist/cjs/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.0.
|
|
4
|
+
* @version 2.0.7
|
|
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
|
'use strict';
|
|
@@ -74,7 +74,7 @@ var AnthroponymInflector = /** @class */ (function () {
|
|
|
74
74
|
this.lastNameInflector = lastNameInflector;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
|
-
* Inflects
|
|
77
|
+
* Inflects the anthroponym in the given grammatical case.
|
|
78
78
|
*/
|
|
79
79
|
AnthroponymInflector.prototype.inflect = function (anthroponym, grammaticalCase) {
|
|
80
80
|
var result = { gender: anthroponym.gender };
|
|
@@ -122,7 +122,7 @@ function __extends(d, b) {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
|
-
* Counts a number of groups in
|
|
125
|
+
* Counts a number of groups in the given regular expression.
|
|
126
126
|
*/
|
|
127
127
|
function countGroups(src) {
|
|
128
128
|
var pattern = new RegExp(src.toString() + "|");
|
|
@@ -195,7 +195,7 @@ var AppendCommandRunner = /** @class */ (function () {
|
|
|
195
195
|
this.command = command;
|
|
196
196
|
}
|
|
197
197
|
/**
|
|
198
|
-
* Appends the command value to
|
|
198
|
+
* Appends the command value to the given value.
|
|
199
199
|
* Returns a new value.
|
|
200
200
|
*/
|
|
201
201
|
AppendCommandRunner.prototype.exec = function (value) {
|
|
@@ -209,7 +209,7 @@ var ReplaceCommandRunner = /** @class */ (function () {
|
|
|
209
209
|
this.command = command;
|
|
210
210
|
}
|
|
211
211
|
/**
|
|
212
|
-
* Replaces
|
|
212
|
+
* Replaces the given value with the command value.
|
|
213
213
|
* Returns a new value.
|
|
214
214
|
*/
|
|
215
215
|
ReplaceCommandRunner.prototype.exec = function (value) {
|
|
@@ -222,7 +222,7 @@ var CommandRunnerFactory = /** @class */ (function () {
|
|
|
222
222
|
function CommandRunnerFactory() {
|
|
223
223
|
}
|
|
224
224
|
/**
|
|
225
|
-
* Creates a new command runner for
|
|
225
|
+
* Creates a new command runner for the given command.
|
|
226
226
|
*/
|
|
227
227
|
CommandRunnerFactory.prototype.make = function (command) {
|
|
228
228
|
switch (command.type) {
|
|
@@ -246,7 +246,7 @@ var RuleInflector = /** @class */ (function () {
|
|
|
246
246
|
this.commandRunnerFactory = new CommandRunnerFactory();
|
|
247
247
|
}
|
|
248
248
|
/**
|
|
249
|
-
* Inflects
|
|
249
|
+
* Inflects the given word in the given grammatical case using the rule.
|
|
250
250
|
*/
|
|
251
251
|
RuleInflector.prototype.inflect = function (word, grammaticalCase) {
|
|
252
252
|
var _this = this;
|
|
@@ -281,7 +281,7 @@ var NameInflector = /** @class */ (function () {
|
|
|
281
281
|
function NameInflector() {
|
|
282
282
|
}
|
|
283
283
|
/**
|
|
284
|
-
* Inflects
|
|
284
|
+
* Inflects the name in the given grammatical case.
|
|
285
285
|
*/
|
|
286
286
|
NameInflector.prototype.inflect = function (name, gender, grammaticalCase) {
|
|
287
287
|
var _this = this;
|
|
@@ -353,7 +353,7 @@ var MiddleNameInflector = /** @class */ (function (_super) {
|
|
|
353
353
|
|
|
354
354
|
var PATTERN_VOWELS = /[аоуеиіяюєї]/gi;
|
|
355
355
|
/**
|
|
356
|
-
* Counts vowel sounds in
|
|
356
|
+
* Counts vowel sounds in the given word.
|
|
357
357
|
* Returns a number of vowels.
|
|
358
358
|
*/
|
|
359
359
|
function countVowels(word) {
|
|
@@ -511,7 +511,7 @@ var NeuralNetwork = /** @class */ (function () {
|
|
|
511
511
|
return JSON.stringify(this.toJSON(), null, 2);
|
|
512
512
|
};
|
|
513
513
|
/**
|
|
514
|
-
* Trains the neural network using
|
|
514
|
+
* Trains the neural network using the given training data.
|
|
515
515
|
*/
|
|
516
516
|
NeuralNetwork.prototype.train = function (trainingData, trainingOptions) {
|
|
517
517
|
var trainingSet = Object.entries(trainingData).map(function (_a) {
|
|
@@ -525,8 +525,8 @@ var NeuralNetwork = /** @class */ (function () {
|
|
|
525
525
|
return this;
|
|
526
526
|
};
|
|
527
527
|
/**
|
|
528
|
-
* Activates the neural network for
|
|
529
|
-
* Returns a part of speech of
|
|
528
|
+
* Activates the neural network for the given word.
|
|
529
|
+
* Returns a part of speech of the given word.
|
|
530
530
|
*/
|
|
531
531
|
NeuralNetwork.prototype.activate = function (word) {
|
|
532
532
|
var input = new WordEncoder().encode(word);
|
|
@@ -540,7 +540,7 @@ var WordTransformer = /** @class */ (function () {
|
|
|
540
540
|
function WordTransformer() {
|
|
541
541
|
}
|
|
542
542
|
/**
|
|
543
|
-
* Transform
|
|
543
|
+
* Transform the given word for use in part of speech recognition process.
|
|
544
544
|
*/
|
|
545
545
|
WordTransformer.prototype.transform = function (word) {
|
|
546
546
|
return word.toLowerCase();
|
|
@@ -553,8 +553,8 @@ var PartOfSpeechRecognizer = /** @class */ (function () {
|
|
|
553
553
|
this.rules = rules;
|
|
554
554
|
}
|
|
555
555
|
/**
|
|
556
|
-
* Recognizes the part of speech of
|
|
557
|
-
* Returns part of speech of
|
|
556
|
+
* Recognizes the part of speech of the given word.
|
|
557
|
+
* Returns part of speech of the given word.
|
|
558
558
|
* Returns null if part of speech was not recognized.
|
|
559
559
|
*/
|
|
560
560
|
PartOfSpeechRecognizer.prototype.recognize = function (word, gender) {
|
|
@@ -575,8 +575,8 @@ var PartOfSpeechRecognitionRule = /** @class */ (function () {
|
|
|
575
575
|
this.cache = cache;
|
|
576
576
|
}
|
|
577
577
|
/**
|
|
578
|
-
* Applies the part of speech recognizer rule to
|
|
579
|
-
* Returns a part of speech of
|
|
578
|
+
* Applies the part of speech recognizer rule to the given word.
|
|
579
|
+
* Returns a part of speech of the given word.
|
|
580
580
|
*/
|
|
581
581
|
PartOfSpeechRecognitionRule.prototype.apply = function (word) {
|
|
582
582
|
var transformedWord = new WordTransformer().transform(word);
|
|
@@ -154451,49 +154451,49 @@ var internal = /*#__PURE__*/Object.freeze({
|
|
|
154451
154451
|
});
|
|
154452
154452
|
|
|
154453
154453
|
/**
|
|
154454
|
-
* Inflects
|
|
154454
|
+
* Inflects the anthroponym in nominative grammatical case.
|
|
154455
154455
|
*/
|
|
154456
154456
|
function inNominative(anthroponym) {
|
|
154457
154457
|
validateAnthroponym(anthroponym);
|
|
154458
154458
|
return anthroponymInflector.inflect(anthroponym, GrammaticalCase.Nominative);
|
|
154459
154459
|
}
|
|
154460
154460
|
/**
|
|
154461
|
-
* Inflects
|
|
154461
|
+
* Inflects the anthroponym in genitive grammatical case.
|
|
154462
154462
|
*/
|
|
154463
154463
|
function inGenitive(anthroponym) {
|
|
154464
154464
|
validateAnthroponym(anthroponym);
|
|
154465
154465
|
return anthroponymInflector.inflect(anthroponym, GrammaticalCase.Genitive);
|
|
154466
154466
|
}
|
|
154467
154467
|
/**
|
|
154468
|
-
* Inflects
|
|
154468
|
+
* Inflects the anthroponym in dative grammatical case.
|
|
154469
154469
|
*/
|
|
154470
154470
|
function inDative(anthroponym) {
|
|
154471
154471
|
validateAnthroponym(anthroponym);
|
|
154472
154472
|
return anthroponymInflector.inflect(anthroponym, GrammaticalCase.Dative);
|
|
154473
154473
|
}
|
|
154474
154474
|
/**
|
|
154475
|
-
* Inflects
|
|
154475
|
+
* Inflects the anthroponym in accusative grammatical case.
|
|
154476
154476
|
*/
|
|
154477
154477
|
function inAccusative(anthroponym) {
|
|
154478
154478
|
validateAnthroponym(anthroponym);
|
|
154479
154479
|
return anthroponymInflector.inflect(anthroponym, GrammaticalCase.Accusative);
|
|
154480
154480
|
}
|
|
154481
154481
|
/**
|
|
154482
|
-
* Inflects
|
|
154482
|
+
* Inflects the anthroponym in ablative grammatical case.
|
|
154483
154483
|
*/
|
|
154484
154484
|
function inAblative(anthroponym) {
|
|
154485
154485
|
validateAnthroponym(anthroponym);
|
|
154486
154486
|
return anthroponymInflector.inflect(anthroponym, GrammaticalCase.Ablative);
|
|
154487
154487
|
}
|
|
154488
154488
|
/**
|
|
154489
|
-
* Inflects
|
|
154489
|
+
* Inflects the anthroponym in locative grammatical case.
|
|
154490
154490
|
*/
|
|
154491
154491
|
function inLocative(anthroponym) {
|
|
154492
154492
|
validateAnthroponym(anthroponym);
|
|
154493
154493
|
return anthroponymInflector.inflect(anthroponym, GrammaticalCase.Locative);
|
|
154494
154494
|
}
|
|
154495
154495
|
/**
|
|
154496
|
-
* Inflects
|
|
154496
|
+
* Inflects the anthroponym in vocative grammatical case.
|
|
154497
154497
|
*/
|
|
154498
154498
|
function inVocative(anthroponym) {
|
|
154499
154499
|
validateAnthroponym(anthroponym);
|
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.0.
|
|
4
|
+
* @version 2.0.7
|
|
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,49 +154371,49 @@ 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);
|
|
@@ -8,7 +8,7 @@ export declare class AnthroponymInflector {
|
|
|
8
8
|
private readonly lastNameInflector;
|
|
9
9
|
constructor(firstNameInflector: FirstNameInflector, middleNameInflector: MiddleNameInflector, lastNameInflector: LastNameInflector);
|
|
10
10
|
/**
|
|
11
|
-
* Inflects
|
|
11
|
+
* Inflects the anthroponym in the given grammatical case.
|
|
12
12
|
*/
|
|
13
13
|
inflect(anthroponym: Anthroponym, grammaticalCase: GrammaticalCase): Anthroponym;
|
|
14
14
|
}
|
|
@@ -4,7 +4,7 @@ export declare class AppendCommandRunner implements InflectorCommandRunner {
|
|
|
4
4
|
private readonly command;
|
|
5
5
|
constructor(command: InflectorCommand);
|
|
6
6
|
/**
|
|
7
|
-
* Appends the command value to
|
|
7
|
+
* Appends the command value to the given value.
|
|
8
8
|
* Returns a new value.
|
|
9
9
|
*/
|
|
10
10
|
exec(value: string): string;
|
|
@@ -2,7 +2,7 @@ import { InflectorCommand } from './inflector.types';
|
|
|
2
2
|
import { InflectorCommandRunner } from './inflector-command-runner';
|
|
3
3
|
export declare class CommandRunnerFactory {
|
|
4
4
|
/**
|
|
5
|
-
* Creates a new command runner for
|
|
5
|
+
* Creates a new command runner for the given command.
|
|
6
6
|
*/
|
|
7
7
|
make(command: InflectorCommand): InflectorCommandRunner;
|
|
8
8
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Gender, GrammaticalCase } from '../core';
|
|
2
2
|
export declare abstract class NameInflector {
|
|
3
3
|
/**
|
|
4
|
-
* Inflects
|
|
4
|
+
* Inflects the name in the given grammatical case.
|
|
5
5
|
*/
|
|
6
6
|
inflect(name: string, gender: Gender, grammaticalCase: GrammaticalCase): string;
|
|
7
7
|
/**
|
|
8
|
-
* Inflects
|
|
8
|
+
* Inflects the word of the compound name in the given grammatical case.
|
|
9
9
|
*/
|
|
10
10
|
protected abstract inflectWord(word: string, gender: Gender, grammaticalCase: GrammaticalCase, isLastWord: boolean): string;
|
|
11
11
|
}
|
|
@@ -4,7 +4,7 @@ export declare class ReplaceCommandRunner implements InflectorCommandRunner {
|
|
|
4
4
|
private readonly command;
|
|
5
5
|
constructor(command: InflectorCommand);
|
|
6
6
|
/**
|
|
7
|
-
* Replaces
|
|
7
|
+
* Replaces the given value with the command value.
|
|
8
8
|
* Returns a new value.
|
|
9
9
|
*/
|
|
10
10
|
exec(value: string): string;
|
|
@@ -5,7 +5,7 @@ export declare class RuleInflector {
|
|
|
5
5
|
private readonly commandRunnerFactory;
|
|
6
6
|
constructor(rule: InflectorRule);
|
|
7
7
|
/**
|
|
8
|
-
* Inflects
|
|
8
|
+
* Inflects the given word in the given grammatical case using the rule.
|
|
9
9
|
*/
|
|
10
10
|
inflect(word: string, grammaticalCase: GrammaticalCase): string;
|
|
11
11
|
}
|
|
@@ -16,12 +16,12 @@ export declare class NeuralNetwork {
|
|
|
16
16
|
*/
|
|
17
17
|
toString(): string;
|
|
18
18
|
/**
|
|
19
|
-
* Trains the neural network using
|
|
19
|
+
* Trains the neural network using the given training data.
|
|
20
20
|
*/
|
|
21
21
|
train(trainingData: NeuralNetworkTrainingData, trainingOptions: any): NeuralNetwork;
|
|
22
22
|
/**
|
|
23
|
-
* Activates the neural network for
|
|
24
|
-
* Returns a part of speech of
|
|
23
|
+
* Activates the neural network for the given word.
|
|
24
|
+
* Returns a part of speech of the given word.
|
|
25
25
|
*/
|
|
26
26
|
activate(word: string): PartOfSpeech;
|
|
27
27
|
}
|
|
@@ -11,8 +11,8 @@ export declare class PartOfSpeechRecognitionRule {
|
|
|
11
11
|
private readonly neuralNetwork;
|
|
12
12
|
constructor(guard: PartOfSpeechRecognitionGuard, neuralNetwork: NeuralNetwork, cache: NeuralNetworkTrainingData);
|
|
13
13
|
/**
|
|
14
|
-
* Applies the part of speech recognizer rule to
|
|
15
|
-
* Returns a part of speech of
|
|
14
|
+
* Applies the part of speech recognizer rule to the given word.
|
|
15
|
+
* Returns a part of speech of the given word.
|
|
16
16
|
*/
|
|
17
17
|
apply(word: string): PartOfSpeech;
|
|
18
18
|
}
|
|
@@ -5,8 +5,8 @@ export declare class PartOfSpeechRecognizer {
|
|
|
5
5
|
private readonly rules;
|
|
6
6
|
constructor(rules: PartOfSpeechRecognitionRule[]);
|
|
7
7
|
/**
|
|
8
|
-
* Recognizes the part of speech of
|
|
9
|
-
* Returns part of speech of
|
|
8
|
+
* Recognizes the part of speech of the given word.
|
|
9
|
+
* Returns part of speech of the given word.
|
|
10
10
|
* Returns null if part of speech was not recognized.
|
|
11
11
|
*/
|
|
12
12
|
recognize(word: string, gender: Gender): PartOfSpeech | null;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { Anthroponym } from './core';
|
|
2
2
|
/**
|
|
3
|
-
* Inflects
|
|
3
|
+
* Inflects the anthroponym in nominative grammatical case.
|
|
4
4
|
*/
|
|
5
5
|
export declare function inNominative(anthroponym: Anthroponym): Anthroponym;
|
|
6
6
|
/**
|
|
7
|
-
* Inflects
|
|
7
|
+
* Inflects the anthroponym in genitive grammatical case.
|
|
8
8
|
*/
|
|
9
9
|
export declare function inGenitive(anthroponym: Anthroponym): Anthroponym;
|
|
10
10
|
/**
|
|
11
|
-
* Inflects
|
|
11
|
+
* Inflects the anthroponym in dative grammatical case.
|
|
12
12
|
*/
|
|
13
13
|
export declare function inDative(anthroponym: Anthroponym): Anthroponym;
|
|
14
14
|
/**
|
|
15
|
-
* Inflects
|
|
15
|
+
* Inflects the anthroponym in accusative grammatical case.
|
|
16
16
|
*/
|
|
17
17
|
export declare function inAccusative(anthroponym: Anthroponym): Anthroponym;
|
|
18
18
|
/**
|
|
19
|
-
* Inflects
|
|
19
|
+
* Inflects the anthroponym in ablative grammatical case.
|
|
20
20
|
*/
|
|
21
21
|
export declare function inAblative(anthroponym: Anthroponym): Anthroponym;
|
|
22
22
|
/**
|
|
23
|
-
* Inflects
|
|
23
|
+
* Inflects the anthroponym in locative grammatical case.
|
|
24
24
|
*/
|
|
25
25
|
export declare function inLocative(anthroponym: Anthroponym): Anthroponym;
|
|
26
26
|
/**
|
|
27
|
-
* Inflects
|
|
27
|
+
* Inflects the anthroponym in vocative grammatical case.
|
|
28
28
|
*/
|
|
29
29
|
export declare function inVocative(anthroponym: Anthroponym): Anthroponym;
|
|
30
30
|
export * as Internal from './internal';
|
|
@@ -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.0.
|
|
4
|
+
* @version 2.0.7
|
|
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
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).shevchenko={})}(this,(function(t){"use strict";var e,l;function r(t){if(null==t)throw new TypeError('"anthroponym" must be an object.');if("object"!=typeof t)throw new TypeError('"anthroponym" must be an object.');if(![e.Male,e.Female].includes(t.gender))throw new TypeError('"anthroponym.gender" must be one of the following: "'+e.Male+'", "'+e.Female+'".');if(void 0===t.firstName&&void 0===t.middleName&&void 0===t.lastName)throw new TypeError('At least one of the following fields must present: "anthroponym.firstName", "anthroponym.middleName", "anthroponym.lastName".');if(void 0!==t.firstName&&"string"!=typeof t.firstName)throw new TypeError('"anthroponym.firstName" must be a string.');if(void 0!==t.middleName&&"string"!=typeof t.middleName)throw new TypeError('"anthroponym.middleName" must be a string.');if(void 0!==t.lastName&&"string"!=typeof t.lastName)throw new TypeError('"anthroponym.lastName" must be a string.')}!function(t){t.Male="male",t.Female="female"}(e||(e={})),function(t){t.Nominative="nominative",t.Genitive="genitive",t.Dative="dative",t.Accusative="accusative",t.Ablative="ablative",t.Locative="locative",t.Vocative="vocative"}(l||(l={}));var o,g=function(){function t(t,e,l){this.firstNameInflector=t,this.middleNameInflector=e,this.lastNameInflector=l}return t.prototype.inflect=function(t,e){var l={gender:t.gender};return null!=t.firstName&&(l.firstName=this.firstNameInflector.inflect(t.firstName,t.gender,e)),null!=t.middleName&&(l.middleName=this.middleNameInflector.inflect(t.middleName,t.gender,e)),null!=t.lastName&&(l.lastName=this.lastNameInflector.inflect(t.lastName,t.gender,e)),l},t}(),a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var l in e)e.hasOwnProperty(l)&&(t[l]=e[l])})(t,e)};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shevchenko",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "JavaScript library
|
|
3
|
+
"version": "2.0.7",
|
|
4
|
+
"description": "JavaScript library for declension of Ukrainian anthroponyms",
|
|
5
5
|
"browser": "./dist/umd/shevchenko.min.js",
|
|
6
6
|
"main": "./dist/cjs/shevchenko.js",
|
|
7
7
|
"module": "./dist/es/shevchenko.js",
|
|
@@ -22,16 +22,20 @@
|
|
|
22
22
|
"build:docs": "node ./docs/src/main.mjs"
|
|
23
23
|
},
|
|
24
24
|
"keywords": [
|
|
25
|
-
"ukrainian
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
25
|
+
"ukrainian",
|
|
26
|
+
"language",
|
|
27
|
+
"grammar",
|
|
28
|
+
"linguistics",
|
|
29
|
+
"inflection",
|
|
30
|
+
"declension",
|
|
31
|
+
"anthroponym",
|
|
32
|
+
"nominative",
|
|
33
|
+
"genitive",
|
|
34
|
+
"dative",
|
|
35
|
+
"accusative",
|
|
36
|
+
"ablative",
|
|
37
|
+
"locative",
|
|
38
|
+
"vocative"
|
|
35
39
|
],
|
|
36
40
|
"repository": {
|
|
37
41
|
"type": "git",
|