nlptoolkit-morphologicalanalysis 1.0.18 → 1.0.20

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 (34) hide show
  1. package/dist/Corpus/DisambiguatedWord.js +26 -35
  2. package/dist/Corpus/DisambiguatedWord.js.map +1 -1
  3. package/dist/Corpus/DisambiguationCorpus.js +70 -47
  4. package/dist/Corpus/DisambiguationCorpus.js.map +1 -1
  5. package/dist/MorphologicalAnalysis/FiniteStateMachine.js +148 -158
  6. package/dist/MorphologicalAnalysis/FiniteStateMachine.js.map +1 -1
  7. package/dist/MorphologicalAnalysis/FsmMorphologicalAnalyzer.js +1281 -1254
  8. package/dist/MorphologicalAnalysis/FsmMorphologicalAnalyzer.js.map +1 -1
  9. package/dist/MorphologicalAnalysis/FsmParse.js +596 -603
  10. package/dist/MorphologicalAnalysis/FsmParse.js.map +1 -1
  11. package/dist/MorphologicalAnalysis/FsmParseList.js +263 -273
  12. package/dist/MorphologicalAnalysis/FsmParseList.js.map +1 -1
  13. package/dist/MorphologicalAnalysis/InflectionalGroup.js +152 -162
  14. package/dist/MorphologicalAnalysis/InflectionalGroup.js.map +1 -1
  15. package/dist/MorphologicalAnalysis/MetamorphicParse.js +120 -129
  16. package/dist/MorphologicalAnalysis/MetamorphicParse.js.map +1 -1
  17. package/dist/MorphologicalAnalysis/MorphologicalParse.js +1037 -1046
  18. package/dist/MorphologicalAnalysis/MorphologicalParse.js.map +1 -1
  19. package/dist/MorphologicalAnalysis/MorphologicalTag.js +530 -540
  20. package/dist/MorphologicalAnalysis/MorphologicalTag.js.map +1 -1
  21. package/dist/MorphologicalAnalysis/MorphotacticEngine.js +230 -240
  22. package/dist/MorphologicalAnalysis/MorphotacticEngine.js.map +1 -1
  23. package/dist/MorphologicalAnalysis/State.js +54 -60
  24. package/dist/MorphologicalAnalysis/State.js.map +1 -1
  25. package/dist/MorphologicalAnalysis/Transition.js +408 -418
  26. package/dist/MorphologicalAnalysis/Transition.js.map +1 -1
  27. package/dist/index.js +19 -25
  28. package/dist/index.js.map +1 -1
  29. package/package.json +8 -7
  30. package/tests/FsmParseListTest.ts +3 -3
  31. package/tests/FsmParseTest.ts +1 -1
  32. package/tsconfig.json +4 -3
  33. package/turkish_dictionary.txt +9114 -9114
  34. package/source/tsconfig.json +0 -13
