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,50 +1,53 @@
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", "./MorphologicalParse", "nlptoolkit-dictionary/dist/Dictionary/TxtWord", "./InflectionalGroup", "./Transition"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.FsmParse = void 0;
13
- const MorphologicalParse_1 = require("./MorphologicalParse");
14
- const TxtWord_1 = require("nlptoolkit-dictionary/dist/Dictionary/TxtWord");
15
- const InflectionalGroup_1 = require("./InflectionalGroup");
16
- const Transition_1 = require("./Transition");
17
- class FsmParse extends MorphologicalParse_1.MorphologicalParse {
18
- /**
19
- * Another constructor of {@link FsmParse} class which takes a {@link TxtWord} root and a {@link State} as inputs.
20
- * First, initializes root variable with this {@link TxtWord}. It also initializes form with root's name, pos and
21
- * initialPos with given {@link State}'s POS, creates 4 new {@link Array} suffixList, formList, transitionList
22
- * and withList and adds given {@link State} to suffixList, form to formList.
23
- *
24
- * @param root {@link TxtWord} input.
25
- * @param startState {@link State} input.
26
- */
27
- constructor(root, startState) {
28
- super();
29
- this.suffixList = new Array();
30
- this.formList = new Array();
31
- this.transitionList = new Array();
32
- this.withList = new Array();
33
- this.verbAgreement = undefined;
34
- this.possesiveAgreement = undefined;
35
- if (root instanceof TxtWord_1.TxtWord && startState != undefined) {
36
- this.root = root;
37
- this.form = root.getName();
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FsmParse = void 0;
4
+ const MorphologicalParse_1 = require("./MorphologicalParse");
5
+ const TxtWord_1 = require("nlptoolkit-dictionary/dist/Dictionary/TxtWord");
6
+ const InflectionalGroup_1 = require("./InflectionalGroup");
7
+ const Transition_1 = require("./Transition");
8
+ class FsmParse extends MorphologicalParse_1.MorphologicalParse {
9
+ suffixList = new Array();
10
+ formList = new Array();
11
+ transitionList = new Array();
12
+ withList = new Array();
13
+ initialPos;
14
+ pos;
15
+ form;
16
+ verbAgreement = undefined;
17
+ possesiveAgreement = undefined;
18
+ /**
19
+ * Another constructor of {@link FsmParse} class which takes a {@link TxtWord} root and a {@link State} as inputs.
20
+ * First, initializes root variable with this {@link TxtWord}. It also initializes form with root's name, pos and
21
+ * initialPos with given {@link State}'s POS, creates 4 new {@link Array} suffixList, formList, transitionList
22
+ * and withList and adds given {@link State} to suffixList, form to formList.
23
+ *
24
+ * @param root {@link TxtWord} input.
25
+ * @param startState {@link State} input.
26
+ */
27
+ constructor(root, startState) {
28
+ super();
29
+ if (root instanceof TxtWord_1.TxtWord && startState != undefined) {
30
+ this.root = root;
31
+ this.form = root.getName();
32
+ this.pos = startState.getPos();
33
+ this.initialPos = startState.getPos();
34
+ this.suffixList.push(startState);
35
+ this.formList.push(this.form);
36
+ }
37
+ else {
38
+ if (!Number.isNaN(root) && startState != undefined) {
39
+ let num = new TxtWord_1.TxtWord(root + "");
40
+ num.addFlag("IS_SAYI");
41
+ this.root = num;
42
+ this.form = this.root.getName();
38
43
  this.pos = startState.getPos();
39
44
  this.initialPos = startState.getPos();
40
45
  this.suffixList.push(startState);
41
46
  this.formList.push(this.form);
42
47
  }
43
48
  else {
44
- if (!Number.isNaN(root) && startState != undefined) {
45
- let num = new TxtWord_1.TxtWord(root + "");
46
- num.addFlag("IS_SAYI");
47
- this.root = num;
49
+ if (startState != undefined) {
50
+ this.root = new TxtWord_1.TxtWord(root);
48
51
  this.form = this.root.getName();
49
52
  this.pos = startState.getPos();
50
53
  this.initialPos = startState.getPos();
@@ -52,560 +55,550 @@
52
55
  this.formList.push(this.form);
53
56
  }
54
57
  else {
55
- if (startState != undefined) {
56
- this.root = new TxtWord_1.TxtWord(root);
57
- this.form = this.root.getName();
58
- this.pos = startState.getPos();
59
- this.initialPos = startState.getPos();
60
- this.suffixList.push(startState);
61
- this.formList.push(this.form);
62
- }
63
- else {
64
- this.root = root;
65
- }
58
+ this.root = root;
66
59
  }
67
60
  }
68
61
  }
69
- /**
70
- * The constructInflectionalGroups method initially calls the transitionList method and assigns the resulting {@link String}
71
- * to the parse variable and creates a new {@link Array} as iGs. If parse {@link String} contains a derivational boundary
72
- * it adds the substring starting from the 0 to the index of derivational boundary to the iGs. If it does not contain a DB,
73
- * it directly adds parse to the iGs. Then, creates and initializes new {@link Array} as inflectionalGroups and fills with
74
- * the items of iGs.
75
- */
76
- constructInflectionalGroups() {
77
- let parse = this.getFsmParseTransitionList();
78
- let iGs = new Array();
79
- while (parse.includes("^DB+")) {
80
- iGs.push(parse.substring(0, parse.indexOf("^DB+")));
81
- parse = parse.substring(parse.indexOf("^DB+") + 4);
82
- }
83
- iGs.push(parse);
84
- this.inflectionalGroups.push(new InflectionalGroup_1.InflectionalGroup(iGs[0].substring(iGs[0].indexOf('+') + 1)));
85
- for (let i = 1; i < iGs.length; i++) {
86
- this.inflectionalGroups.push(new InflectionalGroup_1.InflectionalGroup(iGs[i]));
87
- }
62
+ }
63
+ /**
64
+ * The constructInflectionalGroups method initially calls the transitionList method and assigns the resulting {@link String}
65
+ * to the parse variable and creates a new {@link Array} as iGs. If parse {@link String} contains a derivational boundary
66
+ * it adds the substring starting from the 0 to the index of derivational boundary to the iGs. If it does not contain a DB,
67
+ * it directly adds parse to the iGs. Then, creates and initializes new {@link Array} as inflectionalGroups and fills with
68
+ * the items of iGs.
69
+ */
70
+ constructInflectionalGroups() {
71
+ let parse = this.getFsmParseTransitionList();
72
+ let iGs = new Array();
73
+ while (parse.includes("^DB+")) {
74
+ iGs.push(parse.substring(0, parse.indexOf("^DB+")));
75
+ parse = parse.substring(parse.indexOf("^DB+") + 4);
88
76
  }
89
- /**
90
- * Getter for the verbAgreement variable.
91
- *
92
- * @return the verbAgreement variable.
93
- */
94
- getVerbAgreement() {
95
- return this.verbAgreement;
96
- }
97
- /**
98
- * Getter for the getPossesiveAgreement variable.
99
- *
100
- * @return the possesiveAgreement variable.
101
- */
102
- getPossesiveAgreement() {
103
- return this.possesiveAgreement;
104
- }
105
- /**
106
- * The setAgreement method takes a {@link String} transitionName as an input and if it is one of the A1SG, A2SG, A3SG,
107
- * A1PL, A2PL or A3PL it assigns transitionName input to the verbAgreement variable. Or if it is ine of the PNON, P1SG, P2SG,P3SG,
108
- * P1PL, P2PL or P3PL it assigns transitionName input to the possesiveAgreement variable.
109
- *
110
- * @param transitionName {@link String} input.
111
- */
112
- setAgreement(transitionName) {
113
- if (transitionName != undefined && (transitionName == "A1SG" || transitionName == "A2SG" ||
114
- transitionName == "A3SG" || transitionName == "A1PL" || transitionName == "A2PL" ||
115
- transitionName == "A3PL")) {
116
- this.verbAgreement = transitionName;
117
- }
118
- if (transitionName != undefined && (transitionName == "PNON" || transitionName == "P1SG" ||
119
- transitionName == "P2SG" || transitionName == "P3SG" || transitionName == "P1PL" ||
120
- transitionName == "P2PL" || transitionName == "P3PL")) {
121
- this.possesiveAgreement = transitionName;
122
- }
77
+ iGs.push(parse);
78
+ this.inflectionalGroups.push(new InflectionalGroup_1.InflectionalGroup(iGs[0].substring(iGs[0].indexOf('+') + 1)));
79
+ for (let i = 1; i < iGs.length; i++) {
80
+ this.inflectionalGroups.push(new InflectionalGroup_1.InflectionalGroup(iGs[i]));
123
81
  }
124
- /**
125
- * The getLastLemmaWithTag method takes a String input pos as an input. If given pos is an initial pos then it assigns
126
- * root to the lemma, and assign null otherwise. Then, it loops i times where i ranges from 1 to size of the formList,
127
- * if the item at i-1 of transitionList is not null and contains a derivational boundary with pos but not with ZERO,
128
- * it assigns the ith item of formList to lemma.
129
- *
130
- * @param pos {@link String} input.
131
- * @return String output lemma.
132
- */
133
- getLastLemmaWithTag(pos) {
134
- let lemma;
135
- if (this.initialPos != undefined && this.initialPos == pos) {
136
- lemma = this.root.getName();
137
- }
138
- else {
139
- lemma = undefined;
140
- }
141
- for (let i = 1; i < this.formList.length; i++) {
142
- if (this.transitionList[i - 1] != undefined && this.transitionList[i - 1].includes("^DB+" + pos) &&
143
- !this.transitionList[i - 1].includes("^DB+" + pos + "+ZERO")) {
144
- lemma = this.formList[i];
145
- }
146
- }
147
- return lemma;
148
- }
149
- /**
150
- * The getLastLemma method initially assigns root as lemma. Then, it loops i times where i ranges from 1 to size of the formList,
151
- * if the item at i-1 of transitionList is not null and contains a derivational boundary, it assigns the ith item of formList to lemma.
152
- *
153
- * @return String output lemma.
154
- */
155
- getLastLemma() {
156
- let lemma = this.root.getName();
157
- for (let i = 1; i < this.formList.length; i++) {
158
- if (this.transitionList[i - 1] != undefined && this.transitionList[i - 1].includes("^DB+")) {
159
- lemma = this.formList[i];
160
- }
161
- }
162
- return lemma;
163
- }
164
- /**
165
- * The addSuffix method takes 5 different inputs; {@link State} suffix, {@link String} form, transition, with and toPos.
166
- * If the pos of given input suffix is not null, it then assigns it to the pos variable. If the pos of the given suffix
167
- * is null but given toPos is not null than it assigns toPos to pos variable. At the end, it adds suffix to the suffixList,
168
- * form to the formList, transition to the transitionList and if given with is not 0, it is also added to withList.
169
- *
170
- * @param suffix {@link State} input.
171
- * @param form {@link String} input.
172
- * @param transition {@link String} input.
173
- * @param _with {@link String} input.
174
- * @param toPos {@link String} input.
175
- */
176
- addSuffix(suffix, form, transition, _with, toPos) {
177
- if (suffix.getPos() != undefined) {
178
- this.pos = suffix.getPos();
179
- }
180
- else {
181
- if (toPos != undefined) {
182
- this.pos = toPos;
183
- }
184
- }
185
- this.suffixList.push(suffix);
186
- this.formList.push(form);
187
- this.transitionList.push(transition);
188
- if (_with != "0") {
189
- this.withList.push(_with);
190
- }
191
- this.form = form;
192
- }
193
- /**
194
- * Getter for the form variable.
195
- *
196
- * @return the form variable.
197
- */
198
- getSurfaceForm() {
199
- return this.form;
200
- }
201
- /**
202
- * The getStartState method returns the first item of suffixList {@link Array}.
203
- *
204
- * @return the first item of suffixList {@link Array}.
205
- */
206
- getStartState() {
207
- return this.suffixList[0];
208
- }
209
- /**
210
- * Getter for the pos variable.
211
- *
212
- * @return the pos variable.
213
- */
214
- getFinalPos() {
215
- return this.pos;
216
- }
217
- /**
218
- * Getter for the initialPos variable.
219
- *
220
- * @return the initialPos variable.
221
- */
222
- getInitialPos() {
223
- return this.initialPos;
224
- }
225
- /**
226
- * The setForm method takes a {@link String} name as an input and assigns it to the form variable, then it removes
227
- * the first item of formList {@link Array} and adds the given name to the formList.
228
- *
229
- * @param name String input to set form.
230
- */
231
- setForm(name) {
232
- this.form = name;
233
- this.formList.splice(0, 1);
234
- this.formList.push(name);
235
- }
236
- /**
237
- * The getFinalSuffix method returns the last item of suffixList {@link Array}.
238
- *
239
- * @return the last item of suffixList {@link Array}.
240
- */
241
- getFinalSuffix() {
242
- return this.suffixList[this.suffixList.length - 1];
243
- }
244
- /**
245
- * The overridden clone method creates a new {@link FsmParse} abject with root variable and initializes variables form, pos,
246
- * initialPos, verbAgreement, possesiveAgreement, and also the {@link ArrayList}s suffixList, formList, transitionList and withList.
247
- * Then returns newly created and cloned {@link FsmParse} object.
248
- *
249
- * @return FsmParse object.
250
- */
251
- clone() {
252
- let p = new FsmParse(this.root);
253
- p.form = this.form;
254
- p.pos = this.pos;
255
- p.initialPos = this.initialPos;
256
- p.verbAgreement = this.verbAgreement;
257
- p.possesiveAgreement = this.possesiveAgreement;
258
- p.suffixList = new Array();
259
- for (let i = 0; i < this.suffixList.length; i++) {
260
- p.suffixList.push(this.suffixList[i]);
261
- }
262
- p.formList = new Array();
263
- for (let i = 0; i < this.formList.length; i++) {
264
- p.formList.push(this.formList[i]);
265
- }
266
- p.transitionList = new Array();
267
- for (let i = 0; i < this.transitionList.length; i++) {
268
- p.transitionList.push(this.transitionList[i]);
269
- }
270
- p.withList = new Array();
271
- for (let i = 0; i < this.withList.length; i++) {
272
- p.withList.push(this.withList[i]);
273
- }
274
- return p;
275
- }
276
- /**
277
- * The headerTransition method gets the first item of formList and checks for cases;
278
- * <p>
279
- * If it is &lt;DOC&gt;, it returns &lt;DOC&gt;+BDTAG which indicates the beginning of a document.
280
- * If it is &lt;/DOC&gt;, it returns &lt;/DOC&gt;+EDTAG which indicates the ending of a document.
281
- * If it is &lt;TITLE&gt;, it returns &lt;TITLE&gt;+BTTAG which indicates the beginning of a title.
282
- * If it is &lt;/TITLE&gt;, it returns &lt;/TITLE&gt;+ETTAG which indicates the ending of a title.
283
- * If it is &lt;S&gt;, it returns &lt;S&gt;+BSTAG which indicates the beginning of a sentence.
284
- * If it is &lt;/S&gt;, it returns &lt;/S&gt;+ESTAG which indicates the ending of a sentence.
285
- *
286
- * @return corresponding tags of the headers and an empty {@link String} if any case does not match.
287
- */
288
- headerTransition() {
289
- if (this.formList[0] == "<DOC>") {
290
- return "<DOC>+BDTAG";
291
- }
292
- if (this.formList[0] == "</DOC>") {
293
- return "</DOC>+EDTAG";
294
- }
295
- if (this.formList[0] == "<TITLE>") {
296
- return "<TITLE>+BTTAG";
297
- }
298
- if (this.formList[0] == "</TITLE>") {
299
- return "</TITLE>+ETTAG";
300
- }
301
- if (this.formList[0] == "<S>") {
302
- return "<S>+BSTAG";
303
- }
304
- if (this.formList[0] == "</S>") {
305
- return "</S>+ESTAG";
306
- }
307
- return "";
308
- }
309
- /**
310
- * The pronounTransition method gets the first item of formList and checks for cases;
311
- * <p>
312
- * If it is "kendi", it returns kendi+PRON+REFLEXP which indicates a reflexive pronoun.
313
- * If it is one of the "hep, öbür, topu, öteki, kimse, hiçbiri, tümü, çoğu, hepsi, herkes, başkası, birçoğu, birçokları, biri, birbirleri, birbiri, birkaçı, böylesi, diğeri, cümlesi, bazı, kimi", it returns
314
- * +PRON+QUANTP which indicates a quantitative pronoun.
315
- * If it is one of the "o, bu, şu" and if it is "o" it also checks the first item of suffixList and if it is a PronounRoot(DEMONS),
316
- * it returns +PRON+DEMONSP which indicates a demonstrative pronoun.
317
- * If it is "ben", it returns +PRON+PERS+A1SG+PNON which indicates a 1st person singular agreement.
318
- * If it is "sen", it returns +PRON+PERS+A2SG+PNON which indicates a 2nd person singular agreement.
319
- * If it is "o" and the first item of suffixList, if it is a PronounRoot(PERS), it returns +PRON+PERS+A3SG+PNON which
320
- * indicates a 3rd person singular agreement.
321
- * If it is "biz", it returns +PRON+PERS+A1PL+PNON which indicates a 1st person plural agreement.
322
- * If it is "siz", it returns +PRON+PERS+A2PL+PNON which indicates a 2nd person plural agreement.
323
- * If it is "onlar" and the first item of suffixList, if it is a PronounRoot(PERS), it returns o+PRON+PERS+A3PL+PNON which
324
- * indicates a 3rd person plural agreement.
325
- * If it is one of the "nere, ne, kim, hangi", it returns +PRON+QUESP which indicates a question pronoun.
326
- *
327
- * @return corresponding transitions of pronouns and an empty {@link String} if any case does not match.
328
- */
329
- pronounTransition() {
330
- if (this.formList[0] == "kendi") {
331
- return "kendi+PRON+REFLEXP";
332
- }
333
- if (this.formList[0] == "hep" || this.formList[0] == "öbür" || this.formList[0] == "topu" ||
334
- this.formList[0] == "öteki" || this.formList[0] == "kimse" || this.formList[0] == "hiçbiri" ||
335
- this.formList[0] == "tümü" || this.formList[0] == "çoğu" || this.formList[0] == "hepsi" ||
336
- this.formList[0] == "herkes" || this.formList[0] == "başkası" || this.formList[0] == "birçoğu" ||
337
- this.formList[0] == "birçokları" || this.formList[0] == "birbiri" || this.formList[0] == "birbirleri" ||
338
- this.formList[0] == "biri" || this.formList[0] == "birkaçı" || this.formList[0] == "böylesi" ||
339
- this.formList[0] == "diğeri" || this.formList[0] == "cümlesi" || this.formList[0] == "bazı" ||
340
- this.formList[0] == "kimi") {
341
- return this.formList[0] + "+PRON+QUANTP";
342
- }
343
- if ((this.formList[0] == "o" && this.suffixList[0].getName() == "PronounRoot(DEMONS)") ||
344
- this.formList[0] == "bu" || this.formList[0] == "şu") {
345
- return this.formList[0] + "+PRON+DEMONSP";
346
- }
347
- if (this.formList[0] == "ben") {
348
- return this.formList[0] + "+PRON+PERS+A1SG+PNON";
349
- }
350
- if (this.formList[0] == "sen") {
351
- return this.formList[0] + "+PRON+PERS+A2SG+PNON";
352
- }
353
- if (this.formList[0] == "o" && this.suffixList[0].getName() == "PronounRoot(PERS)") {
354
- return this.formList[0] + "+PRON+PERS+A3SG+PNON";
355
- }
356
- if (this.formList[0] == "biz") {
357
- return this.formList[0] + "+PRON+PERS+A1PL+PNON";
358
- }
359
- if (this.formList[0] == "siz") {
360
- return this.formList[0] + "+PRON+PERS+A2PL+PNON";
82
+ }
83
+ /**
84
+ * Getter for the verbAgreement variable.
85
+ *
86
+ * @return the verbAgreement variable.
87
+ */
88
+ getVerbAgreement() {
89
+ return this.verbAgreement;
90
+ }
91
+ /**
92
+ * Getter for the getPossesiveAgreement variable.
93
+ *
94
+ * @return the possesiveAgreement variable.
95
+ */
96
+ getPossesiveAgreement() {
97
+ return this.possesiveAgreement;
98
+ }
99
+ /**
100
+ * The setAgreement method takes a {@link String} transitionName as an input and if it is one of the A1SG, A2SG, A3SG,
101
+ * A1PL, A2PL or A3PL it assigns transitionName input to the verbAgreement variable. Or if it is ine of the PNON, P1SG, P2SG,P3SG,
102
+ * P1PL, P2PL or P3PL it assigns transitionName input to the possesiveAgreement variable.
103
+ *
104
+ * @param transitionName {@link String} input.
105
+ */
106
+ setAgreement(transitionName) {
107
+ if (transitionName != undefined && (transitionName == "A1SG" || transitionName == "A2SG" ||
108
+ transitionName == "A3SG" || transitionName == "A1PL" || transitionName == "A2PL" ||
109
+ transitionName == "A3PL")) {
110
+ this.verbAgreement = transitionName;
111
+ }
112
+ if (transitionName != undefined && (transitionName == "PNON" || transitionName == "P1SG" ||
113
+ transitionName == "P2SG" || transitionName == "P3SG" || transitionName == "P1PL" ||
114
+ transitionName == "P2PL" || transitionName == "P3PL")) {
115
+ this.possesiveAgreement = transitionName;
116
+ }
117
+ }
118
+ /**
119
+ * The getLastLemmaWithTag method takes a String input pos as an input. If given pos is an initial pos then it assigns
120
+ * root to the lemma, and assign null otherwise. Then, it loops i times where i ranges from 1 to size of the formList,
121
+ * if the item at i-1 of transitionList is not null and contains a derivational boundary with pos but not with ZERO,
122
+ * it assigns the ith item of formList to lemma.
123
+ *
124
+ * @param pos {@link String} input.
125
+ * @return String output lemma.
126
+ */
127
+ getLastLemmaWithTag(pos) {
128
+ let lemma;
129
+ if (this.initialPos != undefined && this.initialPos == pos) {
130
+ lemma = this.root.getName();
131
+ }
132
+ else {
133
+ lemma = undefined;
134
+ }
135
+ for (let i = 1; i < this.formList.length; i++) {
136
+ if (this.transitionList[i - 1] != undefined && this.transitionList[i - 1].includes("^DB+" + pos) &&
137
+ !this.transitionList[i - 1].includes("^DB+" + pos + "+ZERO")) {
138
+ lemma = this.formList[i];
361
139
  }
362
- if (this.formList[0] == "onlar") {
363
- return "o+PRON+PERS+A3PL+PNON";
140
+ }
141
+ return lemma;
142
+ }
143
+ /**
144
+ * The getLastLemma method initially assigns root as lemma. Then, it loops i times where i ranges from 1 to size of the formList,
145
+ * if the item at i-1 of transitionList is not null and contains a derivational boundary, it assigns the ith item of formList to lemma.
146
+ *
147
+ * @return String output lemma.
148
+ */
149
+ getLastLemma() {
150
+ let lemma = this.root.getName();
151
+ for (let i = 1; i < this.formList.length; i++) {
152
+ if (this.transitionList[i - 1] != undefined && this.transitionList[i - 1].includes("^DB+")) {
153
+ lemma = this.formList[i];
364
154
  }
365
- if (this.formList[0] == "nere" || this.formList[0] == "ne" || this.formList[0] == "kaçı" ||
366
- this.formList[0] == "kim" || this.formList[0] == "hangi") {
367
- return this.formList[0] + "+PRON+QUESP";
155
+ }
156
+ return lemma;
157
+ }
158
+ /**
159
+ * The addSuffix method takes 5 different inputs; {@link State} suffix, {@link String} form, transition, with and toPos.
160
+ * If the pos of given input suffix is not null, it then assigns it to the pos variable. If the pos of the given suffix
161
+ * is null but given toPos is not null than it assigns toPos to pos variable. At the end, it adds suffix to the suffixList,
162
+ * form to the formList, transition to the transitionList and if given with is not 0, it is also added to withList.
163
+ *
164
+ * @param suffix {@link State} input.
165
+ * @param form {@link String} input.
166
+ * @param transition {@link String} input.
167
+ * @param _with {@link String} input.
168
+ * @param toPos {@link String} input.
169
+ */
170
+ addSuffix(suffix, form, transition, _with, toPos) {
171
+ if (suffix.getPos() != undefined) {
172
+ this.pos = suffix.getPos();
173
+ }
174
+ else {
175
+ if (toPos != undefined) {
176
+ this.pos = toPos;
368
177
  }
369
- return "";
370
- }
371
- /**
372
- * The transitionList method first creates an empty {@link String} result, then gets the first item of suffixList and checks for cases;
373
- * <p>
374
- * If it is one of the "NominalRoot, NominalRootNoPossesive, CompoundNounRoot, NominalRootPlural", it assigns concatenation of first
375
- * item of formList and +NOUN to the result String.
376
- * Ex : Birincilik
377
- * <p>
378
- * If it is one of the "VerbalRoot, PassiveHn", it assigns concatenation of first item of formList and +VERB to the result String.
379
- * Ex : Başkalaştı
380
- * <p>
381
- * If it is "CardinalRoot", it assigns concatenation of first item of formList and +NUM+CARD to the result String.
382
- * Ex : Onuncu
383
- * <p>
384
- * If it is "FractionRoot", it assigns concatenation of first item of formList and NUM+FRACTION to the result String.
385
- * Ex : 1/2
386
- * <p>
387
- * If it is "TimeRoot", it assigns concatenation of first item of formList and +TIME to the result String.
388
- * Ex : 14:28
389
- * <p>
390
- * If it is "RealRoot", it assigns concatenation of first item of formList and +NUM+REAL to the result String.
391
- * Ex : 1.2
392
- * <p>
393
- * If it is "Punctuation", it assigns concatenation of first item of formList and +PUNC to the result String.
394
- * Ex : ,
395
- * <p>
396
- * If it is "Hashtag", it assigns concatenation of first item of formList and +HASHTAG to the result String.
397
- * Ex : #
398
- * <p>
399
- * If it is "DateRoot", it assigns concatenation of first item of formList and +DATE to the result String.
400
- * Ex : 11/06/2018
401
- * <p>
402
- * If it is "RangeRoot", it assigns concatenation of first item of formList and +RANGE to the result String.
403
- * Ex : 3-5
404
- * <p>
405
- * If it is "Email", it assigns concatenation of first item of formList and +EMAIL to the result String.
406
- * Ex : abc@
407
- * <p>
408
- * If it is "PercentRoot", it assigns concatenation of first item of formList and +PERCENT to the result String.
409
- * Ex : %12.5
410
- * <p>
411
- * If it is "DeterminerRoot", it assigns concatenation of first item of formList and +DET to the result String.
412
- * Ex : Birtakım
413
- * <p>
414
- * If it is "ConjunctionRoot", it assigns concatenation of first item of formList and +CONJ to the result String.
415
- * Ex : Ama
416
- * <p>
417
- * If it is "AdverbRoot", it assigns concatenation of first item of formList and +ADV to the result String.
418
- * Ex : Acilen
419
- * <p>
420
- * If it is "ProperRoot", it assigns concatenation of first item of formList and +NOUN+PROP to the result String.
421
- * Ex : Ahmet
422
- * <p>
423
- * If it is "HeaderRoot", it assigns the result of the headerTransition method to the result String.
424
- * Ex : &lt;DOC&gt;
425
- * <p>
426
- * If it is "InterjectionRoot", it assigns concatenation of first item of formList and +INTERJ to the result String.
427
- * Ex : Hey
428
- * <p>
429
- * If it is "DuplicateRoot", it assigns concatenation of first item of formList and +DUP to the result String.
430
- * Ex : Allak
431
- * <p>
432
- * If it is "CodeRoot", it assigns concatenation of first item of formList and +CODE to the result String.
433
- * Ex : 5000-WX
434
- * <p>
435
- * If it is "MetricRoot", it assigns concatenation of first item of formList and +METRIC to the result String.
436
- * Ex : 6cmx12cm
437
- * <p>
438
- * If it is "QuestionRoot", it assigns concatenation of first item of formList and +QUES to the result String.
439
- * Ex : Mı
440
- * <p>
441
- * If it is "PostP", and the first item of formList is one of the "karşı, ilişkin, göre, kadar, ait, yönelik, rağmen, değin,
442
- * dek, doğru, karşın, dair, atfen, binaen, hitaben, istinaden, mahsuben, mukabil, nazaran", it assigns concatenation of first
443
- * item of formList and +POSTP+PCDAT to the result String.
444
- * Ex : İlişkin
445
- * <p>
446
- * If it is "PostP", and the first item of formList is one of the "sonra, önce, beri, fazla, dolayı, itibaren, başka,
447
- * çok, evvel, ötürü, yana, öte, aşağı, yukarı, dışarı, az, gayrı", it assigns concatenation of first
448
- * item of formList and +POSTP+PCABL to the result String.
449
- * Ex : Başka
450
- * <p>
451
- * If it is "PostP", and the first item of formList is "yanısıra", it assigns concatenation of first
452
- * item of formList and +POSTP+PCGEN to the result String.
453
- * Ex : Yanısıra
454
- * <p>
455
- * If it is "PostP", and the first item of formList is one of the "birlikte, beraber", it assigns concatenation of first
456
- * item of formList and +PPOSTP+PCINS to the result String.
457
- * Ex : Birlikte
458
- * <p>
459
- * If it is "PostP", and the first item of formList is one of the "aşkın, takiben", it assigns concatenation of first
460
- * item of formList and +POSTP+PCACC to the result String.
461
- * Ex : Takiben
462
- * <p>
463
- * If it is "PostP", it assigns concatenation of first item of formList and +POSTP+PCNOM to the result String.
464
- * <p>
465
- * If it is "PronounRoot", it assigns result of the pronounTransition method to the result String.
466
- * Ex : Ben
467
- * <p>
468
- * If it is "OrdinalRoot", it assigns concatenation of first item of formList and +NUM+ORD to the result String.
469
- * Ex : Altıncı
470
- * <p>
471
- * If it starts with "Adjective", it assigns concatenation of first item of formList and +ADJ to the result String.
472
- * Ex : Güzel
473
- * <p>
474
- * At the end, it loops through the formList and concatenates each item with result {@link String}.
475
- *
476
- * @return String result accumulated with items of formList.
477
- */
478
- getFsmParseTransitionList() {
479
- let result = "";
480
- if (this.suffixList[0].getName() == "NominalRoot" || this.suffixList[0].getName() == "NominalRootNoPossesive" ||
481
- this.suffixList[0].getName() == "CompoundNounRoot" || this.suffixList[0].getName() == "NominalRootPlural") {
482
- result = this.formList[0] + "+NOUN";
178
+ }
179
+ this.suffixList.push(suffix);
180
+ this.formList.push(form);
181
+ this.transitionList.push(transition);
182
+ if (_with != "0") {
183
+ this.withList.push(_with);
184
+ }
185
+ this.form = form;
186
+ }
187
+ /**
188
+ * Getter for the form variable.
189
+ *
190
+ * @return the form variable.
191
+ */
192
+ getSurfaceForm() {
193
+ return this.form;
194
+ }
195
+ /**
196
+ * The getStartState method returns the first item of suffixList {@link Array}.
197
+ *
198
+ * @return the first item of suffixList {@link Array}.
199
+ */
200
+ getStartState() {
201
+ return this.suffixList[0];
202
+ }
203
+ /**
204
+ * Getter for the pos variable.
205
+ *
206
+ * @return the pos variable.
207
+ */
208
+ getFinalPos() {
209
+ return this.pos;
210
+ }
211
+ /**
212
+ * Getter for the initialPos variable.
213
+ *
214
+ * @return the initialPos variable.
215
+ */
216
+ getInitialPos() {
217
+ return this.initialPos;
218
+ }
219
+ /**
220
+ * The setForm method takes a {@link String} name as an input and assigns it to the form variable, then it removes
221
+ * the first item of formList {@link Array} and adds the given name to the formList.
222
+ *
223
+ * @param name String input to set form.
224
+ */
225
+ setForm(name) {
226
+ this.form = name;
227
+ this.formList.splice(0, 1);
228
+ this.formList.push(name);
229
+ }
230
+ /**
231
+ * The getFinalSuffix method returns the last item of suffixList {@link Array}.
232
+ *
233
+ * @return the last item of suffixList {@link Array}.
234
+ */
235
+ getFinalSuffix() {
236
+ return this.suffixList[this.suffixList.length - 1];
237
+ }
238
+ /**
239
+ * The overridden clone method creates a new {@link FsmParse} abject with root variable and initializes variables form, pos,
240
+ * initialPos, verbAgreement, possesiveAgreement, and also the {@link ArrayList}s suffixList, formList, transitionList and withList.
241
+ * Then returns newly created and cloned {@link FsmParse} object.
242
+ *
243
+ * @return FsmParse object.
244
+ */
245
+ clone() {
246
+ let p = new FsmParse(this.root);
247
+ p.form = this.form;
248
+ p.pos = this.pos;
249
+ p.initialPos = this.initialPos;
250
+ p.verbAgreement = this.verbAgreement;
251
+ p.possesiveAgreement = this.possesiveAgreement;
252
+ p.suffixList = new Array();
253
+ for (let i = 0; i < this.suffixList.length; i++) {
254
+ p.suffixList.push(this.suffixList[i]);
255
+ }
256
+ p.formList = new Array();
257
+ for (let i = 0; i < this.formList.length; i++) {
258
+ p.formList.push(this.formList[i]);
259
+ }
260
+ p.transitionList = new Array();
261
+ for (let i = 0; i < this.transitionList.length; i++) {
262
+ p.transitionList.push(this.transitionList[i]);
263
+ }
264
+ p.withList = new Array();
265
+ for (let i = 0; i < this.withList.length; i++) {
266
+ p.withList.push(this.withList[i]);
267
+ }
268
+ return p;
269
+ }
270
+ /**
271
+ * The headerTransition method gets the first item of formList and checks for cases;
272
+ * <p>
273
+ * If it is &lt;DOC&gt;, it returns &lt;DOC&gt;+BDTAG which indicates the beginning of a document.
274
+ * If it is &lt;/DOC&gt;, it returns &lt;/DOC&gt;+EDTAG which indicates the ending of a document.
275
+ * If it is &lt;TITLE&gt;, it returns &lt;TITLE&gt;+BTTAG which indicates the beginning of a title.
276
+ * If it is &lt;/TITLE&gt;, it returns &lt;/TITLE&gt;+ETTAG which indicates the ending of a title.
277
+ * If it is &lt;S&gt;, it returns &lt;S&gt;+BSTAG which indicates the beginning of a sentence.
278
+ * If it is &lt;/S&gt;, it returns &lt;/S&gt;+ESTAG which indicates the ending of a sentence.
279
+ *
280
+ * @return corresponding tags of the headers and an empty {@link String} if any case does not match.
281
+ */
282
+ headerTransition() {
283
+ if (this.formList[0] == "<DOC>") {
284
+ return "<DOC>+BDTAG";
285
+ }
286
+ if (this.formList[0] == "</DOC>") {
287
+ return "</DOC>+EDTAG";
288
+ }
289
+ if (this.formList[0] == "<TITLE>") {
290
+ return "<TITLE>+BTTAG";
291
+ }
292
+ if (this.formList[0] == "</TITLE>") {
293
+ return "</TITLE>+ETTAG";
294
+ }
295
+ if (this.formList[0] == "<S>") {
296
+ return "<S>+BSTAG";
297
+ }
298
+ if (this.formList[0] == "</S>") {
299
+ return "</S>+ESTAG";
300
+ }
301
+ return "";
302
+ }
303
+ /**
304
+ * The pronounTransition method gets the first item of formList and checks for cases;
305
+ * <p>
306
+ * If it is "kendi", it returns kendi+PRON+REFLEXP which indicates a reflexive pronoun.
307
+ * If it is one of the "hep, öbür, topu, öteki, kimse, hiçbiri, tümü, çoğu, hepsi, herkes, başkası, birçoğu, birçokları, biri, birbirleri, birbiri, birkaçı, böylesi, diğeri, cümlesi, bazı, kimi", it returns
308
+ * +PRON+QUANTP which indicates a quantitative pronoun.
309
+ * If it is one of the "o, bu, şu" and if it is "o" it also checks the first item of suffixList and if it is a PronounRoot(DEMONS),
310
+ * it returns +PRON+DEMONSP which indicates a demonstrative pronoun.
311
+ * If it is "ben", it returns +PRON+PERS+A1SG+PNON which indicates a 1st person singular agreement.
312
+ * If it is "sen", it returns +PRON+PERS+A2SG+PNON which indicates a 2nd person singular agreement.
313
+ * If it is "o" and the first item of suffixList, if it is a PronounRoot(PERS), it returns +PRON+PERS+A3SG+PNON which
314
+ * indicates a 3rd person singular agreement.
315
+ * If it is "biz", it returns +PRON+PERS+A1PL+PNON which indicates a 1st person plural agreement.
316
+ * If it is "siz", it returns +PRON+PERS+A2PL+PNON which indicates a 2nd person plural agreement.
317
+ * If it is "onlar" and the first item of suffixList, if it is a PronounRoot(PERS), it returns o+PRON+PERS+A3PL+PNON which
318
+ * indicates a 3rd person plural agreement.
319
+ * If it is one of the "nere, ne, kim, hangi", it returns +PRON+QUESP which indicates a question pronoun.
320
+ *
321
+ * @return corresponding transitions of pronouns and an empty {@link String} if any case does not match.
322
+ */
323
+ pronounTransition() {
324
+ if (this.formList[0] == "kendi") {
325
+ return "kendi+PRON+REFLEXP";
326
+ }
327
+ if (this.formList[0] == "hep" || this.formList[0] == "öbür" || this.formList[0] == "topu" ||
328
+ this.formList[0] == "öteki" || this.formList[0] == "kimse" || this.formList[0] == "hiçbiri" ||
329
+ this.formList[0] == "tümü" || this.formList[0] == "çoğu" || this.formList[0] == "hepsi" ||
330
+ this.formList[0] == "herkes" || this.formList[0] == "başkası" || this.formList[0] == "birçoğu" ||
331
+ this.formList[0] == "birçokları" || this.formList[0] == "birbiri" || this.formList[0] == "birbirleri" ||
332
+ this.formList[0] == "biri" || this.formList[0] == "birkaçı" || this.formList[0] == "böylesi" ||
333
+ this.formList[0] == "diğeri" || this.formList[0] == "cümlesi" || this.formList[0] == "bazı" ||
334
+ this.formList[0] == "kimi") {
335
+ return this.formList[0] + "+PRON+QUANTP";
336
+ }
337
+ if ((this.formList[0] == "o" && this.suffixList[0].getName() == "PronounRoot(DEMONS)") ||
338
+ this.formList[0] == "bu" || this.formList[0] == "şu") {
339
+ return this.formList[0] + "+PRON+DEMONSP";
340
+ }
341
+ if (this.formList[0] == "ben") {
342
+ return this.formList[0] + "+PRON+PERS+A1SG+PNON";
343
+ }
344
+ if (this.formList[0] == "sen") {
345
+ return this.formList[0] + "+PRON+PERS+A2SG+PNON";
346
+ }
347
+ if (this.formList[0] == "o" && this.suffixList[0].getName() == "PronounRoot(PERS)") {
348
+ return this.formList[0] + "+PRON+PERS+A3SG+PNON";
349
+ }
350
+ if (this.formList[0] == "biz") {
351
+ return this.formList[0] + "+PRON+PERS+A1PL+PNON";
352
+ }
353
+ if (this.formList[0] == "siz") {
354
+ return this.formList[0] + "+PRON+PERS+A2PL+PNON";
355
+ }
356
+ if (this.formList[0] == "onlar") {
357
+ return "o+PRON+PERS+A3PL+PNON";
358
+ }
359
+ if (this.formList[0] == "nere" || this.formList[0] == "ne" || this.formList[0] == "kaçı" ||
360
+ this.formList[0] == "kim" || this.formList[0] == "hangi") {
361
+ return this.formList[0] + "+PRON+QUESP";
362
+ }
363
+ return "";
364
+ }
365
+ /**
366
+ * The transitionList method first creates an empty {@link String} result, then gets the first item of suffixList and checks for cases;
367
+ * <p>
368
+ * If it is one of the "NominalRoot, NominalRootNoPossesive, CompoundNounRoot, NominalRootPlural", it assigns concatenation of first
369
+ * item of formList and +NOUN to the result String.
370
+ * Ex : Birincilik
371
+ * <p>
372
+ * If it is one of the "VerbalRoot, PassiveHn", it assigns concatenation of first item of formList and +VERB to the result String.
373
+ * Ex : Başkalaştı
374
+ * <p>
375
+ * If it is "CardinalRoot", it assigns concatenation of first item of formList and +NUM+CARD to the result String.
376
+ * Ex : Onuncu
377
+ * <p>
378
+ * If it is "FractionRoot", it assigns concatenation of first item of formList and NUM+FRACTION to the result String.
379
+ * Ex : 1/2
380
+ * <p>
381
+ * If it is "TimeRoot", it assigns concatenation of first item of formList and +TIME to the result String.
382
+ * Ex : 14:28
383
+ * <p>
384
+ * If it is "RealRoot", it assigns concatenation of first item of formList and +NUM+REAL to the result String.
385
+ * Ex : 1.2
386
+ * <p>
387
+ * If it is "Punctuation", it assigns concatenation of first item of formList and +PUNC to the result String.
388
+ * Ex : ,
389
+ * <p>
390
+ * If it is "Hashtag", it assigns concatenation of first item of formList and +HASHTAG to the result String.
391
+ * Ex : #
392
+ * <p>
393
+ * If it is "DateRoot", it assigns concatenation of first item of formList and +DATE to the result String.
394
+ * Ex : 11/06/2018
395
+ * <p>
396
+ * If it is "RangeRoot", it assigns concatenation of first item of formList and +RANGE to the result String.
397
+ * Ex : 3-5
398
+ * <p>
399
+ * If it is "Email", it assigns concatenation of first item of formList and +EMAIL to the result String.
400
+ * Ex : abc@
401
+ * <p>
402
+ * If it is "PercentRoot", it assigns concatenation of first item of formList and +PERCENT to the result String.
403
+ * Ex : %12.5
404
+ * <p>
405
+ * If it is "DeterminerRoot", it assigns concatenation of first item of formList and +DET to the result String.
406
+ * Ex : Birtakım
407
+ * <p>
408
+ * If it is "ConjunctionRoot", it assigns concatenation of first item of formList and +CONJ to the result String.
409
+ * Ex : Ama
410
+ * <p>
411
+ * If it is "AdverbRoot", it assigns concatenation of first item of formList and +ADV to the result String.
412
+ * Ex : Acilen
413
+ * <p>
414
+ * If it is "ProperRoot", it assigns concatenation of first item of formList and +NOUN+PROP to the result String.
415
+ * Ex : Ahmet
416
+ * <p>
417
+ * If it is "HeaderRoot", it assigns the result of the headerTransition method to the result String.
418
+ * Ex : &lt;DOC&gt;
419
+ * <p>
420
+ * If it is "InterjectionRoot", it assigns concatenation of first item of formList and +INTERJ to the result String.
421
+ * Ex : Hey
422
+ * <p>
423
+ * If it is "DuplicateRoot", it assigns concatenation of first item of formList and +DUP to the result String.
424
+ * Ex : Allak
425
+ * <p>
426
+ * If it is "CodeRoot", it assigns concatenation of first item of formList and +CODE to the result String.
427
+ * Ex : 5000-WX
428
+ * <p>
429
+ * If it is "MetricRoot", it assigns concatenation of first item of formList and +METRIC to the result String.
430
+ * Ex : 6cmx12cm
431
+ * <p>
432
+ * If it is "QuestionRoot", it assigns concatenation of first item of formList and +QUES to the result String.
433
+ * Ex : Mı
434
+ * <p>
435
+ * If it is "PostP", and the first item of formList is one of the "karşı, ilişkin, göre, kadar, ait, yönelik, rağmen, değin,
436
+ * dek, doğru, karşın, dair, atfen, binaen, hitaben, istinaden, mahsuben, mukabil, nazaran", it assigns concatenation of first
437
+ * item of formList and +POSTP+PCDAT to the result String.
438
+ * Ex : İlişkin
439
+ * <p>
440
+ * If it is "PostP", and the first item of formList is one of the "sonra, önce, beri, fazla, dolayı, itibaren, başka,
441
+ * çok, evvel, ötürü, yana, öte, aşağı, yukarı, dışarı, az, gayrı", it assigns concatenation of first
442
+ * item of formList and +POSTP+PCABL to the result String.
443
+ * Ex : Başka
444
+ * <p>
445
+ * If it is "PostP", and the first item of formList is "yanısıra", it assigns concatenation of first
446
+ * item of formList and +POSTP+PCGEN to the result String.
447
+ * Ex : Yanısıra
448
+ * <p>
449
+ * If it is "PostP", and the first item of formList is one of the "birlikte, beraber", it assigns concatenation of first
450
+ * item of formList and +PPOSTP+PCINS to the result String.
451
+ * Ex : Birlikte
452
+ * <p>
453
+ * If it is "PostP", and the first item of formList is one of the "aşkın, takiben", it assigns concatenation of first
454
+ * item of formList and +POSTP+PCACC to the result String.
455
+ * Ex : Takiben
456
+ * <p>
457
+ * If it is "PostP", it assigns concatenation of first item of formList and +POSTP+PCNOM to the result String.
458
+ * <p>
459
+ * If it is "PronounRoot", it assigns result of the pronounTransition method to the result String.
460
+ * Ex : Ben
461
+ * <p>
462
+ * If it is "OrdinalRoot", it assigns concatenation of first item of formList and +NUM+ORD to the result String.
463
+ * Ex : Altıncı
464
+ * <p>
465
+ * If it starts with "Adjective", it assigns concatenation of first item of formList and +ADJ to the result String.
466
+ * Ex : Güzel
467
+ * <p>
468
+ * At the end, it loops through the formList and concatenates each item with result {@link String}.
469
+ *
470
+ * @return String result accumulated with items of formList.
471
+ */
472
+ getFsmParseTransitionList() {
473
+ let result = "";
474
+ if (this.suffixList[0].getName() == "NominalRoot" || this.suffixList[0].getName() == "NominalRootNoPossesive" ||
475
+ this.suffixList[0].getName() == "CompoundNounRoot" || this.suffixList[0].getName() == "NominalRootPlural") {
476
+ result = this.formList[0] + "+NOUN";
477
+ }
478
+ else {
479
+ if (this.suffixList[0].getName().startsWith("VerbalRoot") || this.suffixList[0].getName() == "PassiveHn") {
480
+ result = this.formList[0] + "+VERB";
483
481
  }
484
482
  else {
485
- if (this.suffixList[0].getName().startsWith("VerbalRoot") || this.suffixList[0].getName() == "PassiveHn") {
486
- result = this.formList[0] + "+VERB";
483
+ if (this.suffixList[0].getName() == "CardinalRoot") {
484
+ result = this.formList[0] + "+NUM+CARD";
487
485
  }
488
486
  else {
489
- if (this.suffixList[0].getName() == "CardinalRoot") {
490
- result = this.formList[0] + "+NUM+CARD";
487
+ if (this.suffixList[0].getName() == "FractionRoot") {
488
+ result = this.formList[0] + "+NUM+FRACTION";
491
489
  }
492
490
  else {
493
- if (this.suffixList[0].getName() == "FractionRoot") {
494
- result = this.formList[0] + "+NUM+FRACTION";
491
+ if (this.suffixList[0].getName() == "TimeRoot") {
492
+ result = this.formList[0] + "+TIME";
495
493
  }
496
494
  else {
497
- if (this.suffixList[0].getName() == "TimeRoot") {
498
- result = this.formList[0] + "+TIME";
495
+ if (this.suffixList[0].getName() == "RealRoot") {
496
+ result = this.formList[0] + "+NUM+REAL";
499
497
  }
500
498
  else {
501
- if (this.suffixList[0].getName() == "RealRoot") {
502
- result = this.formList[0] + "+NUM+REAL";
499
+ if (this.suffixList[0].getName() == "Punctuation") {
500
+ result = this.formList[0] + "+PUNC";
503
501
  }
504
502
  else {
505
- if (this.suffixList[0].getName() == "Punctuation") {
506
- result = this.formList[0] + "+PUNC";
503
+ if (this.suffixList[0].getName() == "Hashtag") {
504
+ result = this.formList[0] + "+HASHTAG";
507
505
  }
508
506
  else {
509
- if (this.suffixList[0].getName() == "Hashtag") {
510
- result = this.formList[0] + "+HASHTAG";
507
+ if (this.suffixList[0].getName() == "DateRoot") {
508
+ result = this.formList[0] + "+DATE";
511
509
  }
512
510
  else {
513
- if (this.suffixList[0].getName() == "DateRoot") {
514
- result = this.formList[0] + "+DATE";
511
+ if (this.suffixList[0].getName() == "RangeRoot") {
512
+ result = this.formList[0] + "+RANGE";
515
513
  }
516
514
  else {
517
- if (this.suffixList[0].getName() == "RangeRoot") {
518
- result = this.formList[0] + "+RANGE";
515
+ if (this.suffixList[0].getName() == "Email") {
516
+ result = this.formList[0] + "+EMAIL";
519
517
  }
520
518
  else {
521
- if (this.suffixList[0].getName() == "Email") {
522
- result = this.formList[0] + "+EMAIL";
519
+ if (this.suffixList[0].getName() == "PercentRoot") {
520
+ result = this.formList[0] + "+PERCENT";
523
521
  }
524
522
  else {
525
- if (this.suffixList[0].getName() == "PercentRoot") {
526
- result = this.formList[0] + "+PERCENT";
523
+ if (this.suffixList[0].getName() == "DeterminerRoot") {
524
+ result = this.formList[0] + "+DET";
527
525
  }
528
526
  else {
529
- if (this.suffixList[0].getName() == "DeterminerRoot") {
530
- result = this.formList[0] + "+DET";
527
+ if (this.suffixList[0].getName() == "ConjunctionRoot") {
528
+ result = this.formList[0] + "+CONJ";
531
529
  }
532
530
  else {
533
- if (this.suffixList[0].getName() == "ConjunctionRoot") {
534
- result = this.formList[0] + "+CONJ";
531
+ if (this.suffixList[0].getName() == "AdverbRoot") {
532
+ result = this.formList[0] + "+ADV";
535
533
  }
536
534
  else {
537
- if (this.suffixList[0].getName() == "AdverbRoot") {
538
- result = this.formList[0] + "+ADV";
535
+ if (this.suffixList[0].getName() == "ProperRoot") {
536
+ result = this.formList[0] + "+NOUN+PROP";
539
537
  }
540
538
  else {
541
- if (this.suffixList[0].getName() == "ProperRoot") {
542
- result = this.formList[0] + "+NOUN+PROP";
539
+ if (this.suffixList[0].getName() == "HeaderRoot") {
540
+ result = this.headerTransition();
543
541
  }
544
542
  else {
545
- if (this.suffixList[0].getName() == "HeaderRoot") {
546
- result = this.headerTransition();
543
+ if (this.suffixList[0].getName() == "InterjectionRoot") {
544
+ result = this.formList[0] + "+INTERJ";
547
545
  }
548
546
  else {
549
- if (this.suffixList[0].getName() == "InterjectionRoot") {
550
- result = this.formList[0] + "+INTERJ";
547
+ if (this.suffixList[0].getName() == "DuplicateRoot") {
548
+ result = this.formList[0] + "+DUP";
551
549
  }
552
550
  else {
553
- if (this.suffixList[0].getName() == "DuplicateRoot") {
554
- result = this.formList[0] + "+DUP";
551
+ if (this.suffixList[0].getName() == "CodeRoot") {
552
+ result = this.formList[0] + "+CODE";
555
553
  }
556
554
  else {
557
- if (this.suffixList[0].getName() == "CodeRoot") {
558
- result = this.formList[0] + "+CODE";
555
+ if (this.suffixList[0].getName() == "MetricRoot") {
556
+ result = this.formList[0] + "+METRIC";
559
557
  }
560
558
  else {
561
- if (this.suffixList[0].getName() == "MetricRoot") {
562
- result = this.formList[0] + "+METRIC";
559
+ if (this.suffixList[0].getName() == "QuestionRoot") {
560
+ result = "mi+QUES";
563
561
  }
564
562
  else {
565
- if (this.suffixList[0].getName() == "QuestionRoot") {
566
- result = "mi+QUES";
567
- }
568
- else {
569
- if (this.suffixList[0].getName() == "PostP") {
570
- if (this.formList[0] == "karşı" || this.formList[0] == "ilişkin" || this.formList[0] == "göre" || this.formList[0] == "kadar" || this.formList[0] == "ait" || this.formList[0] == "yönelik" || this.formList[0] == "rağmen" || this.formList[0] == "değin" || this.formList[0] == "dek" || this.formList[0] == "doğru" || this.formList[0] == "karşın" || this.formList[0] == "dair" || this.formList[0] == "atfen" || this.formList[0] == "binaen" || this.formList[0] == "hitaben" || this.formList[0] == "istinaden" || this.formList[0] == "mahsuben" || this.formList[0] == "mukabil" || this.formList[0] == "nazaran") {
571
- result = this.formList[0] + "+POSTP+PCDAT";
563
+ if (this.suffixList[0].getName() == "PostP") {
564
+ if (this.formList[0] == "karşı" || this.formList[0] == "ilişkin" || this.formList[0] == "göre" || this.formList[0] == "kadar" || this.formList[0] == "ait" || this.formList[0] == "yönelik" || this.formList[0] == "rağmen" || this.formList[0] == "değin" || this.formList[0] == "dek" || this.formList[0] == "doğru" || this.formList[0] == "karşın" || this.formList[0] == "dair" || this.formList[0] == "atfen" || this.formList[0] == "binaen" || this.formList[0] == "hitaben" || this.formList[0] == "istinaden" || this.formList[0] == "mahsuben" || this.formList[0] == "mukabil" || this.formList[0] == "nazaran") {
565
+ result = this.formList[0] + "+POSTP+PCDAT";
566
+ }
567
+ else {
568
+ if (this.formList[0] == "sonra" || this.formList[0] == "önce" || this.formList[0] == "beri" || this.formList[0] == "fazla" || this.formList[0] == "dolayı" || this.formList[0] == "itibaren" || this.formList[0] == "başka" || this.formList[0] == "çok" || this.formList[0] == "evvel" || this.formList[0] == "ötürü" || this.formList[0] == "yana" || this.formList[0] == "öte" || this.formList[0] == "aşağı" || this.formList[0] == "yukarı" || this.formList[0] == "dışarı" || this.formList[0] == "az" || this.formList[0] == "gayrı") {
569
+ result = this.formList[0] + "+POSTP+PCABL";
572
570
  }
573
571
  else {
574
- if (this.formList[0] == "sonra" || this.formList[0] == "önce" || this.formList[0] == "beri" || this.formList[0] == "fazla" || this.formList[0] == "dolayı" || this.formList[0] == "itibaren" || this.formList[0] == "başka" || this.formList[0] == "çok" || this.formList[0] == "evvel" || this.formList[0] == "ötürü" || this.formList[0] == "yana" || this.formList[0] == "öte" || this.formList[0] == "aşağı" || this.formList[0] == "yukarı" || this.formList[0] == "dışarı" || this.formList[0] == "az" || this.formList[0] == "gayrı") {
575
- result = this.formList[0] + "+POSTP+PCABL";
572
+ if (this.formList[0] == "yanısıra") {
573
+ result = this.formList[0] + "+POSTP+PCGEN";
576
574
  }
577
575
  else {
578
- if (this.formList[0] == "yanısıra") {
579
- result = this.formList[0] + "+POSTP+PCGEN";
576
+ if (this.formList[0] == "birlikte" || this.formList[0] == "beraber") {
577
+ result = this.formList[0] + "+POSTP+PCINS";
580
578
  }
581
579
  else {
582
- if (this.formList[0] == "birlikte" || this.formList[0] == "beraber") {
583
- result = this.formList[0] + "+POSTP+PCINS";
580
+ if (this.formList[0] == "aşkın" || this.formList[0] == "takiben") {
581
+ result = this.formList[0] + "+POSTP+PCACC";
584
582
  }
585
583
  else {
586
- if (this.formList[0] == "aşkın" || this.formList[0] == "takiben") {
587
- result = this.formList[0] + "+POSTP+PCACC";
588
- }
589
- else {
590
- result = this.formList[0] + "+POSTP+PCNOM";
591
- }
584
+ result = this.formList[0] + "+POSTP+PCNOM";
592
585
  }
593
586
  }
594
587
  }
595
588
  }
596
589
  }
590
+ }
591
+ else {
592
+ if (this.suffixList[0].getName().startsWith("PronounRoot")) {
593
+ result = this.pronounTransition();
594
+ }
597
595
  else {
598
- if (this.suffixList[0].getName().startsWith("PronounRoot")) {
599
- result = this.pronounTransition();
596
+ if (this.suffixList[0].getName() == "OrdinalRoot") {
597
+ result = this.formList[0] + "+NUM+ORD";
600
598
  }
601
599
  else {
602
- if (this.suffixList[0].getName() == "OrdinalRoot") {
603
- result = this.formList[0] + "+NUM+ORD";
604
- }
605
- else {
606
- if (this.suffixList[0].getName().startsWith("Adjective")) {
607
- result = this.formList[0] + "+ADJ";
608
- }
600
+ if (this.suffixList[0].getName().startsWith("Adjective")) {
601
+ result = this.formList[0] + "+ADJ";
609
602
  }
610
603
  }
611
604
  }
@@ -631,84 +624,84 @@
631
624
  }
632
625
  }
633
626
  }
634
- for (let transition of this.transitionList) {
635
- if (transition != "") {
636
- if (!transition.startsWith("^")) {
637
- result = result + "+" + transition;
638
- }
639
- else {
640
- result = result + transition;
641
- }
627
+ }
628
+ for (let transition of this.transitionList) {
629
+ if (transition != "") {
630
+ if (!transition.startsWith("^")) {
631
+ result = result + "+" + transition;
642
632
  }
643
- }
644
- return result;
645
- }
646
- /**
647
- * The suffixList method gets the first items of suffixList and formList and concatenates them with parenthesis and
648
- * assigns a String result. Then, loops through the formList and it the current ith item is not equal to previous
649
- * item it accumulates ith items of formList and suffixList to the result {@link String}.
650
- *
651
- * @return result {@link String} accumulated with the items of formList and suffixList.
652
- */
653
- getSuffixList() {
654
- let result = this.suffixList[0].getName() + '(' + this.formList[0] + ')';
655
- for (let i = 1; i < this.formList.length; i++) {
656
- if (this.formList[i] != this.formList[i - 1]) {
657
- result = result + "+" + this.suffixList[i].getName() + '(' + this.formList[i] + ')';
633
+ else {
634
+ result = result + transition;
658
635
  }
659
636
  }
660
- return result;
661
- }
662
- /**
663
- * The withList method gets the root as a result {@link String} then loops through the withList and concatenates each item
664
- * with result {@link String}.
665
- *
666
- * @return result {@link String} accumulated with items of withList.
667
- */
668
- getWithList() {
669
- let result = this.root.getName();
670
- for (let aWith of this.withList) {
671
- result = result + "+" + aWith;
672
- }
673
- return result;
674
- }
675
- /**
676
- * Replace root word of the current parse with the new root word and returns the new word.
677
- * @param newRoot Replaced root word
678
- * @return Root word of the parse will be replaced with the newRoot and the resulting surface form is returned.
679
- */
680
- replaceRootWord(newRoot) {
681
- let result = newRoot.getName();
682
- for (let aWith of this.withList) {
683
- let transition = new Transition_1.Transition(aWith, undefined, undefined);
684
- result = transition.makeTransition(newRoot, result);
685
- }
686
- return result;
687
- }
688
- /**
689
- * The overridden toString method which returns transitionList method.
690
- *
691
- * @return returns transitionList method.
692
- */
693
- toString() {
694
- return this.getFsmParseTransitionList();
695
- }
696
- /**
697
- * In order to morphologically parse special proper nouns in Turkish, whose affixes obeys not the original but their
698
- * pronunciations, the morphologicalAnalysis method replaces the original word with its pronunciation and do the
699
- * rest. This method reverts it back, that is it restores its original form by replacing the pronunciations in the
700
- * parses with the original form.
701
- * @param original Original form of the proper noun.
702
- * @param pronunciation Pronunciation of the proper noun.
703
- */
704
- restoreOriginalForm(original, pronunciation) {
705
- this.root = new TxtWord_1.TxtWord(original, "IS_OA");
706
- this.form = original + this.form.substring(pronunciation.length);
707
- for (let i = 0; i < this.formList.length; i++) {
708
- this.formList[i] = original + this.formList[i].substring(pronunciation.length);
637
+ }
638
+ return result;
639
+ }
640
+ /**
641
+ * The suffixList method gets the first items of suffixList and formList and concatenates them with parenthesis and
642
+ * assigns a String result. Then, loops through the formList and it the current ith item is not equal to previous
643
+ * item it accumulates ith items of formList and suffixList to the result {@link String}.
644
+ *
645
+ * @return result {@link String} accumulated with the items of formList and suffixList.
646
+ */
647
+ getSuffixList() {
648
+ let result = this.suffixList[0].getName() + '(' + this.formList[0] + ')';
649
+ for (let i = 1; i < this.formList.length; i++) {
650
+ if (this.formList[i] != this.formList[i - 1]) {
651
+ result = result + "+" + this.suffixList[i].getName() + '(' + this.formList[i] + ')';
709
652
  }
710
653
  }
654
+ return result;
655
+ }
656
+ /**
657
+ * The withList method gets the root as a result {@link String} then loops through the withList and concatenates each item
658
+ * with result {@link String}.
659
+ *
660
+ * @return result {@link String} accumulated with items of withList.
661
+ */
662
+ getWithList() {
663
+ let result = this.root.getName();
664
+ for (let aWith of this.withList) {
665
+ result = result + "+" + aWith;
666
+ }
667
+ return result;
668
+ }
669
+ /**
670
+ * Replace root word of the current parse with the new root word and returns the new word.
671
+ * @param newRoot Replaced root word
672
+ * @return Root word of the parse will be replaced with the newRoot and the resulting surface form is returned.
673
+ */
674
+ replaceRootWord(newRoot) {
675
+ let result = newRoot.getName();
676
+ for (let aWith of this.withList) {
677
+ let transition = new Transition_1.Transition(aWith, undefined, undefined);
678
+ result = transition.makeTransition(newRoot, result);
679
+ }
680
+ return result;
681
+ }
682
+ /**
683
+ * The overridden toString method which returns transitionList method.
684
+ *
685
+ * @return returns transitionList method.
686
+ */
687
+ toString() {
688
+ return this.getFsmParseTransitionList();
689
+ }
690
+ /**
691
+ * In order to morphologically parse special proper nouns in Turkish, whose affixes obeys not the original but their
692
+ * pronunciations, the morphologicalAnalysis method replaces the original word with its pronunciation and do the
693
+ * rest. This method reverts it back, that is it restores its original form by replacing the pronunciations in the
694
+ * parses with the original form.
695
+ * @param original Original form of the proper noun.
696
+ * @param pronunciation Pronunciation of the proper noun.
697
+ */
698
+ restoreOriginalForm(original, pronunciation) {
699
+ this.root = new TxtWord_1.TxtWord(original, "IS_OA");
700
+ this.form = original + this.form.substring(pronunciation.length);
701
+ for (let i = 0; i < this.formList.length; i++) {
702
+ this.formList[i] = original + this.formList[i].substring(pronunciation.length);
703
+ }
711
704
  }
712
- exports.FsmParse = FsmParse;
713
- });
705
+ }
706
+ exports.FsmParse = FsmParse;
714
707
  //# sourceMappingURL=FsmParse.js.map