nlptoolkit-morphologicalanalysis 1.0.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.
Files changed (65) hide show
  1. package/README.md +144 -0
  2. package/dist/Corpus/DisambiguatedWord.d.ts +20 -0
  3. package/dist/Corpus/DisambiguatedWord.js +38 -0
  4. package/dist/Corpus/DisambiguatedWord.js.map +1 -0
  5. package/dist/Corpus/DisambiguationCorpus.d.ts +4 -0
  6. package/dist/Corpus/DisambiguationCorpus.js +54 -0
  7. package/dist/Corpus/DisambiguationCorpus.js.map +1 -0
  8. package/dist/MorphologicalAnalysis/FiniteStateMachine.d.ts +63 -0
  9. package/dist/MorphologicalAnalysis/FiniteStateMachine.js +178 -0
  10. package/dist/MorphologicalAnalysis/FiniteStateMachine.js.map +1 -0
  11. package/dist/MorphologicalAnalysis/FsmMorphologicalAnalyzer.d.ts +399 -0
  12. package/dist/MorphologicalAnalysis/FsmMorphologicalAnalyzer.js +1255 -0
  13. package/dist/MorphologicalAnalysis/FsmMorphologicalAnalyzer.js.map +1 -0
  14. package/dist/MorphologicalAnalysis/FsmParse.d.ts +290 -0
  15. package/dist/MorphologicalAnalysis/FsmParse.js +684 -0
  16. package/dist/MorphologicalAnalysis/FsmParse.js.map +1 -0
  17. package/dist/MorphologicalAnalysis/FsmParseList.d.ts +96 -0
  18. package/dist/MorphologicalAnalysis/FsmParseList.js +242 -0
  19. package/dist/MorphologicalAnalysis/FsmParseList.js.map +1 -0
  20. package/dist/MorphologicalAnalysis/InflectionalGroup.d.ts +77 -0
  21. package/dist/MorphologicalAnalysis/InflectionalGroup.js +213 -0
  22. package/dist/MorphologicalAnalysis/InflectionalGroup.js.map +1 -0
  23. package/dist/MorphologicalAnalysis/MetamorphicParse.d.ts +63 -0
  24. package/dist/MorphologicalAnalysis/MetamorphicParse.js +592 -0
  25. package/dist/MorphologicalAnalysis/MetamorphicParse.js.map +1 -0
  26. package/dist/MorphologicalAnalysis/MorphologicalParse.d.ts +301 -0
  27. package/dist/MorphologicalAnalysis/MorphologicalParse.js +969 -0
  28. package/dist/MorphologicalAnalysis/MorphologicalParse.js.map +1 -0
  29. package/dist/MorphologicalAnalysis/MorphologicalTag.d.ts +510 -0
  30. package/dist/MorphologicalAnalysis/MorphologicalTag.js +525 -0
  31. package/dist/MorphologicalAnalysis/MorphologicalTag.js.map +1 -0
  32. package/dist/MorphologicalAnalysis/State.d.ts +40 -0
  33. package/dist/MorphologicalAnalysis/State.js +64 -0
  34. package/dist/MorphologicalAnalysis/State.js.map +1 -0
  35. package/dist/MorphologicalAnalysis/Transition.d.ts +159 -0
  36. package/dist/MorphologicalAnalysis/Transition.js +751 -0
  37. package/dist/MorphologicalAnalysis/Transition.js.map +1 -0
  38. package/index.js +12 -0
  39. package/package.json +30 -0
  40. package/penntreebank.txt +208431 -0
  41. package/source/Corpus/DisambiguatedWord.ts +29 -0
  42. package/source/Corpus/DisambiguationCorpus.ts +39 -0
  43. package/source/MorphologicalAnalysis/FiniteStateMachine.ts +165 -0
  44. package/source/MorphologicalAnalysis/FsmMorphologicalAnalyzer.ts +1256 -0
  45. package/source/MorphologicalAnalysis/FsmParse.ts +664 -0
  46. package/source/MorphologicalAnalysis/FsmParseList.ts +238 -0
  47. package/source/MorphologicalAnalysis/InflectionalGroup.ts +210 -0
  48. package/source/MorphologicalAnalysis/MetamorphicParse.ts +589 -0
  49. package/source/MorphologicalAnalysis/MorphologicalParse.ts +995 -0
  50. package/source/MorphologicalAnalysis/MorphologicalTag.ts +510 -0
  51. package/source/MorphologicalAnalysis/State.ts +59 -0
  52. package/source/MorphologicalAnalysis/Transition.ts +733 -0
  53. package/source/tsconfig.json +13 -0
  54. package/tests/DisambiguationCorpusTest.ts +12 -0
  55. package/tests/FiniteStateMachineTest.ts +87 -0
  56. package/tests/FsmMorphologicalAnalyzerTest.ts +204 -0
  57. package/tests/FsmParseListTest.ts +90 -0
  58. package/tests/FsmParseTest.ts +66 -0
  59. package/tests/InflectionalGroupTest.ts +84 -0
  60. package/tests/MorphologicalParseTest.ts +152 -0
  61. package/tests/TransitionTest.ts +174 -0
  62. package/tsconfig.json +15 -0
  63. package/turkish_dictionary.txt +62120 -0
  64. package/turkish_finite_state_machine.xml +1887 -0
  65. package/turkish_misspellings.txt +148932 -0