@@ -1,485 +1,475 @@
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;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Transition = void 0;
4
+ const State_1 = require("./State");
5
+ const TurkishLanguage_1 = require("nlptoolkit-dictionary/dist/Language/TurkishLanguage");
6
+ const Word_1 = require("nlptoolkit-dictionary/dist/Dictionary/Word");
7
+ const MorphotacticEngine_1 = require("./MorphotacticEngine");
8
+ class Transition {
9
+ _toState = undefined;
10
+ _with = undefined;
11
+ withName = undefined;
12
+ _toPos = undefined;
13
+ /**
14
+ * Another constructor of {@link Transition} class which takes a {@link State}, and three {@link String}s as input. Then it
15
+ * initializes toState, with, withName and toPos variables with given inputs.
16
+ *
17
+ * @param toState {@link State} input.
18
+ * @param _with String input.
19
+ * @param withName String input.
20
+ * @param toPos String input.
21
+ */
22
+ constructor(_with, withName, toState, toPos) {
23
+ this._with = _with;
24
+ this.withName = withName;
25
+ this._toState = toState;
26
+ this._toPos = toPos;
5
27
  }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./State", "nlptoolkit-dictionary/dist/Language/TurkishLanguage", "nlptoolkit-dictionary/dist/Dictionary/Word", "./MorphotacticEngine"], factory);
28
+ /**
29
+ * Getter for the toState variable.
30
+ *
31
+ * @return toState variable.
32
+ */
33
+ toState() {
34
+ return this._toState;
8
35
  }
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
- const Word_1 = require("nlptoolkit-dictionary/dist/Dictionary/Word");
16
- const MorphotacticEngine_1 = require("./MorphotacticEngine");
17
- class Transition {
18
- /**
19
- * Another constructor of {@link Transition} class which takes a {@link State}, and three {@link String}s as input. Then it
20
- * initializes toState, with, withName and toPos variables with given inputs.
21
- *
22
- * @param toState {@link State} input.
23
- * @param _with String input.
24
- * @param withName String input.
25
- * @param toPos String input.
26
- */
27
- constructor(_with, withName, toState, toPos) {
28
- this._toState = undefined;
29
- this._with = undefined;
30
- this.withName = undefined;
31
- this._toPos = undefined;
32
- this._with = _with;
33
- this.withName = withName;
34
- this._toState = toState;
35
- this._toPos = toPos;
36
+ /**
37
+ * Getter for the toPos variable.
38
+ *
39
+ * @return toPos variable.
40
+ */
41
+ toPos() {
42
+ return this._toPos;
43
+ }
44
+ /**
45
+ * The transitionPossible method takes two {@link String} as inputs; currentSurfaceForm and realSurfaceForm. If the
46
+ * length of the given currentSurfaceForm is greater than the given realSurfaceForm, it directly returns true. If not,
47
+ * it takes a substring from given realSurfaceForm with the size of currentSurfaceForm. Then checks for the characters of
48
+ * with variable.
49
+ * <p>
50
+ * If the character of with that makes transition is C, it returns true if the substring contains c or ç.
51
+ * If the character of with that makes transition is D, it returns true if the substring contains d or t.
52
+ * If the character of with that makes transition is A, it returns true if the substring contains a or e.
53
+ * If the character of with that makes transition is K, it returns true if the substring contains k, g or ğ.
54
+ * If the character of with that makes transition is other than the ones above, it returns true if the substring
55
+ * contains the same character as with.
56
+ *
57
+ * @param currentSurfaceForm {@link String} input.
58
+ * @param realSurfaceForm {@link String} input.
59
+ * @return true when the transition is possible according to Turkish grammar, false otherwise.
60
+ */
61
+ transitionPossible(currentSurfaceForm, realSurfaceForm) {
62
+ if (currentSurfaceForm.length == 0 || currentSurfaceForm.length >= realSurfaceForm.length) {
63
+ return true;
36
64
  }
37
- /**
38
- * Getter for the toState variable.
39
- *
40
- * @return toState variable.
41
- */
42
- toState() {
43
- return this._toState;
65
+ let searchString = realSurfaceForm.substring(currentSurfaceForm.length);
66
+ for (let i = 0; i < this._with.length; i++) {
67
+ switch (this._with.charAt(i)) {
68
+ case 'C':
69
+ return searchString.includes("c") || searchString.includes("ç");
70
+ case 'D':
71
+ return searchString.includes("d") || searchString.includes("t");
72
+ case 'c':
73
+ case 'e':
74
+ case 'r':
75
+ case 'p':
76
+ case 'l':
77
+ case 'b':
78
+ case 'g':
79
+ case 'o':
80
+ case 'm':
81
+ case 'v':
82
+ case 'i':
83
+ case 'ü':
84
+ case 'z':
85
+ return searchString.includes(this._with.charAt(i));
86
+ case 'A':
87
+ return searchString.includes("a") || searchString.includes("e");
88
+ case 'k':
89
+ return searchString.includes("k") || searchString.includes("g") || searchString.includes("ğ");
90
+ }
44
91
  }
45
- /**
46
- * Getter for the toPos variable.
47
- *
48
- * @return toPos variable.
49
- */
50
- toPos() {
51
- return this._toPos;
92
+ return true;
93
+ }
94
+ /**
95
+ * The transitionPossible method takes a {@link FsmParse} currentFsmParse as an input. It then checks some special cases;
96
+ *
97
+ * @param currentFsmParse Parse to be checked
98
+ * @return true if transition is possible false otherwise
99
+ */
100
+ transitionPossibleFromParse(currentFsmParse) {
101
+ if (this._with == "Ar" && currentFsmParse.getSurfaceForm().endsWith("l") &&
102
+ currentFsmParse.getWord().getName() != currentFsmParse.getSurfaceForm()) {
103
+ return false;
52
104
  }
53
- /**
54
- * The transitionPossible method takes two {@link String} as inputs; currentSurfaceForm and realSurfaceForm. If the
55
- * length of the given currentSurfaceForm is greater than the given realSurfaceForm, it directly returns true. If not,
56
- * it takes a substring from given realSurfaceForm with the size of currentSurfaceForm. Then checks for the characters of
57
- * with variable.
58
- * <p>
59
- * If the character of with that makes transition is C, it returns true if the substring contains c or ç.
60
- * If the character of with that makes transition is D, it returns true if the substring contains d or t.
61
- * If the character of with that makes transition is A, it returns true if the substring contains a or e.
62
- * If the character of with that makes transition is K, it returns true if the substring contains k, g or ğ.
63
- * If the character of with that makes transition is other than the ones above, it returns true if the substring
64
- * contains the same character as with.
65
- *
66
- * @param currentSurfaceForm {@link String} input.
67
- * @param realSurfaceForm {@link String} input.
68
- * @return true when the transition is possible according to Turkish grammar, false otherwise.
69
- */
70
- transitionPossible(currentSurfaceForm, realSurfaceForm) {
71
- if (currentSurfaceForm.length == 0 || currentSurfaceForm.length >= realSurfaceForm.length) {
105
+ return true;
106
+ }
107
+ /**
108
+ * The transitionPossibleFromRoot method takes root and current parse as inputs. It then checks some special cases.
109
+ *
110
+ * @param root Current root word
111
+ * @param fromState From which state we arrived to this state.
112
+ * @return true if transition is possible false otherwise
113
+ */
114
+ transitionPossibleFromRoot(root, fromState) {
115
+ if (root.isAdjective() && ((root.isNominal() && !root.isExceptional()) || root.isPronoun()) && this._toState.getName() == "NominalRoot(ADJ)" && this._with == "0") {
116
+ return false;
117
+ }
118
+ if (root.isAdjective() && root.isNominal() && this._with == "^DB+VERB+ZERO+PRES+A3PL" && fromState.getName() == "AdjectiveRoot") {
119
+ return false;
120
+ }
121
+ if (root.isAdjective() && root.isNominal() && this._with == "SH" && fromState.getName() == "AdjectiveRoot") {
122
+ return false;
123
+ }
124
+ if (this._with == "ki") {
125
+ return root.takesRelativeSuffixKi();
126
+ }
127
+ if (this._with == "kü") {
128
+ return root.takesRelativeSuffixKu();
129
+ }
130
+ if (this._with == "DHr") {
131
+ if (this._toState.getName() == "Adverb") {
72
132
  return true;
73
133
  }
74
- let searchString = realSurfaceForm.substring(currentSurfaceForm.length);
75
- for (let i = 0; i < this._with.length; i++) {
76
- switch (this._with.charAt(i)) {
77
- case 'C':
78
- return searchString.includes("c") || searchString.includes("ç");
79
- case 'D':
80
- return searchString.includes("d") || searchString.includes("t");
81
- case 'c':
82
- case 'e':
83
- case 'r':
84
- case 'p':
85
- case 'l':
86
- case 'b':
87
- case 'g':
88
- case 'o':
89
- case 'm':
90
- case 'v':
91
- case 'i':
92
- case 'ü':
93
- case 'z':
94
- return searchString.includes(this._with.charAt(i));
95
- case 'A':
96
- return searchString.includes("a") || searchString.includes("e");
97
- case 'k':
98
- return searchString.includes("k") || searchString.includes("g") || searchString.includes("ğ");
99
- }
134
+ else {
135
+ return root.takesSuffixDIRAsFactitive();
100
136
  }
101
- return true;
102
137
  }
103
- /**
104
- * The transitionPossible method takes a {@link FsmParse} currentFsmParse as an input. It then checks some special cases;
105
- *
106
- * @param currentFsmParse Parse to be checked
107
- * @return true if transition is possible false otherwise
108
- */
109
- transitionPossibleFromParse(currentFsmParse) {
110
- if (this._with == "Ar" && currentFsmParse.getSurfaceForm().endsWith("l") &&
111
- currentFsmParse.getWord().getName() != currentFsmParse.getSurfaceForm()) {
112
- return false;
113
- }
114
- return true;
138
+ if (this._with == "Hr" && (this._toState.getName() == "AdjectiveRoot(VERB)" ||
139
+ this._toState.getName() == "OtherTense" || this._toState.getName() == "OtherTense2")) {
140
+ return root.takesSuffixIRAsAorist();
115
141
  }
116
- /**
117
- * The transitionPossibleFromRoot method takes root and current parse as inputs. It then checks some special cases.
118
- *
119
- * @param root Current root word
120
- * @param fromState From which state we arrived to this state.
121
- * @return true if transition is possible false otherwise
122
- */
123
- transitionPossibleFromRoot(root, fromState) {
124
- if (root.isAdjective() && ((root.isNominal() && !root.isExceptional()) || root.isPronoun()) && this._toState.getName() == "NominalRoot(ADJ)" && this._with == "0") {
125
- return false;
126
- }
127
- if (root.isAdjective() && root.isNominal() && this._with == "^DB+VERB+ZERO+PRES+A3PL" && fromState.getName() == "AdjectiveRoot") {
128
- return false;
129
- }
130
- if (root.isAdjective() && root.isNominal() && this._with == "SH" && fromState.getName() == "AdjectiveRoot") {
131
- return false;
132
- }
133
- if (this._with == "ki") {
134
- return root.takesRelativeSuffixKi();
135
- }
136
- if (this._with == "kü") {
137
- return root.takesRelativeSuffixKu();
138
- }
139
- if (this._with == "DHr") {
140
- if (this._toState.getName() == "Adverb") {
141
- return true;
142
- }
143
- else {
144
- return root.takesSuffixDIRAsFactitive();
145
- }
146
- }
147
- if (this._with == "Hr" && (this._toState.getName() == "AdjectiveRoot(VERB)" ||
148
- this._toState.getName() == "OtherTense" || this._toState.getName() == "OtherTense2")) {
149
- return root.takesSuffixIRAsAorist();
150
- }
151
- return true;
142
+ return true;
143
+ }
144
+ /**
145
+ * The withFirstChar method returns the first character of the with variable.
146
+ *
147
+ * @return the first character of the with variable.
148
+ */
149
+ withFirstChar() {
150
+ if (this._with.length == 0) {
151
+ return '$';
152
152
  }
153
- /**
154
- * The withFirstChar method returns the first character of the with variable.
155
- *
156
- * @return the first character of the with variable.
157
- */
158
- withFirstChar() {
159
- if (this._with.length == 0) {
160
- return '$';
161
- }
162
- if (this._with.charAt(0) != '\'') {
153
+ if (this._with.charAt(0) != '\'') {
154
+ return this._with.charAt(0);
155
+ }
156
+ else {
157
+ if (this._with.length == 1) {
163
158
  return this._with.charAt(0);
164
159
  }
165
160
  else {
166
- if (this._with.length == 1) {
167
- return this._with.charAt(0);
168
- }
169
- else {
170
- return this._with.charAt(1);
171
- }
161
+ return this._with.charAt(1);
172
162
  }
173
163
  }
174
- /**
175
- * The startWithVowelorConsonantDrops method checks for some cases. If the first character of with variable is "nsy",
176
- * and with variable does not equal to one of the Strings; "ylA, ysA, ymHs, yDH, yken", it returns true. If
177
- * <p>
178
- * Or, if the first character of with variable is 'A, H: or any other vowels, it returns true.
179
- *
180
- * @return true if it starts with vowel or consonant drops, false otherwise.
181
- */
182
- startWithVowelorConsonantDrops() {
183
- if (TurkishLanguage_1.TurkishLanguage.isConsonantDrop(this.withFirstChar()) && this._with != "ylA" && this._with != "ysA" &&
184
- this._with != "ymHs" && this._with != "yDH" && this._with != "yken") {
185
- return true;
164
+ }
165
+ /**
166
+ * The startWithVowelorConsonantDrops method checks for some cases. If the first character of with variable is "nsy",
167
+ * and with variable does not equal to one of the Strings; "ylA, ysA, ymHs, yDH, yken", it returns true. If
168
+ * <p>
169
+ * Or, if the first character of with variable is 'A, H: or any other vowels, it returns true.
170
+ *
171
+ * @return true if it starts with vowel or consonant drops, false otherwise.
172
+ */
173
+ startWithVowelorConsonantDrops() {
174
+ if (TurkishLanguage_1.TurkishLanguage.isConsonantDrop(this.withFirstChar()) && this._with != "ylA" && this._with != "ysA" &&
175
+ this._with != "ymHs" && this._with != "yDH" && this._with != "yken") {
176
+ return true;
177
+ }
178
+ if (this.withFirstChar() == 'A' || this.withFirstChar() == 'H' || TurkishLanguage_1.TurkishLanguage.isVowel(this.withFirstChar())) {
179
+ return true;
180
+ }
181
+ return false;
182
+ }
183
+ /**
184
+ * The softenDuringSuffixation method takes a {@link TxtWord} root as an input. It checks two cases; first case returns
185
+ * 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
186
+ * equals o one of the Strings "Hm, nDAn, ncA, nDA, yA, yHm, yHz, yH, nH, nA, nHn, H, sH, Hn, HnHz, HmHz".
187
+ * <p>
188
+ * And the second case returns true if the given root is verb and has the "F_SD" flag, also with variable starts with
189
+ * "Hyor" or equals one of the Strings "yHs, yAn, yA, yAcAk, yAsH, yHncA, yHp, yAlH, yArAk, yAdur, yHver, yAgel, yAgor,
190
+ * yAbil, yAyaz, yAkal, yAkoy, yAmA, yHcH, HCH, Hr, Hs, Hn, yHn", yHnHz, Ar, Hl").
191
+ *
192
+ * @param root {@link TxtWord} input.
193
+ * @param startState {@link State} input.
194
+ * @return true if there is softening during suffixation of the given root, false otherwise.
195
+ */
196
+ softenDuringSuffixation(root, startState) {
197
+ if (!startState.getName().startsWith("VerbalRoot") && (root.isNominal() || root.isAdjective()) && root.nounSoftenDuringSuffixation() &&
198
+ (this._with == "Hm" || this._with == "nDAn" || this._with == "ncA" || this._with == "nDA" ||
199
+ this._with == "yA" || this._with == "yHm" || this._with == "yHz" || this._with == "yH" ||
200
+ this._with == "nH" || this._with == "nA" || this._with == "nHn" || this._with == "H" ||
201
+ this._with == "sH" || this._with == "Hn" || this._with == "HnHz" || this._with == "HmHz")) {
202
+ return true;
203
+ }
204
+ if (startState.getName().startsWith("VerbalRoot") && root.isVerb() && root.verbSoftenDuringSuffixation() &&
205
+ (this._with.startsWith("Hyor") || this._with == "yHs" || this._with == "yAn" || this._with == "yA" ||
206
+ this._with.startsWith("yAcAk") || this._with == "yAsH" || this._with == "yHncA" || this._with == "yHp" ||
207
+ this._with == "yAlH" || this._with == "yArAk" || this._with == "yAdur" || this._with == "yHver" ||
208
+ this._with == "yAgel" || this._with == "yAgor" || this._with == "yAbil" || this._with == "yAyaz" ||
209
+ this._with == "yAkal" || this._with == "yAkoy" || this._with == "yAmA" || this._with == "yHcH" ||
210
+ this._with == "HCH" || this._with.startsWith("Hr") || this._with == "Hs" || this._with == "Hn" ||
211
+ this._with == "yHn" || this._with == "yHnHz" || this._with.startsWith("Ar") || this._with == "Hl")) {
212
+ return true;
213
+ }
214
+ return false;
215
+ }
216
+ /**
217
+ * The method is main driving method to accomplish the current transition from one state to another depending on
218
+ * the root form of the word, current value of the word form, and the type of the start state. The method
219
+ * (a) returns the original word form if the transition is an epsilon transition, (b) adds 'nunla' if the current
220
+ * stem is 'bu', 'şu' or 'o', (c) returns 'bana' or 'sana' if the current stem is 'ben' or 'sen' respectively.
221
+ * For other cases, the method first modifies current stem and then adds the transition using special metamorpheme
222
+ * resolving methods. These cases are: (d) Converts 'y' of the first character of the transition to 'i' if the
223
+ * current stem is 'ye' or 'de'. (e) Drops the last two characters and adds last character when the transition is
224
+ * ('Hl' or 'Hn') and last 'I' drops during passive suffixation. (f) Adds 'y' character when the word ends with 'su'
225
+ * and the transition does not start with 'y'. (g) Adds the last character again when the root duplicates during
226
+ * suffixation. (h) Drops the last two characters and adds the last character when last 'i' drops during
227
+ * suffixation. (i) Replaces the last character with a soft one when the root soften during suffixation.
228
+ * @param root Root of the current word form
229
+ * @param stem Current word form
230
+ * @param startState The state from which this Fsm morphological analysis search has started.
231
+ * @return The current value of the word form after this transition is completed in the finite state machine.
232
+ */
233
+ makeTransition(root, stem, startState) {
234
+ if (startState == undefined) {
235
+ if (root.isVerb()) {
236
+ return this.makeTransition(root, stem, new State_1.State("VerbalRoot", true, false));
186
237
  }
187
- if (this.withFirstChar() == 'A' || this.withFirstChar() == 'H' || TurkishLanguage_1.TurkishLanguage.isVowel(this.withFirstChar())) {
188
- return true;
238
+ else {
239
+ return this.makeTransition(root, stem, new State_1.State("NominalRoot", true, false));
189
240
  }
190
- return false;
191
241
  }
192
- /**
193
- * The softenDuringSuffixation method takes a {@link TxtWord} root as an input. It checks two cases; first case returns
194
- * 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
195
- * equals o one of the Strings "Hm, nDAn, ncA, nDA, yA, yHm, yHz, yH, nH, nA, nHn, H, sH, Hn, HnHz, HmHz".
196
- * <p>
197
- * And the second case returns true if the given root is verb and has the "F_SD" flag, also with variable starts with
198
- * "Hyor" or equals one of the Strings "yHs, yAn, yA, yAcAk, yAsH, yHncA, yHp, yAlH, yArAk, yAdur, yHver, yAgel, yAgor,
199
- * yAbil, yAyaz, yAkal, yAkoy, yAmA, yHcH, HCH, Hr, Hs, Hn, yHn", yHnHz, Ar, Hl").
200
- *
201
- * @param root {@link TxtWord} input.
202
- * @param startState {@link State} input.
203
- * @return true if there is softening during suffixation of the given root, false otherwise.
204
- */
205
- softenDuringSuffixation(root, startState) {
206
- if (!startState.getName().startsWith("VerbalRoot") && (root.isNominal() || root.isAdjective()) && root.nounSoftenDuringSuffixation() &&
207
- (this._with == "Hm" || this._with == "nDAn" || this._with == "ncA" || this._with == "nDA" ||
208
- this._with == "yA" || this._with == "yHm" || this._with == "yHz" || this._with == "yH" ||
209
- this._with == "nH" || this._with == "nA" || this._with == "nHn" || this._with == "H" ||
210
- this._with == "sH" || this._with == "Hn" || this._with == "HnHz" || this._with == "HmHz")) {
211
- return true;
242
+ else {
243
+ let rootWord = root.getName() == stem || (root.getName() + "'") == stem;
244
+ let formation = stem;
245
+ let i = 0;
246
+ if (this._with == "0") {
247
+ return stem;
212
248
  }
213
- if (startState.getName().startsWith("VerbalRoot") && root.isVerb() && root.verbSoftenDuringSuffixation() &&
214
- (this._with.startsWith("Hyor") || this._with == "yHs" || this._with == "yAn" || this._with == "yA" ||
215
- this._with.startsWith("yAcAk") || this._with == "yAsH" || this._with == "yHncA" || this._with == "yHp" ||
216
- this._with == "yAlH" || this._with == "yArAk" || this._with == "yAdur" || this._with == "yHver" ||
217
- this._with == "yAgel" || this._with == "yAgor" || this._with == "yAbil" || this._with == "yAyaz" ||
218
- this._with == "yAkal" || this._with == "yAkoy" || this._with == "yAmA" || this._with == "yHcH" ||
219
- this._with == "HCH" || this._with.startsWith("Hr") || this._with == "Hs" || this._with == "Hn" ||
220
- this._with == "yHn" || this._with == "yHnHz" || this._with.startsWith("Ar") || this._with == "Hl")) {
221
- return true;
249
+ if ((stem == "bu" || stem == "şu" || stem == "o") && rootWord && this._with == "ylA") {
250
+ return stem + "nunla";
222
251
  }
223
- return false;
224
- }
225
- /**
226
- * The method is main driving method to accomplish the current transition from one state to another depending on
227
- * the root form of the word, current value of the word form, and the type of the start state. The method
228
- * (a) returns the original word form if the transition is an epsilon transition, (b) adds 'nunla' if the current
229
- * stem is 'bu', 'şu' or 'o', (c) returns 'bana' or 'sana' if the current stem is 'ben' or 'sen' respectively.
230
- * For other cases, the method first modifies current stem and then adds the transition using special metamorpheme
231
- * resolving methods. These cases are: (d) Converts 'y' of the first character of the transition to 'i' if the
232
- * current stem is 'ye' or 'de'. (e) Drops the last two characters and adds last character when the transition is
233
- * ('Hl' or 'Hn') and last 'I' drops during passive suffixation. (f) Adds 'y' character when the word ends with 'su'
234
- * and the transition does not start with 'y'. (g) Adds the last character again when the root duplicates during
235
- * suffixation. (h) Drops the last two characters and adds the last character when last 'i' drops during
236
- * suffixation. (i) Replaces the last character with a soft one when the root soften during suffixation.
237
- * @param root Root of the current word form
238
- * @param stem Current word form
239
- * @param startState The state from which this Fsm morphological analysis search has started.
240
- * @return The current value of the word form after this transition is completed in the finite state machine.
241
- */
242
- makeTransition(root, stem, startState) {
243
- if (startState == undefined) {
244
- if (root.isVerb()) {
245
- return this.makeTransition(root, stem, new State_1.State("VerbalRoot", true, false));
252
+ if (this._with == "yA") {
253
+ if (stem == "ben") {
254
+ return "bana";
246
255
  }
247
- else {
248
- return this.makeTransition(root, stem, new State_1.State("NominalRoot", true, false));
256
+ if (stem == "sen") {
257
+ return "sana";
249
258
  }
250
259
  }
260
+ let formationToCheck;
261
+ //---vowelEChangesToIDuringYSuffixation---
262
+ //de->d(i)yor, ye->y(i)yor
263
+ if (rootWord && this.withFirstChar() == 'y' && root.vowelEChangesToIDuringYSuffixation() &&
264
+ (this._with.charAt(1) != 'H' || root.getName() == "ye")) {
265
+ formation = stem.substring(0, stem.length - 1) + 'i';
266
+ formationToCheck = formation;
267
+ }
251
268
  else {
252
- let rootWord = root.getName() == stem || (root.getName() + "'") == stem;
253
- let formation = stem;
254
- let i = 0;
255
- if (this._with == "0") {
256
- return stem;
257
- }
258
- if ((stem == "bu" || stem == "şu" || stem == "o") && rootWord && this._with == "ylA") {
259
- return stem + "nunla";
260
- }
261
- if (this._with == "yA") {
262
- if (stem == "ben") {
263
- return "bana";
264
- }
265
- if (stem == "sen") {
266
- return "sana";
267
- }
268
- }
269
- let formationToCheck;
270
- //---vowelEChangesToIDuringYSuffixation---
271
- //de->d(i)yor, ye->y(i)yor
272
- if (rootWord && this.withFirstChar() == 'y' && root.vowelEChangesToIDuringYSuffixation() &&
273
- (this._with.charAt(1) != 'H' || root.getName() == "ye")) {
274
- formation = stem.substring(0, stem.length - 1) + 'i';
275
- formationToCheck = formation;
269
+ //---lastIdropsDuringPassiveSuffixation---
270
+ // yoğur->yoğrul, ayır->ayrıl, buyur->buyrul, çağır->çağrıl, çevir->çevril, devir->devril,
271
+ // kavur->kavrul, kayır->kayrıl, kıvır->kıvrıl, savur->savrul, sıyır->sıyrıl, yoğur->yoğrul
272
+ if (rootWord && (this._with == "Hl" || this._with == "Hn") && root.lastIdropsDuringPassiveSuffixation()) {
273
+ formation = stem.substring(0, stem.length - 2) + stem.charAt(stem.length - 1);
274
+ formationToCheck = stem;
276
275
  }
277
276
  else {
278
- //---lastIdropsDuringPassiveSuffixation---
279
- // yoğur->yoğrul, ayır->ayrıl, buyur->buyrul, çağır->çağrıl, çevir->çevril, devir->devril,
280
- // kavur->kavrul, kayır->kayrıl, kıvır->kıvrıl, savur->savrul, sıyır->sıyrıl, yoğur->yoğrul
281
- if (rootWord && (this._with == "Hl" || this._with == "Hn") && root.lastIdropsDuringPassiveSuffixation()) {
282
- formation = stem.substring(0, stem.length - 2) + stem.charAt(stem.length - 1);
283
- formationToCheck = stem;
277
+ //---showsSuRegularities---
278
+ //karasu->karasuyu, su->suyu, ağırsu->ağırsuyu, akarsu->akarsuyu, bengisu->bengisuyu
279
+ if (rootWord && root.showsSuRegularities() && this.startWithVowelorConsonantDrops()) {
280
+ formation = stem + 'y';
281
+ i = 1;
282
+ formationToCheck = formation;
284
283
  }
285
284
  else {
286
- //---showsSuRegularities---
287
- //karasu->karasuyu, su->suyu, ağırsu->ağırsuyu, akarsu->akarsuyu, bengisu->bengisuyu
288
- if (rootWord && root.showsSuRegularities() && this.startWithVowelorConsonantDrops()) {
289
- formation = stem + 'y';
290
- i = 1;
285
+ if (rootWord && root.duplicatesDuringSuffixation() && !startState.getName().startsWith("VerbalRoot") &&
286
+ TurkishLanguage_1.TurkishLanguage.isConsonantDrop(this._with.charAt(0))) {
287
+ //---duplicatesDuringSuffixation---
288
+ if (this.softenDuringSuffixation(root, startState)) {
289
+ //--extra softenDuringSuffixation
290
+ switch (Word_1.Word.lastPhoneme(stem)) {
291
+ case 'p':
292
+ //tıp->tıbbı
293
+ formation = stem.substring(0, stem.length - 1) + "bb";
294
+ break;
295
+ case 't':
296
+ //cet->ceddi, met->meddi, ret->reddi, serhat->serhaddi, zıt->zıddı, şet->şeddi
297
+ formation = stem.substring(0, stem.length - 1) + "dd";
298
+ break;
299
+ }
300
+ }
301
+ else {
302
+ //cer->cerri, emrihak->emrihakkı, fek->fekki, fen->fenni, had->haddi, hat->hattı,
303
+ // haz->hazzı, his->hissi
304
+ formation = stem + stem.charAt(stem.length - 1);
305
+ }
291
306
  formationToCheck = formation;
292
307
  }
293
308
  else {
294
- if (rootWord && root.duplicatesDuringSuffixation() && !startState.getName().startsWith("VerbalRoot") &&
295
- TurkishLanguage_1.TurkishLanguage.isConsonantDrop(this._with.charAt(0))) {
296
- //---duplicatesDuringSuffixation---
309
+ if (rootWord && root.lastIdropsDuringSuffixation() &&
310
+ !startState.getName().startsWith("VerbalRoot") && !startState.getName().startsWith("ProperRoot") &&
311
+ this.startWithVowelorConsonantDrops()) {
312
+ //---lastIdropsDuringSuffixation---
297
313
  if (this.softenDuringSuffixation(root, startState)) {
298
- //--extra softenDuringSuffixation
314
+ //---softenDuringSuffixation---
299
315
  switch (Word_1.Word.lastPhoneme(stem)) {
300
316
  case 'p':
301
- //tıp->tıbbı
302
- formation = stem.substring(0, stem.length - 1) + "bb";
317
+ //hizip->hizbi, kayıp->kaybı, kayıt->kaydı, kutup->kutbu
318
+ formation = stem.substring(0, stem.length - 2) + 'b';
303
319
  break;
304
320
  case 't':
305
- //cet->ceddi, met->meddi, ret->reddi, serhat->serhaddi, zıt->zıddı, şet->şeddi
306
- formation = stem.substring(0, stem.length - 1) + "dd";
321
+ //akit->akdi, ahit->ahdi, lahit->lahdi, nakit->nakdi, vecit->vecdi
322
+ formation = stem.substring(0, stem.length - 2) + 'd';
323
+ break;
324
+ case 'ç':
325
+ //eviç->evci, nesiç->nesci
326
+ formation = stem.substring(0, stem.length - 2) + 'c';
307
327
  break;
308
328
  }
309
329
  }
310
330
  else {
311
- //cer->cerri, emrihak->emrihakkı, fek->fekki, fen->fenni, had->haddi, hat->hattı,
312
- // haz->hazzı, his->hissi
313
- formation = stem + stem.charAt(stem.length - 1);
331
+ //sarıağız->sarıağzı, zehir->zehri, zikir->zikri, nutuk->nutku, omuz->omzu, ömür->ömrü
332
+ //lütuf->lütfu, metin->metni, kavim->kavmi, kasıt->kastı
333
+ formation = stem.substring(0, stem.length - 2) + stem.charAt(stem.length - 1);
314
334
  }
315
- formationToCheck = formation;
335
+ formationToCheck = stem;
316
336
  }
317
337
  else {
318
- if (rootWord && root.lastIdropsDuringSuffixation() &&
319
- !startState.getName().startsWith("VerbalRoot") && !startState.getName().startsWith("ProperRoot") &&
320
- this.startWithVowelorConsonantDrops()) {
321
- //---lastIdropsDuringSuffixation---
322
- if (this.softenDuringSuffixation(root, startState)) {
323
- //---softenDuringSuffixation---
324
- switch (Word_1.Word.lastPhoneme(stem)) {
325
- case 'p':
326
- //hizip->hizbi, kayıp->kaybı, kayıt->kaydı, kutup->kutbu
327
- formation = stem.substring(0, stem.length - 2) + 'b';
328
- break;
329
- case 't':
330
- //akit->akdi, ahit->ahdi, lahit->lahdi, nakit->nakdi, vecit->vecdi
331
- formation = stem.substring(0, stem.length - 2) + 'd';
332
- break;
333
- case 'ç':
334
- //eviç->evci, nesiç->nesci
335
- formation = stem.substring(0, stem.length - 2) + 'c';
336
- break;
338
+ switch (Word_1.Word.lastPhoneme(stem)) {
339
+ //---nounSoftenDuringSuffixation or verbSoftenDuringSuffixation
340
+ case 'p':
341
+ //adap->adabı, amip->amibi, azap->azabı, gazap->gazabı
342
+ if (this.startWithVowelorConsonantDrops() && rootWord && this.softenDuringSuffixation(root, startState)) {
343
+ formation = stem.substring(0, stem.length - 1) + 'b';
337
344
  }
338
- }
339
- else {
340
- //sarıağız->sarıağzı, zehir->zehri, zikir->zikri, nutuk->nutku, omuz->omzu, ömür->ömrü
341
- //lütuf->lütfu, metin->metni, kavim->kavmi, kasıt->kastı
342
- formation = stem.substring(0, stem.length - 2) + stem.charAt(stem.length - 1);
343
- }
344
- formationToCheck = stem;
345
- }
346
- else {
347
- switch (Word_1.Word.lastPhoneme(stem)) {
348
- //---nounSoftenDuringSuffixation or verbSoftenDuringSuffixation
349
- case 'p':
350
- //adap->adabı, amip->amibi, azap->azabı, gazap->gazabı
351
- if (this.startWithVowelorConsonantDrops() && rootWord && this.softenDuringSuffixation(root, startState)) {
352
- formation = stem.substring(0, stem.length - 1) + 'b';
353
- }
354
- break;
355
- case 't':
356
- //adet->adedi, akort->akordu, armut->armudu
357
- //affet->affedi, yoket->yokedi, sabret->sabredi, rakset->raksedi
358
- if (this.startWithVowelorConsonantDrops() && rootWord && this.softenDuringSuffixation(root, startState)) {
359
- formation = stem.substring(0, stem.length - 1) + 'd';
360
- }
361
- break;
362
- case 'ç':
363
- //ağaç->ağacı, almaç->almacı, akaç->akacı, avuç->avucu
364
- if (this.startWithVowelorConsonantDrops() && rootWord && this.softenDuringSuffixation(root, startState)) {
365
- formation = stem.substring(0, stem.length - 1) + 'c';
366
- }
367
- break;
368
- case 'g':
369
- //arkeolog->arkeoloğu, filolog->filoloğu, minerolog->mineroloğu
370
- if (this.startWithVowelorConsonantDrops() && rootWord && this.softenDuringSuffixation(root, startState)) {
345
+ break;
346
+ case 't':
347
+ //adet->adedi, akort->akordu, armut->armudu
348
+ //affet->affedi, yoket->yokedi, sabret->sabredi, rakset->raksedi
349
+ if (this.startWithVowelorConsonantDrops() && rootWord && this.softenDuringSuffixation(root, startState)) {
350
+ formation = stem.substring(0, stem.length - 1) + 'd';
351
+ }
352
+ break;
353
+ case 'ç':
354
+ //ağaç->ağacı, almaç->almacı, akaç->akacı, avuç->avucu
355
+ if (this.startWithVowelorConsonantDrops() && rootWord && this.softenDuringSuffixation(root, startState)) {
356
+ formation = stem.substring(0, stem.length - 1) + 'c';
357
+ }
358
+ break;
359
+ case 'g':
360
+ //arkeolog->arkeoloğu, filolog->filoloğu, minerolog->mineroloğu
361
+ if (this.startWithVowelorConsonantDrops() && rootWord && this.softenDuringSuffixation(root, startState)) {
362
+ formation = stem.substring(0, stem.length - 1) + 'ğ';
363
+ }
364
+ break;
365
+ case 'k':
366
+ //ahenk->ahengi, künk->küngü, renk->rengi, pelesenk->pelesengi
367
+ if (this.startWithVowelorConsonantDrops() && rootWord && root.endingKChangesIntoG() &&
368
+ (!root.isProperNoun() || startState.toString() != "ProperRoot")) {
369
+ formation = stem.substring(0, stem.length - 1) + 'g';
370
+ }
371
+ else {
372
+ //ablak->ablağı, küllük->küllüğü, kitaplık->kitaplığı, evcilik->evciliği
373
+ if (this.startWithVowelorConsonantDrops() && (!rootWord ||
374
+ (this.softenDuringSuffixation(root, startState) && (!root.isProperNoun() ||
375
+ startState.toString() != "ProperRoot")))) {
371
376
  formation = stem.substring(0, stem.length - 1) + 'ğ';
372
377
  }
373
- break;
374
- case 'k':
375
- //ahenk->ahengi, künk->küngü, renk->rengi, pelesenk->pelesengi
376
- if (this.startWithVowelorConsonantDrops() && rootWord && root.endingKChangesIntoG() &&
377
- (!root.isProperNoun() || startState.toString() != "ProperRoot")) {
378
- formation = stem.substring(0, stem.length - 1) + 'g';
379
- }
380
- else {
381
- //ablak->ablağı, küllük->küllüğü, kitaplık->kitaplığı, evcilik->evciliği
382
- if (this.startWithVowelorConsonantDrops() && (!rootWord ||
383
- (this.softenDuringSuffixation(root, startState) && (!root.isProperNoun() ||
384
- startState.toString() != "ProperRoot")))) {
385
- formation = stem.substring(0, stem.length - 1) + 'ğ';
386
- }
387
- }
388
- break;
389
- }
390
- formationToCheck = formation;
378
+ }
379
+ break;
391
380
  }
381
+ formationToCheck = formation;
392
382
  }
393
383
  }
394
384
  }
395
385
  }
396
- if (TurkishLanguage_1.TurkishLanguage.isConsonantDrop(this.withFirstChar()) &&
397
- !TurkishLanguage_1.TurkishLanguage.isVowel(stem.charAt(stem.length - 1)) &&
398
- (root.isNumeral() || root.isReal() || root.isFraction() || root.isTime() || root.isDate() ||
399
- root.isPercent() || root.isRange()) && (root.getName().endsWith("1") || root.getName().endsWith("3") ||
400
- root.getName().endsWith("4") || root.getName().endsWith("5") || root.getName().endsWith("8") ||
401
- root.getName().endsWith("9") || root.getName().endsWith("10") || root.getName().endsWith("30") ||
402
- root.getName().endsWith("40") || root.getName().endsWith("60") || root.getName().endsWith("70") ||
403
- root.getName().endsWith("80") || root.getName().endsWith("90") || root.getName().endsWith("00"))) {
386
+ }
387
+ if (TurkishLanguage_1.TurkishLanguage.isConsonantDrop(this.withFirstChar()) &&
388
+ !TurkishLanguage_1.TurkishLanguage.isVowel(stem.charAt(stem.length - 1)) &&
389
+ (root.isNumeral() || root.isReal() || root.isFraction() || root.isTime() || root.isDate() ||
390
+ root.isPercent() || root.isRange()) && (root.getName().endsWith("1") || root.getName().endsWith("3") ||
391
+ root.getName().endsWith("4") || root.getName().endsWith("5") || root.getName().endsWith("8") ||
392
+ root.getName().endsWith("9") || root.getName().endsWith("10") || root.getName().endsWith("30") ||
393
+ root.getName().endsWith("40") || root.getName().endsWith("60") || root.getName().endsWith("70") ||
394
+ root.getName().endsWith("80") || root.getName().endsWith("90") || root.getName().endsWith("00"))) {
395
+ if (this._with.charAt(0) == '\'') {
396
+ formation = formation + '\'';
397
+ i = 2;
398
+ }
399
+ else {
400
+ i = 1;
401
+ }
402
+ }
403
+ else {
404
+ if ((TurkishLanguage_1.TurkishLanguage.isConsonantDrop(this.withFirstChar()) && TurkishLanguage_1.TurkishLanguage.isConsonant(Word_1.Word.lastPhoneme(stem))) ||
405
+ (rootWord && root.consonantSMayInsertedDuringPossesiveSuffixation())) {
404
406
  if (this._with.charAt(0) == '\'') {
405
407
  formation = formation + '\'';
406
- i = 2;
408
+ if (root.isAbbreviation())
409
+ i = 1;
410
+ else
411
+ i = 2;
407
412
  }
408
413
  else {
409
414
  i = 1;
410
415
  }
411
416
  }
412
- else {
413
- if ((TurkishLanguage_1.TurkishLanguage.isConsonantDrop(this.withFirstChar()) && TurkishLanguage_1.TurkishLanguage.isConsonant(Word_1.Word.lastPhoneme(stem))) ||
414
- (rootWord && root.consonantSMayInsertedDuringPossesiveSuffixation())) {
415
- if (this._with.charAt(0) == '\'') {
416
- formation = formation + '\'';
417
- if (root.isAbbreviation())
418
- i = 1;
419
- else
420
- i = 2;
417
+ }
418
+ for (; i < this._with.length; i++) {
419
+ switch (this._with.charAt(i)) {
420
+ case 'D':
421
+ formation = MorphotacticEngine_1.MorphotacticEngine.resolveD(root, formation, formationToCheck);
422
+ break;
423
+ case 'A':
424
+ formation = MorphotacticEngine_1.MorphotacticEngine.resolveA(root, formation, rootWord, formationToCheck);
425
+ break;
426
+ case 'H':
427
+ if (this._with.charAt(0) != '\'') {
428
+ formation = MorphotacticEngine_1.MorphotacticEngine.resolveH(root, formation, i == 0, this._with.startsWith("Hyor"), rootWord, formationToCheck);
421
429
  }
422
430
  else {
423
- i = 1;
431
+ formation = MorphotacticEngine_1.MorphotacticEngine.resolveH(root, formation, i == 1, false, rootWord, formationToCheck);
432
+ }
433
+ rootWord = false;
434
+ break;
435
+ case 'C':
436
+ formation = MorphotacticEngine_1.MorphotacticEngine.resolveC(formation, formationToCheck);
437
+ break;
438
+ case 'S':
439
+ formation = MorphotacticEngine_1.MorphotacticEngine.resolveS(formation);
440
+ break;
441
+ case 'Ş':
442
+ formation = MorphotacticEngine_1.MorphotacticEngine.resolveSh(formation);
443
+ break;
444
+ default:
445
+ if (i == this._with.length - 1 && this._with.charAt(i) == 's') {
446
+ formation += 'ş';
447
+ }
448
+ else {
449
+ formation += this._with.charAt(i);
424
450
  }
425
- }
426
- }
427
- for (; i < this._with.length; i++) {
428
- switch (this._with.charAt(i)) {
429
- case 'D':
430
- formation = MorphotacticEngine_1.MorphotacticEngine.resolveD(root, formation, formationToCheck);
431
- break;
432
- case 'A':
433
- formation = MorphotacticEngine_1.MorphotacticEngine.resolveA(root, formation, rootWord, formationToCheck);
434
- break;
435
- case 'H':
436
- if (this._with.charAt(0) != '\'') {
437
- formation = MorphotacticEngine_1.MorphotacticEngine.resolveH(root, formation, i == 0, this._with.startsWith("Hyor"), rootWord, formationToCheck);
438
- }
439
- else {
440
- formation = MorphotacticEngine_1.MorphotacticEngine.resolveH(root, formation, i == 1, false, rootWord, formationToCheck);
441
- }
442
- rootWord = false;
443
- break;
444
- case 'C':
445
- formation = MorphotacticEngine_1.MorphotacticEngine.resolveC(formation, formationToCheck);
446
- break;
447
- case 'S':
448
- formation = MorphotacticEngine_1.MorphotacticEngine.resolveS(formation);
449
- break;
450
- case 'Ş':
451
- formation = MorphotacticEngine_1.MorphotacticEngine.resolveSh(formation);
452
- break;
453
- default:
454
- if (i == this._with.length - 1 && this._with.charAt(i) == 's') {
455
- formation += 'ş';
456
- }
457
- else {
458
- formation += this._with.charAt(i);
459
- }
460
- }
461
- formationToCheck = formation;
462
451
  }
463
- return formation;
452
+ formationToCheck = formation;
464
453
  }
454
+ return formation;
465
455
  }
466
- /**
467
- * An overridden toString method which returns the with variable.
468
- *
469
- * @return with variable.
470
- */
471
- toString() {
472
- return this._with;
473
- }
474
- /**
475
- * The with method returns the withName variable.
476
- *
477
- * @return the withName variable.
478
- */
479
- getWith() {
480
- return this.withName;
481
- }
482
456
  }
483
- exports.Transition = Transition;
484
- });
457
+ /**
458
+ * An overridden toString method which returns the with variable.
459
+ *
460
+ * @return with variable.
461
+ */
462
+ toString() {
463
+ return this._with;
464
+ }
465
+ /**
466
+ * The with method returns the withName variable.
467
+ *
468
+ * @return the withName variable.
469
+ */
470
+ getWith() {
471
+ return this.withName;
472
+ }
473
+ }
474
+ exports.Transition = Transition;
485
475
  //# sourceMappingURL=Transition.js.map