@@ -0,0 +1,751 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "./State", "nlptoolkit-dictionary/dist/Language/TurkishLanguage"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Transition = void 0;
13
+ const State_1 = require("./State");
14
+ const TurkishLanguage_1 = require("nlptoolkit-dictionary/dist/Language/TurkishLanguage");
15
+ class Transition {
16
+ /**
17
+ * Another constructor of {@link Transition} class which takes a {@link State}, and three {@link String}s as input. Then it
18
+ * initializes toState, with, withName and toPos variables with given inputs.
19
+ *
20
+ * @param toState {@link State} input.
21
+ * @param _with String input.
22
+ * @param withName String input.
23
+ * @param toPos String input.
24
+ */
25
+ constructor(_with, withName, toState, toPos) {
26
+ this._toState = undefined;
27
+ this._with = undefined;
28
+ this.withName = undefined;
29
+ this.formationToCheck = undefined;
30
+ this._toPos = undefined;
31
+ this._with = _with;
32
+ this.withName = withName;
33
+ this._toState = toState;
34
+ this._toPos = toPos;
35
+ }
36
+ /**
37
+ * Getter for the toState variable.
38
+ *
39
+ * @return toState variable.
40
+ */
41
+ toState() {
42
+ return this._toState;
43
+ }
44
+ /**
45
+ * Getter for the toPos variable.
46
+ *
47
+ * @return toPos variable.
48
+ */
49
+ toPos() {
50
+ return this._toPos;
51
+ }
52
+ /**
53
+ * The transitionPossible method takes two {@link String} as inputs; currentSurfaceForm and realSurfaceForm. If the
54
+ * length of the given currentSurfaceForm is greater than the given realSurfaceForm, it directly returns true. If not,
55
+ * it takes a substring from given realSurfaceForm with the size of currentSurfaceForm. Then checks for the characters of
56
+ * with variable.
57
+ * <p>
58
+ * If the character of with that makes transition is C, it returns true if the substring contains c or ç.
59
+ * If the character of with that makes transition is D, it returns true if the substring contains d or t.
60
+ * If the character of with that makes transition is A, it returns true if the substring contains a or e.
61
+ * If the character of with that makes transition is K, it returns true if the substring contains k, g or ğ.
62
+ * If the character of with that makes transition is other than the ones above, it returns true if the substring
63
+ * contains the same character as with.
64
+ *
65
+ * @param currentSurfaceForm {@link String} input.
66
+ * @param realSurfaceForm {@link String} input.
67
+ * @return true when the transition is possible according to Turkish grammar, false otherwise.
68
+ */
69
+ transitionPossible(currentSurfaceForm, realSurfaceForm) {
70
+ if (currentSurfaceForm.length == 0 || currentSurfaceForm.length >= realSurfaceForm.length) {
71
+ return true;
72
+ }
73
+ let searchString = realSurfaceForm.substring(currentSurfaceForm.length);
74
+ for (let i = 0; i < this._with.length; i++) {
75
+ switch (this._with.charAt(i)) {
76
+ case 'C':
77
+ return searchString.includes("c") || searchString.includes("ç");
78
+ case 'D':
79
+ return searchString.includes("d") || searchString.includes("t");
80
+ case 'c':
81
+ case 'e':
82
+ case 'r':
83
+ case 'p':
84
+ case 'l':
85
+ case 'b':
86
+ case 'g':
87
+ case 'o':
88
+ case 'm':
89
+ case 'v':
90
+ case 'i':
91
+ case 'ü':
92
+ case 'z':
93
+ return searchString.includes(this._with.charAt(i));
94
+ case 'A':
95
+ return searchString.includes("a") || searchString.includes("e");
96
+ case 'k':
97
+ return searchString.includes("k") || searchString.includes("g") || searchString.includes("ğ");
98
+ }
99
+ }
100
+ return true;
101
+ }
102
+ /**
103
+ * The transitionPossible method takes a {@link FsmParse} currentFsmParse as an input. It then checks some special cases;
104
+ *
105
+ * @param currentFsmParse Parse to be checked
106
+ * @return true if transition is possible false otherwise
107
+ */
108
+ transitionPossibleFromParse(currentFsmParse) {
109
+ if (this._with == "Ar" && currentFsmParse.getSurfaceForm().endsWith("l") &&
110
+ currentFsmParse.getWord().getName() != currentFsmParse.getSurfaceForm()) {
111
+ return false;
112
+ }
113
+ if (currentFsmParse.getVerbAgreement() != null && currentFsmParse.getPossesiveAgreement() != null &&
114
+ this.withName != undefined) {
115
+ if (currentFsmParse.getVerbAgreement() == "A3PL" && this.withName == "^DB+VERB+ZERO+PRES+A1SG") {
116
+ return false;
117
+ }
118
+ if (currentFsmParse.getVerbAgreement() == "A3SG" &&
119
+ (currentFsmParse.getPossesiveAgreement() == "P1SG" || currentFsmParse.getPossesiveAgreement() == "P2SG") &&
120
+ this.withName == "^DB+VERB+ZERO+PRES+A1PL") {
121
+ return false;
122
+ }
123
+ }
124
+ return true;
125
+ }
126
+ transitionPossibleFromRoot(root, fromState) {
127
+ if (root.isAdjective() && ((root.isNominal() && !root.isExceptional()) || root.isPronoun()) && this._toState.getName() == "NominalRoot(ADJ)" && this._with == "0") {
128
+ return false;
129
+ }
130
+ if (root.isAdjective() && root.isNominal() && this._with == "^DB+VERB+ZERO+PRES+A3PL" && fromState.getName() == "AdjectiveRoot") {
131
+ return false;
132
+ }
133
+ if (root.isAdjective() && root.isNominal() && this._with == "SH" && fromState.getName() == "AdjectiveRoot") {
134
+ return false;
135
+ }
136
+ if (this._with == "ki") {
137
+ return root.takesRelativeSuffixKi();
138
+ }
139
+ if (this._with == "kü") {
140
+ return root.takesRelativeSuffixKu();
141
+ }
142
+ if (this._with == "dHr") {
143
+ if (this._toState.getName() == "Adverb") {
144
+ return true;
145
+ }
146
+ else {
147
+ return root.takesSuffixDIRAsFactitive();
148
+ }
149
+ }
150
+ if (this._with == "Hr" && (this._toState.getName() == "AdjectiveRoot(VERB)" ||
151
+ this._toState.getName() == "OtherTense" || this._toState.getName() == "OtherTense2")) {
152
+ return root.takesSuffixIRAsAorist();
153
+ }
154
+ return true;
155
+ }
156
+ /**
157
+ * The beforeLastVowel method takes a {@link String} stem as an input. It loops through the given stem and returns
158
+ * the second last vowel.
159
+ *
160
+ * @param stem String input.
161
+ * @return Vowel before the last vowel.
162
+ */
163
+ beforeLastVowel(stem) {
164
+ let before = 1;
165
+ let last = '0';
166
+ for (let i = stem.length - 1; i >= 0; i--) {
167
+ if (TurkishLanguage_1.TurkishLanguage.isVowel(stem.charAt(i))) {
168
+ if (before == 1) {
169
+ last = stem.charAt(i);
170
+ before--;
171
+ continue;
172
+ }
173
+ return stem.charAt(i);
174
+ }
175
+ }
176
+ return last;
177
+ }
178
+ /**
179
+ * The lastVowel method takes a {@link String} stem as an input. It loops through the given stem and returns
180
+ * the last vowel.
181
+ *
182
+ * @param stem String input.
183
+ * @return the last vowel.
184
+ */
185
+ lastVowel(stem) {
186
+ for (let i = stem.length - 1; i >= 0; i--) {
187
+ if (TurkishLanguage_1.TurkishLanguage.isVowel(stem.charAt(i))) {
188
+ return stem.charAt(i);
189
+ }
190
+ }
191
+ for (let i = stem.length - 1; i >= 0; i--) {
192
+ if (stem.charAt(i) >= '0' && stem.charAt(i) <= '9') {
193
+ return stem.charAt(i);
194
+ }
195
+ }
196
+ return '0';
197
+ }
198
+ /**
199
+ * The lastPhoneme method takes a {@link String} stem as an input. It then returns the last phoneme of the given stem.
200
+ *
201
+ * @param stem String input.
202
+ * @return the last phoneme.
203
+ */
204
+ lastPhoneme(stem) {
205
+ if (stem.length == 0) {
206
+ return ' ';
207
+ }
208
+ if (stem.charAt(stem.length - 1) != '\'') {
209
+ return stem.charAt(stem.length - 1);
210
+ }
211
+ else {
212
+ return stem.charAt(stem.length - 2);
213
+ }
214
+ }
215
+ /**
216
+ * The withFirstChar method returns the first character of the with variable.
217
+ *
218
+ * @return the first character of the with variable.
219
+ */
220
+ withFirstChar() {
221
+ if (this._with.length == 0) {
222
+ return '$';
223
+ }
224
+ if (this._with.charAt(0) != '\'') {
225
+ return this._with.charAt(0);
226
+ }
227
+ else {
228
+ if (this._with.length == 1) {
229
+ return this._with.charAt(0);
230
+ }
231
+ else {
232
+ return this._with.charAt(1);
233
+ }
234
+ }
235
+ }
236
+ /**
237
+ * The startWithVowelorConsonantDrops method checks for some cases. If the first character of with variable is "nsy",
238
+ * and with variable does not equal to one of the Strings; "ylA, ysA, ymHs, yDH, yken", it returns true. If
239
+ * <p>
240
+ * Or, if the first character of with variable is 'A, H: or any other vowels, it returns true.
241
+ *
242
+ * @return true if it starts with vowel or consonant drops, false otherwise.
243
+ */
244
+ startWithVowelorConsonantDrops() {
245
+ if (TurkishLanguage_1.TurkishLanguage.isConsonantDrop(this.withFirstChar()) && this._with != "ylA" && this._with != "ysA" &&
246
+ this._with != "ymHs" && this._with != "yDH" && this._with != "yken") {
247
+ return true;
248
+ }
249
+ if (this.withFirstChar() == 'A' || this.withFirstChar() == 'H' || TurkishLanguage_1.TurkishLanguage.isVowel(this.withFirstChar())) {
250
+ return true;
251
+ }
252
+ return false;
253
+ }
254
+ /**
255
+ * The softenDuringSuffixation method takes a {@link TxtWord} root as an input. It checks two cases; first case returns
256
+ * true if the given root is nominal or adjective and has one of the flags "IS_SD, IS_B_SD, IS_SDD" and with variable
257
+ * equals o one of the Strings "Hm, nDAn, ncA, nDA, yA, yHm, yHz, yH, nH, nA, nHn, H, sH, Hn, HnHz, HmHz".
258
+ * <p>
259
+ * And the second case returns true if the given root is verb and has the "F_SD" flag, also with variable starts with
260
+ * "Hyor" or equals one of the Strings "yHs, yAn, yA, yAcAk, yAsH, yHncA, yHp, yAlH, yArAk, yAdur, yHver, yAgel, yAgor,
261
+ * yAbil, yAyaz, yAkal, yAkoy, yAmA, yHcH, HCH, Hr, Hs, Hn, yHn", yHnHz, Ar, Hl").
262
+ *
263
+ * @param root {@link TxtWord} input.
264
+ * @return true if there is softening during suffixation of the given root, false otherwise.
265
+ */
266
+ softenDuringSuffixation(root) {
267
+ if ((root.isNominal() || root.isAdjective()) && root.nounSoftenDuringSuffixation() &&
268
+ (this._with == "Hm" || this._with == "nDAn" || this._with == "ncA" || this._with == "nDA" ||
269
+ this._with == "yA" || this._with == "yHm" || this._with == "yHz" || this._with == "yH" ||
270
+ this._with == "nH" || this._with == "nA" || this._with == "nHn" || this._with == "H" ||
271
+ this._with == "sH" || this._with == "Hn" || this._with == "HnHz" || this._with == "HmHz")) {
272
+ return true;
273
+ }
274
+ if (root.isVerb() && root.verbSoftenDuringSuffixation() &&
275
+ (this._with.startsWith("Hyor") || this._with == "yHs" || this._with == "yAn" || this._with == "yA" ||
276
+ this._with.startsWith("yAcAk") || this._with == "yAsH" || this._with == "yHncA" || this._with == "yHp" ||
277
+ this._with == "yAlH" || this._with == "yArAk" || this._with == "yAdur" || this._with == "yHver" ||
278
+ this._with == "yAgel" || this._with == "yAgor" || this._with == "yAbil" || this._with == "yAyaz" ||
279
+ this._with == "yAkal" || this._with == "yAkoy" || this._with == "yAmA" || this._with == "yHcH" ||
280
+ this._with == "HCH" || this._with.startsWith("Hr") || this._with == "Hs" || this._with == "Hn" ||
281
+ this._with == "yHn" || this._with == "yHnHz" || this._with.startsWith("Ar") || this._with == "Hl")) {
282
+ return true;
283
+ }
284
+ return false;
285
+ }
286
+ /**
287
+ * The makeTransition method takes a {@link TxtWord} root and s {@link String} stem as inputs. If given root is a verb,
288
+ * it makes transition with given root and stem with the verbal root state. If given root is not verb, it makes transition
289
+ * with given root and stem and the nominal root state.
290
+ *
291
+ * @param root {@link TxtWord} input.
292
+ * @param stem String input.
293
+ * @param startState Start state to make the transition.
294
+ * @return String type output that has the transition.
295
+ */
296
+ makeTransition(root, stem, startState) {
297
+ if (startState == undefined) {
298
+ if (root.isVerb()) {
299
+ return this.makeTransition(root, stem, new State_1.State("VerbalRoot", true, false));
300
+ }
301
+ else {
302
+ return this.makeTransition(root, stem, new State_1.State("NominalRoot", true, false));
303
+ }
304
+ }
305
+ else {
306
+ let rootWord = root.getName() == stem || (root.getName() + "'") == stem;
307
+ let formation = stem;
308
+ let i = 0;
309
+ if (this._with == "0") {
310
+ return stem;
311
+ }
312
+ if ((stem == "bu" || stem == "şu" || stem == "o") && rootWord && this._with == "ylA") {
313
+ return stem + "nunla";
314
+ }
315
+ if (this._with == "yA") {
316
+ if (stem == "ben") {
317
+ return "bana";
318
+ }
319
+ if (stem == "sen") {
320
+ return "sana";
321
+ }
322
+ }
323
+ this.formationToCheck = stem;
324
+ //---vowelEChangesToIDuringYSuffixation---
325
+ //de->d(i)yor, ye->y(i)yor
326
+ if (rootWord && this.withFirstChar() == 'y' && root.vowelEChangesToIDuringYSuffixation() &&
327
+ (this._with.charAt(1) != 'H' || root.getName() == "ye")) {
328
+ formation = stem.substring(0, stem.length - 1) + 'i';
329
+ this.formationToCheck = formation;
330
+ }
331
+ else {
332
+ //---lastIdropsDuringPassiveSuffixation---
333
+ // yoğur->yoğrul, ayır->ayrıl, buyur->buyrul, çağır->çağrıl, çevir->çevril, devir->devril,
334
+ // kavur->kavrul, kayır->kayrıl, kıvır->kıvrıl, savur->savrul, sıyır->sıyrıl, yoğur->yoğrul
335
+ if (rootWord && (this._with == "Hl" || this._with == "Hn") && root.lastIdropsDuringPassiveSuffixation()) {
336
+ formation = stem.substring(0, stem.length - 2) + stem.charAt(stem.length - 1);
337
+ this.formationToCheck = stem;
338
+ }
339
+ else {
340
+ //---showsSuRegularities---
341
+ //karasu->karasuyu, su->suyu, ağırsu->ağırsuyu, akarsu->akarsuyu, bengisu->bengisuyu
342
+ if (rootWord && root.showsSuRegularities() && this.startWithVowelorConsonantDrops() && !this._with.startsWith("y")) {
343
+ formation = stem + 'y';
344
+ this.formationToCheck = formation;
345
+ }
346
+ else {
347
+ if (rootWord && root.duplicatesDuringSuffixation() && !startState.getName().startsWith("VerbalRoot") &&
348
+ TurkishLanguage_1.TurkishLanguage.isConsonantDrop(this._with.charAt(0))) {
349
+ //---duplicatesDuringSuffixation---
350
+ if (this.softenDuringSuffixation(root)) {
351
+ //--extra softenDuringSuffixation
352
+ switch (this.lastPhoneme(stem)) {
353
+ case 'p':
354
+ //tıp->tıbbı
355
+ formation = stem.substring(0, stem.length - 1) + "bb";
356
+ break;
357
+ case 't':
358
+ //cet->ceddi, met->meddi, ret->reddi, serhat->serhaddi, zıt->zıddı, şet->şeddi
359
+ formation = stem.substring(0, stem.length - 1) + "dd";
360
+ break;
361
+ }
362
+ }
363
+ else {
364
+ //cer->cerri, emrihak->emrihakkı, fek->fekki, fen->fenni, had->haddi, hat->hattı,
365
+ // haz->hazzı, his->hissi
366
+ formation = stem + stem.charAt(stem.length - 1);
367
+ }
368
+ this.formationToCheck = formation;
369
+ }
370
+ else {
371
+ if (rootWord && root.lastIdropsDuringSuffixation() &&
372
+ !startState.getName().startsWith("VerbalRoot") && !startState.getName().startsWith("ProperRoot") &&
373
+ this.startWithVowelorConsonantDrops()) {
374
+ //---lastIdropsDuringSuffixation---
375
+ if (this.softenDuringSuffixation(root)) {
376
+ //---softenDuringSuffixation---
377
+ switch (this.lastPhoneme(stem)) {
378
+ case 'p':
379
+ //hizip->hizbi, kayıp->kaybı, kayıt->kaydı, kutup->kutbu
380
+ formation = stem.substring(0, stem.length - 2) + 'b';
381
+ break;
382
+ case 't':
383
+ //akit->akdi, ahit->ahdi, lahit->lahdi, nakit->nakdi, vecit->vecdi
384
+ formation = stem.substring(0, stem.length - 2) + 'd';
385
+ break;
386
+ case 'ç':
387
+ //eviç->evci, nesiç->nesci
388
+ formation = stem.substring(0, stem.length - 2) + 'c';
389
+ break;
390
+ }
391
+ }
392
+ else {
393
+ //sarıağız->sarıağzı, zehir->zehri, zikir->zikri, nutuk->nutku, omuz->omzu, ömür->ömrü
394
+ //lütuf->lütfu, metin->metni, kavim->kavmi, kasıt->kastı
395
+ formation = stem.substring(0, stem.length - 2) + stem.charAt(stem.length - 1);
396
+ }
397
+ this.formationToCheck = stem;
398
+ }
399
+ else {
400
+ switch (this.lastPhoneme(stem)) {
401
+ //---nounSoftenDuringSuffixation or verbSoftenDuringSuffixation
402
+ case 'p':
403
+ //adap->adabı, amip->amibi, azap->azabı, gazap->gazabı
404
+ if (this.startWithVowelorConsonantDrops() && rootWord && this.softenDuringSuffixation(root)) {
405
+ formation = stem.substring(0, stem.length - 1) + 'b';
406
+ }
407
+ break;
408
+ case 't':
409
+ //adet->adedi, akort->akordu, armut->armudu
410
+ //affet->affedi, yoket->yokedi, sabret->sabredi, rakset->raksedi
411
+ if (this.startWithVowelorConsonantDrops() && rootWord && this.softenDuringSuffixation(root)) {
412
+ formation = stem.substring(0, stem.length - 1) + 'd';
413
+ }
414
+ break;
415
+ case 'ç':
416
+ //ağaç->ağacı, almaç->almacı, akaç->akacı, avuç->avucu
417
+ if (this.startWithVowelorConsonantDrops() && rootWord && this.softenDuringSuffixation(root)) {
418
+ formation = stem.substring(0, stem.length - 1) + 'c';
419
+ }
420
+ break;
421
+ case 'g':
422
+ //arkeolog->arkeoloğu, filolog->filoloğu, minerolog->mineroloğu
423
+ if (this.startWithVowelorConsonantDrops() && rootWord && this.softenDuringSuffixation(root)) {
424
+ formation = stem.substring(0, stem.length - 1) + 'ğ';
425
+ }
426
+ break;
427
+ case 'k':
428
+ //ahenk->ahengi, künk->küngü, renk->rengi, pelesenk->pelesengi
429
+ if (this.startWithVowelorConsonantDrops() && rootWord && root.endingKChangesIntoG() &&
430
+ (!root.isProperNoun() || startState.toString() != "ProperRoot")) {
431
+ formation = stem.substring(0, stem.length - 1) + 'g';
432
+ }
433
+ else {
434
+ //ablak->ablağı, küllük->küllüğü, kitaplık->kitaplığı, evcilik->evciliği
435
+ if (this.startWithVowelorConsonantDrops() && (!rootWord ||
436
+ (this.softenDuringSuffixation(root) && (!root.isProperNoun() ||
437
+ startState.toString() != "ProperRoot")))) {
438
+ formation = stem.substring(0, stem.length - 1) + 'ğ';
439
+ }
440
+ }
441
+ break;
442
+ }
443
+ this.formationToCheck = formation;
444
+ }
445
+ }
446
+ }
447
+ }
448
+ }
449
+ if (TurkishLanguage_1.TurkishLanguage.isConsonantDrop(this.withFirstChar()) &&
450
+ !TurkishLanguage_1.TurkishLanguage.isVowel(stem.charAt(stem.length - 1)) &&
451
+ (root.isNumeral() || root.isReal() || root.isFraction() || root.isTime() || root.isDate() ||
452
+ root.isPercent() || root.isRange()) && (root.getName().endsWith("1") || root.getName().endsWith("3") ||
453
+ root.getName().endsWith("4") || root.getName().endsWith("5") || root.getName().endsWith("8") ||
454
+ root.getName().endsWith("9") || root.getName().endsWith("10") || root.getName().endsWith("30") ||
455
+ root.getName().endsWith("40") || root.getName().endsWith("60") || root.getName().endsWith("70") ||
456
+ root.getName().endsWith("80") || root.getName().endsWith("90") || root.getName().endsWith("00"))) {
457
+ if (this._with.charAt(0) == '\'') {
458
+ formation = formation + '\'';
459
+ i = 2;
460
+ }
461
+ else {
462
+ i = 1;
463
+ }
464
+ }
465
+ else {
466
+ if ((TurkishLanguage_1.TurkishLanguage.isConsonantDrop(this.withFirstChar()) && TurkishLanguage_1.TurkishLanguage.isConsonant(this.lastPhoneme(stem))) ||
467
+ (rootWord && root.consonantSMayInsertedDuringPossesiveSuffixation())) {
468
+ if (this._with.charAt(0) == '\'') {
469
+ formation = formation + '\'';
470
+ if (root.isAbbreviation())
471
+ i = 1;
472
+ else
473
+ i = 2;
474
+ }
475
+ else {
476
+ i = 1;
477
+ }
478
+ }
479
+ }
480
+ for (; i < this._with.length; i++) {
481
+ switch (this._with.charAt(i)) {
482
+ case 'D':
483
+ formation = this.resolveD(root, formation);
484
+ break;
485
+ case 'A':
486
+ formation = this.resolveA(root, formation, rootWord);
487
+ break;
488
+ case 'H':
489
+ if (this._with.charAt(0) != '\'') {
490
+ formation = this.resolveH(root, formation, i == 0, this._with.startsWith("Hyor"), rootWord);
491
+ }
492
+ else {
493
+ formation = this.resolveH(root, formation, i == 1, false, rootWord);
494
+ }
495
+ break;
496
+ case 'C':
497
+ formation = this.resolveC(formation);
498
+ break;
499
+ case 'S':
500
+ formation = this.resolveS(formation);
501
+ break;
502
+ case 'Ş':
503
+ formation = this.resolveSh(formation);
504
+ break;
505
+ default:
506
+ if (i == this._with.length - 1 && this._with.charAt(i) == 's') {
507
+ formation += 'ş';
508
+ }
509
+ else {
510
+ formation += this._with.charAt(i);
511
+ }
512
+ }
513
+ this.formationToCheck = formation;
514
+ }
515
+ return formation;
516
+ }
517
+ }
518
+ resolveD(root, formation) {
519
+ if (root.isAbbreviation()) {
520
+ return formation + 'd';
521
+ }
522
+ if (this.lastPhoneme(this.formationToCheck) >= '0' && this.lastPhoneme(this.formationToCheck) <= '9') {
523
+ switch (this.lastPhoneme(this.formationToCheck)) {
524
+ case '3':
525
+ case '4':
526
+ case '5':
527
+ //3->3'tü, 5->5'ti, 4->4'tü
528
+ return formation + 't';
529
+ case '0':
530
+ if (root.getName().endsWith("40") || root.getName().endsWith("60") || root.getName().endsWith("70"))
531
+ //40->40'tı, 60->60'tı, 70->70'ti
532
+ return formation + 't';
533
+ else
534
+ //30->30'du, 50->50'ydi, 80->80'di
535
+ return formation + 'd';
536
+ default:
537
+ return formation + 'd';
538
+ }
539
+ }
540
+ else {
541
+ if (TurkishLanguage_1.TurkishLanguage.isSertSessiz(this.lastPhoneme(this.formationToCheck))) {
542
+ //yap+DH->yaptı
543
+ return formation + 't';
544
+ }
545
+ else {
546
+ //sar+DH->sardı
547
+ return formation + 'd';
548
+ }
549
+ }
550
+ }
551
+ resolveA(root, formation, rootWord) {
552
+ if (root.isAbbreviation()) {
553
+ return formation + 'e';
554
+ }
555
+ if (this.lastVowel(this.formationToCheck) >= '0' && this.lastVowel(this.formationToCheck) <= '9') {
556
+ switch (this.lastVowel(this.formationToCheck)) {
557
+ case '6':
558
+ case '9':
559
+ //6'ya, 9'a
560
+ return formation + 'a';
561
+ case '0':
562
+ if (root.getName().endsWith("10") || root.getName().endsWith("30") || root.getName().endsWith("40") ||
563
+ root.getName().endsWith("60") || root.getName().endsWith("90"))
564
+ //10'a, 30'a, 40'a, 60'a, 90'a
565
+ return formation + 'a';
566
+ else
567
+ //20'ye, 50'ye, 80'e, 70'e
568
+ return formation + 'e';
569
+ default:
570
+ //3'e, 8'e, 4'e, 2'ye
571
+ return formation + 'e';
572
+ }
573
+ }
574
+ if (TurkishLanguage_1.TurkishLanguage.isBackVowel(this.lastVowel(this.formationToCheck))) {
575
+ if (root.notObeysVowelHarmonyDuringAgglutination() && rootWord) {
576
+ //alkole, anormale
577
+ return formation + 'e';
578
+ }
579
+ else {
580
+ //sakala, kabala
581
+ return formation + 'a';
582
+ }
583
+ }
584
+ if (TurkishLanguage_1.TurkishLanguage.isFrontVowel(this.lastVowel(this.formationToCheck))) {
585
+ if (root.notObeysVowelHarmonyDuringAgglutination() && rootWord) {
586
+ //faika, halika
587
+ return formation + 'a';
588
+ }
589
+ else {
590
+ //kediye, eve
591
+ return formation + 'e';
592
+ }
593
+ }
594
+ if (root.isNumeral() || root.isFraction() || root.isReal()) {
595
+ if (root.getName().endsWith("6") || root.getName().endsWith("9") || root.getName().endsWith("10") ||
596
+ root.getName().endsWith("30") || root.getName().endsWith("40") || root.getName().endsWith("60") ||
597
+ root.getName().endsWith("90")) {
598
+ return formation + 'a';
599
+ }
600
+ else {
601
+ return formation + 'e';
602
+ }
603
+ }
604
+ return formation;
605
+ }
606
+ resolveH(root, formation, beginningOfSuffix, specialCaseTenseSuffix, rootWord) {
607
+ if (root.isAbbreviation())
608
+ return formation + 'i';
609
+ if (beginningOfSuffix && TurkishLanguage_1.TurkishLanguage.isVowel(this.lastPhoneme(this.formationToCheck)) &&
610
+ !specialCaseTenseSuffix) {
611
+ return formation;
612
+ }
613
+ if (specialCaseTenseSuffix) {
614
+ //eğer ek Hyor eki ise,
615
+ if (rootWord) {
616
+ if (root.vowelAChangesToIDuringYSuffixation()) {
617
+ if (TurkishLanguage_1.TurkishLanguage.isFrontRoundedVowel(this.beforeLastVowel(this.formationToCheck))) {
618
+ //büyülüyor, bölümlüyor, çözümlüyor, döşüyor
619
+ return formation.substring(0, formation.length - 1) + 'ü';
620
+ }
621
+ if (TurkishLanguage_1.TurkishLanguage.isFrontUnroundedVowel(this.beforeLastVowel(this.formationToCheck))) {
622
+ //adresliyor, alevliyor, ateşliyor, bekliyor
623
+ return formation.substring(0, formation.length - 1) + 'i';
624
+ }
625
+ if (TurkishLanguage_1.TurkishLanguage.isBackRoundedVowel(this.beforeLastVowel(this.formationToCheck))) {
626
+ //buğuluyor, bulguluyor, çamurluyor, aforozluyor
627
+ return formation.substring(0, formation.length - 1) + 'u';
628
+ }
629
+ if (TurkishLanguage_1.TurkishLanguage.isBackUnroundedVowel(this.beforeLastVowel(this.formationToCheck))) {
630
+ //açıklıyor, çalkalıyor, gazlıyor, gıcırdıyor
631
+ return formation.substring(0, formation.length - 1) + 'ı';
632
+ }
633
+ }
634
+ }
635
+ if (TurkishLanguage_1.TurkishLanguage.isVowel(this.lastPhoneme(this.formationToCheck))) {
636
+ if (TurkishLanguage_1.TurkishLanguage.isFrontRoundedVowel(this.beforeLastVowel(this.formationToCheck))) {
637
+ return formation.substring(0, formation.length - 1) + 'ü';
638
+ }
639
+ if (TurkishLanguage_1.TurkishLanguage.isFrontUnroundedVowel(this.beforeLastVowel(this.formationToCheck))) {
640
+ return formation.substring(0, formation.length - 1) + 'i';
641
+ }
642
+ if (TurkishLanguage_1.TurkishLanguage.isBackRoundedVowel(this.beforeLastVowel(this.formationToCheck))) {
643
+ return formation.substring(0, formation.length - 1) + 'u';
644
+ }
645
+ if (TurkishLanguage_1.TurkishLanguage.isBackUnroundedVowel(this.beforeLastVowel(this.formationToCheck))) {
646
+ return formation.substring(0, formation.length - 1) + 'ı';
647
+ }
648
+ }
649
+ }
650
+ if (TurkishLanguage_1.TurkishLanguage.isFrontRoundedVowel(this.lastVowel(this.formationToCheck)) ||
651
+ (TurkishLanguage_1.TurkishLanguage.isBackRoundedVowel(this.lastVowel(this.formationToCheck)) && root.notObeysVowelHarmonyDuringAgglutination())) {
652
+ return formation + 'ü';
653
+ }
654
+ if (TurkishLanguage_1.TurkishLanguage.isFrontUnroundedVowel(this.lastVowel(this.formationToCheck)) ||
655
+ (this.lastVowel(this.formationToCheck) == 'a' && root.notObeysVowelHarmonyDuringAgglutination())) {
656
+ return formation + 'i';
657
+ }
658
+ if (TurkishLanguage_1.TurkishLanguage.isBackRoundedVowel(this.lastVowel(this.formationToCheck))) {
659
+ return formation + 'u';
660
+ }
661
+ if (TurkishLanguage_1.TurkishLanguage.isBackUnroundedVowel(this.lastVowel(this.formationToCheck))) {
662
+ return formation + 'ı';
663
+ }
664
+ if (root.isNumeral() || root.isFraction() || root.isReal()) {
665
+ if (root.getName().endsWith("6") || root.getName().endsWith("40") || root.getName().endsWith("60") ||
666
+ root.getName().endsWith("90")) {
667
+ //6'yı, 40'ı, 60'ı
668
+ return formation + 'ı';
669
+ }
670
+ else {
671
+ if (root.getName().endsWith("3") || root.getName().endsWith("4") || root.getName().endsWith("00")) {
672
+ //3'ü, 4'ü, 100'ü
673
+ return formation + 'ü';
674
+ }
675
+ else {
676
+ if (root.getName().endsWith("9") || root.getName().endsWith("10") || root.getName().endsWith("30")) {
677
+ //9'u, 10'u, 30'u
678
+ return formation + 'u';
679
+ }
680
+ else {
681
+ //2'yi, 5'i, 8'i
682
+ return formation + 'i';
683
+ }
684
+ }
685
+ }
686
+ }
687
+ return formation;
688
+ }
689
+ /**
690
+ * The resolveC method takes a {@link String} formation as an input. If the last phoneme is on of the "çfhkpsşt", it
691
+ * concatenates given formation with 'ç', if not it concatenates given formation with 'c'.
692
+ *
693
+ * @param formation {@link String} input.
694
+ * @return resolved String.
695
+ */
696
+ resolveC(formation) {
697
+ if (TurkishLanguage_1.TurkishLanguage.isSertSessiz(this.lastPhoneme(this.formationToCheck))) {
698
+ return formation + 'ç';
699
+ }
700
+ else {
701
+ return formation + 'c';
702
+ }
703
+ }
704
+ /**
705
+ * The resolveS method takes a {@link String} formation as an input. It then concatenates given formation with 's'.
706
+ *
707
+ * @param formation {@link String} input.
708
+ * @return resolved String.
709
+ */
710
+ resolveS(formation) {
711
+ return formation + 's';
712
+ }
713
+ /**
714
+ * The resolveSh method takes a {@link String} formation as an input. If the last character is a vowel, it concatenates
715
+ * given formation with ş, if the last character is not a vowel, and not 't' it directly returns given formation, but if it
716
+ * is equal to 't', it transforms it to 'd'.
717
+ *
718
+ * @param formation {@link String} input.
719
+ * @return resolved String.
720
+ */
721
+ resolveSh(formation) {
722
+ if (TurkishLanguage_1.TurkishLanguage.isVowel(formation.charAt(formation.length - 1))) {
723
+ return formation + 'ş';
724
+ }
725
+ else {
726
+ if (formation.charAt(formation.length - 1) != 't')
727
+ return formation;
728
+ else
729
+ return formation.substring(0, formation.length - 1) + 'd';
730
+ }
731
+ }
732
+ /**
733
+ * An overridden toString method which returns the with variable.
734
+ *
735
+ * @return with variable.
736
+ */
737
+ toString() {
738
+ return this._with;
739
+ }
740
+ /**
741
+ * The with method returns the withName variable.
742
+ *
743
+ * @return the withName variable.
744
+ */
745
+ getWith() {
746
+ return this.withName;
747
+ }
748
+ }
749
+ exports.Transition = Transition;
750
+ });
751
+ //# sourceMappingURL=Transition.js.map