nlptoolkit-morphologicalanalysis 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +144 -0
- package/dist/Corpus/DisambiguatedWord.d.ts +20 -0
- package/dist/Corpus/DisambiguatedWord.js +38 -0
- package/dist/Corpus/DisambiguatedWord.js.map +1 -0
- package/dist/Corpus/DisambiguationCorpus.d.ts +4 -0
- package/dist/Corpus/DisambiguationCorpus.js +54 -0
- package/dist/Corpus/DisambiguationCorpus.js.map +1 -0
- package/dist/MorphologicalAnalysis/FiniteStateMachine.d.ts +63 -0
- package/dist/MorphologicalAnalysis/FiniteStateMachine.js +178 -0
- package/dist/MorphologicalAnalysis/FiniteStateMachine.js.map +1 -0
- package/dist/MorphologicalAnalysis/FsmMorphologicalAnalyzer.d.ts +399 -0
- package/dist/MorphologicalAnalysis/FsmMorphologicalAnalyzer.js +1255 -0
- package/dist/MorphologicalAnalysis/FsmMorphologicalAnalyzer.js.map +1 -0
- package/dist/MorphologicalAnalysis/FsmParse.d.ts +290 -0
- package/dist/MorphologicalAnalysis/FsmParse.js +684 -0
- package/dist/MorphologicalAnalysis/FsmParse.js.map +1 -0
- package/dist/MorphologicalAnalysis/FsmParseList.d.ts +96 -0
- package/dist/MorphologicalAnalysis/FsmParseList.js +242 -0
- package/dist/MorphologicalAnalysis/FsmParseList.js.map +1 -0
- package/dist/MorphologicalAnalysis/InflectionalGroup.d.ts +77 -0
- package/dist/MorphologicalAnalysis/InflectionalGroup.js +213 -0
- package/dist/MorphologicalAnalysis/InflectionalGroup.js.map +1 -0
- package/dist/MorphologicalAnalysis/MetamorphicParse.d.ts +63 -0
- package/dist/MorphologicalAnalysis/MetamorphicParse.js +592 -0
- package/dist/MorphologicalAnalysis/MetamorphicParse.js.map +1 -0
- package/dist/MorphologicalAnalysis/MorphologicalParse.d.ts +301 -0
- package/dist/MorphologicalAnalysis/MorphologicalParse.js +969 -0
- package/dist/MorphologicalAnalysis/MorphologicalParse.js.map +1 -0
- package/dist/MorphologicalAnalysis/MorphologicalTag.d.ts +510 -0
- package/dist/MorphologicalAnalysis/MorphologicalTag.js +525 -0
- package/dist/MorphologicalAnalysis/MorphologicalTag.js.map +1 -0
- package/dist/MorphologicalAnalysis/State.d.ts +40 -0
- package/dist/MorphologicalAnalysis/State.js +64 -0
- package/dist/MorphologicalAnalysis/State.js.map +1 -0
- package/dist/MorphologicalAnalysis/Transition.d.ts +159 -0
- package/dist/MorphologicalAnalysis/Transition.js +751 -0
- package/dist/MorphologicalAnalysis/Transition.js.map +1 -0
- package/index.js +12 -0
- package/package.json +30 -0
- package/penntreebank.txt +208431 -0
- package/source/Corpus/DisambiguatedWord.ts +29 -0
- package/source/Corpus/DisambiguationCorpus.ts +39 -0
- package/source/MorphologicalAnalysis/FiniteStateMachine.ts +165 -0
- package/source/MorphologicalAnalysis/FsmMorphologicalAnalyzer.ts +1256 -0
- package/source/MorphologicalAnalysis/FsmParse.ts +664 -0
- package/source/MorphologicalAnalysis/FsmParseList.ts +238 -0
- package/source/MorphologicalAnalysis/InflectionalGroup.ts +210 -0
- package/source/MorphologicalAnalysis/MetamorphicParse.ts +589 -0
- package/source/MorphologicalAnalysis/MorphologicalParse.ts +995 -0
- package/source/MorphologicalAnalysis/MorphologicalTag.ts +510 -0
- package/source/MorphologicalAnalysis/State.ts +59 -0
- package/source/MorphologicalAnalysis/Transition.ts +733 -0
- package/source/tsconfig.json +13 -0
- package/tests/DisambiguationCorpusTest.ts +12 -0
- package/tests/FiniteStateMachineTest.ts +87 -0
- package/tests/FsmMorphologicalAnalyzerTest.ts +204 -0
- package/tests/FsmParseListTest.ts +90 -0
- package/tests/FsmParseTest.ts +66 -0
- package/tests/InflectionalGroupTest.ts +84 -0
- package/tests/MorphologicalParseTest.ts +152 -0
- package/tests/TransitionTest.ts +174 -0
- package/tsconfig.json +15 -0
- package/turkish_dictionary.txt +62120 -0
- package/turkish_finite_state_machine.xml +1887 -0
- package/turkish_misspellings.txt +148932 -0
|
@@ -0,0 +1,995 @@
|
|
|
1
|
+
import {InflectionalGroup} from "./InflectionalGroup";
|
|
2
|
+
import {Word} from "nlptoolkit-dictionary/dist/Dictionary/Word";
|
|
3
|
+
import {MorphologicalTag} from "./MorphologicalTag";
|
|
4
|
+
|
|
5
|
+
export class MorphologicalParse {
|
|
6
|
+
|
|
7
|
+
protected inflectionalGroups: Array<InflectionalGroup> = new Array<InflectionalGroup>()
|
|
8
|
+
protected root: Word
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Another constructor of {@link MorphologicalParse} class which takes a {@link String} parse as an input. First it creates
|
|
12
|
+
* an {@link Array} as iGs for inflectional groups, and while given String contains derivational boundary (^DB+), it
|
|
13
|
+
*.pushs the substring to the iGs {@link Array} and continue to use given String from 4th index. If it does not contain ^DB+,
|
|
14
|
+
* it directly.pushs the given String to the iGs {@link Array}. Then, it creates a new {@link Array} as
|
|
15
|
+
* inflectionalGroups and checks for some cases.
|
|
16
|
+
* <p>
|
|
17
|
+
* If the first item of iGs {@link Array} is ++Punc, it creates a new root as +, and by calling
|
|
18
|
+
* {@link InflectionalGroup} method with Punc it initializes the IG {@link Array} by parsing given input
|
|
19
|
+
* String IG by + and calling the getMorphologicalTag method with these substrings. If getMorphologicalTag method returns
|
|
20
|
+
* a tag, it.pushs this tag to the IG {@link Array} and also to the inflectionalGroups {@link Array}.
|
|
21
|
+
* <p>
|
|
22
|
+
* If the first item of iGs {@link Array} has +, it creates a new word of first item's substring from index 0 to +,
|
|
23
|
+
* and assigns it to root. Then, by calling {@link InflectionalGroup} method with substring from index 0 to +,
|
|
24
|
+
* it initializes the IG {@link Array} by parsing given input String IG by + and calling the getMorphologicalTag
|
|
25
|
+
* method with these substrings. If getMorphologicalTag method returns a tag, it.pushs this tag to the IG {@link Array}
|
|
26
|
+
* and also to the inflectionalGroups {@link Array}.
|
|
27
|
+
* <p>
|
|
28
|
+
* If the first item of iGs {@link Array} does not contain +, it creates a new word with first item and assigns it as root.
|
|
29
|
+
* <p>
|
|
30
|
+
* At the end, it loops through the items of iGs and by calling {@link InflectionalGroup} method with these items
|
|
31
|
+
* it initializes the IG {@link Array} by parsing given input String IG by + and calling the getMorphologicalTag
|
|
32
|
+
* method with these substrings. If getMorphologicalTag method returns a tag, it.pushs this tag to the IG {@link Array}
|
|
33
|
+
* and also to the inflectionalGroups {@link Array}.
|
|
34
|
+
*
|
|
35
|
+
* @param parseOrInflectionalGroups String input.
|
|
36
|
+
*/
|
|
37
|
+
constructor(parseOrInflectionalGroups?: any) {
|
|
38
|
+
if (parseOrInflectionalGroups != undefined){
|
|
39
|
+
if (!Array.isArray(parseOrInflectionalGroups)){
|
|
40
|
+
let iGs = new Array<string>()
|
|
41
|
+
let st = parseOrInflectionalGroups;
|
|
42
|
+
while (st.includes("^DB+")) {
|
|
43
|
+
iGs.push(st.substring(0, st.indexOf("^DB+")));
|
|
44
|
+
st = st.substring(st.indexOf("^DB+") + 4);
|
|
45
|
+
}
|
|
46
|
+
iGs.push(st);
|
|
47
|
+
if (iGs[0] == "++Punc") {
|
|
48
|
+
this.root = new Word("+");
|
|
49
|
+
this.inflectionalGroups.push(new InflectionalGroup("Punc"));
|
|
50
|
+
} else {
|
|
51
|
+
if (iGs[0].indexOf('+') != -1) {
|
|
52
|
+
this.root = new Word(iGs[0].substring(0, iGs[0].indexOf('+')));
|
|
53
|
+
this.inflectionalGroups.push(new InflectionalGroup(iGs[0].substring(iGs[0].indexOf('+') + 1)));
|
|
54
|
+
} else {
|
|
55
|
+
this.root = new Word(iGs[0]);
|
|
56
|
+
}
|
|
57
|
+
for (let i = 1; i < iGs.length; i++) {
|
|
58
|
+
this.inflectionalGroups.push(new InflectionalGroup(iGs[i]));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
let groups = parseOrInflectionalGroups
|
|
63
|
+
if (groups[0].indexOf('+') != -1) {
|
|
64
|
+
this.root = new Word(groups[0].substring(0, groups[0].indexOf('+')));
|
|
65
|
+
this.inflectionalGroups.push(new InflectionalGroup(groups[0].substring(groups[0].indexOf('+') + 1)));
|
|
66
|
+
}
|
|
67
|
+
for (let i = 1; i < groups.length; i++) {
|
|
68
|
+
this.inflectionalGroups.push(new InflectionalGroup(groups[i]));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The no-arg getWord method returns root {@link Word}.
|
|
76
|
+
*
|
|
77
|
+
* @return root {@link Word}.
|
|
78
|
+
*/
|
|
79
|
+
getWord(): Word{
|
|
80
|
+
return this.root
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The getTransitionList method gets the first item of inflectionalGroups {@link Array} as a {@link String},
|
|
85
|
+
* then loops through the items of inflectionalGroups and concatenates them by using +.
|
|
86
|
+
*
|
|
87
|
+
* @return String that contains transition list.
|
|
88
|
+
*/
|
|
89
|
+
getMorphologicalParseTransitionList(): string{
|
|
90
|
+
let result = this.inflectionalGroups[0].toString();
|
|
91
|
+
for (let i = 1; i < this.inflectionalGroups.length; i++) {
|
|
92
|
+
result = result + "+" + this.inflectionalGroups[i].toString();
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The getInflectionalGroupString method takes an {@link number} index as an input and if index is 0, it directly
|
|
99
|
+
* returns the root and the first item of inflectionalGroups {@link Array}. If the index is not 0, it then returns
|
|
100
|
+
* the corresponding item of inflectionalGroups {@link Array} as a {@link String}.
|
|
101
|
+
*
|
|
102
|
+
* @param index Integer input.
|
|
103
|
+
* @return corresponding item of inflectionalGroups at given index as a {@link String}.
|
|
104
|
+
*/
|
|
105
|
+
getInflectionalGroupString(index: number): string{
|
|
106
|
+
if (index == 0) {
|
|
107
|
+
return this.root.getName() + "+" + this.inflectionalGroups[0].toString();
|
|
108
|
+
} else {
|
|
109
|
+
return this.inflectionalGroups[index].toString();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The getInflectionalGroup method takes an {@link number} index as an input and it directly returns the
|
|
115
|
+
* {@link InflectionalGroup} at given index.
|
|
116
|
+
*
|
|
117
|
+
* @param index Integer input.
|
|
118
|
+
* @return InflectionalGroup at given index.
|
|
119
|
+
*/
|
|
120
|
+
getInflectionalGroup(index?: number): InflectionalGroup{
|
|
121
|
+
if (index == undefined){
|
|
122
|
+
index = this.inflectionalGroups.length - 1
|
|
123
|
+
}
|
|
124
|
+
return this.inflectionalGroups[index];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The getTag method takes an {@link number} index as an input and and if the given index is 0, it directly return
|
|
129
|
+
* the root. Then, it loops through the inflectionalGroups {@link Array} it returns the MorphologicalTag of the
|
|
130
|
+
* corresponding inflectional group.
|
|
131
|
+
*
|
|
132
|
+
* @param index Integer input.
|
|
133
|
+
* @return the MorphologicalTag of the corresponding inflectional group, or null of invalid index inputs.
|
|
134
|
+
*/
|
|
135
|
+
getTag(index: number): string{
|
|
136
|
+
let size = 1;
|
|
137
|
+
if (index == 0)
|
|
138
|
+
return this.root.getName();
|
|
139
|
+
for (let group of this.inflectionalGroups) {
|
|
140
|
+
if (index < size + group.size()) {
|
|
141
|
+
return InflectionalGroup.getTag(group.getTag(index - size));
|
|
142
|
+
}
|
|
143
|
+
size += group.size();
|
|
144
|
+
}
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* The tagSize method loops through the inflectionalGroups {@link Array} and accumulates the sizes of each inflectional group
|
|
150
|
+
* in the inflectionalGroups.
|
|
151
|
+
*
|
|
152
|
+
* @return total size of the inflectionalGroups {@link Array}.
|
|
153
|
+
*/
|
|
154
|
+
tagSize(): number{
|
|
155
|
+
let size = 1;
|
|
156
|
+
for (let group of this.inflectionalGroups) {
|
|
157
|
+
size += group.size();
|
|
158
|
+
}
|
|
159
|
+
return size;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* The size method returns the size of the inflectionalGroups {@link Array}.
|
|
164
|
+
*
|
|
165
|
+
* @return the size of the inflectionalGroups {@link Array}.
|
|
166
|
+
*/
|
|
167
|
+
size(): number{
|
|
168
|
+
return this.inflectionalGroups.length
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The firstInflectionalGroup method returns the first inflectional group of inflectionalGroups {@link Array}.
|
|
173
|
+
*
|
|
174
|
+
* @return the first inflectional group of inflectionalGroups {@link Array}.
|
|
175
|
+
*/
|
|
176
|
+
firstInflectionalGroup(): InflectionalGroup{
|
|
177
|
+
return this.inflectionalGroups[0]
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* The lastInflectionalGroup method returns the last inflectional group of inflectionalGroups {@link Array}.
|
|
182
|
+
*
|
|
183
|
+
* @return the last inflectional group of inflectionalGroups {@link Array}.
|
|
184
|
+
*/
|
|
185
|
+
lastInflectionalGroup(): InflectionalGroup{
|
|
186
|
+
return this.inflectionalGroups[this.inflectionalGroups.length - 1]
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* The getWordWithPos method returns root with the MorphologicalTag of the first inflectional as a new word.
|
|
191
|
+
*
|
|
192
|
+
* @return root with the MorphologicalTag of the first inflectional as a new word.
|
|
193
|
+
*/
|
|
194
|
+
getWordWithPos(): Word{
|
|
195
|
+
return new Word(this.root.getName() + "+" + InflectionalGroup.getTag(this.firstInflectionalGroup().getTag(0)));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* The getPos method returns the MorphologicalTag of the last inflectional group.
|
|
200
|
+
*
|
|
201
|
+
* @return the MorphologicalTag of the last inflectional group.
|
|
202
|
+
*/
|
|
203
|
+
getPos(): string{
|
|
204
|
+
return InflectionalGroup.getTag(this.lastInflectionalGroup().getTag(0));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* The getRootPos method returns the MorphologicalTag of the first inflectional group.
|
|
209
|
+
*
|
|
210
|
+
* @return the MorphologicalTag of the first inflectional group.
|
|
211
|
+
*/
|
|
212
|
+
getRootPos(): string{
|
|
213
|
+
return InflectionalGroup.getTag(this.firstInflectionalGroup().getTag(0));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* The lastIGContainsCase method returns the MorphologicalTag of last inflectional group if it is one of the NOMINATIVE,
|
|
218
|
+
* ACCUSATIVE, DATIVE, LOCATIVE or ABLATIVE cases, null otherwise.
|
|
219
|
+
*
|
|
220
|
+
* @return the MorphologicalTag of last inflectional group if it is one of the NOMINATIVE,
|
|
221
|
+
* ACCUSATIVE, DATIVE, LOCATIVE or ABLATIVE cases, null otherwise.
|
|
222
|
+
*/
|
|
223
|
+
lastIGContainsCase(): string{
|
|
224
|
+
let caseTag = this.lastInflectionalGroup().containsCase();
|
|
225
|
+
if (caseTag != undefined)
|
|
226
|
+
return InflectionalGroup.getTag(caseTag);
|
|
227
|
+
else
|
|
228
|
+
return "NULL";
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* The lastIGContainsTag method takes a MorphologicalTag as an input and returns true if the last inflectional group's
|
|
233
|
+
* MorphologicalTag matches with one of the tags in the IG {@link Array}, false otherwise.
|
|
234
|
+
*
|
|
235
|
+
* @param tag {@link MorphologicalTag} type input.
|
|
236
|
+
* @return true if the last inflectional group's MorphologicalTag matches with one of the tags in the
|
|
237
|
+
* IG {@link Array}, false otherwise.
|
|
238
|
+
*/
|
|
239
|
+
lastIGContainsTag(tag: MorphologicalTag): boolean{
|
|
240
|
+
return this.lastInflectionalGroup().containsTag(tag);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* lastIGContainsPossessive method returns true if the last inflectional group contains one of the
|
|
245
|
+
* possessives: P1PL, P1SG, P2PL, P2SG, P3PL AND P3SG, false otherwise.
|
|
246
|
+
*
|
|
247
|
+
* @return true if the last inflectional group contains one of the possessives: P1PL, P1SG, P2PL, P2SG, P3PL AND P3SG, false otherwise.
|
|
248
|
+
*/
|
|
249
|
+
lastIGContainsPossessive(): boolean{
|
|
250
|
+
return this.lastInflectionalGroup().containsPossessive();
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* The isCapitalWord method returns true if the character at first index o f root is an uppercase letter, false otherwise.
|
|
255
|
+
*
|
|
256
|
+
* @return true if the character at first index o f root is an uppercase letter, false otherwise.
|
|
257
|
+
*/
|
|
258
|
+
isCapitalWord(): boolean{
|
|
259
|
+
let ch = this.root.getName().charAt(0)
|
|
260
|
+
return ch == ch.toLocaleUpperCase("tr")
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* The isNoun method returns true if the part of speech is NOUN, false otherwise.
|
|
265
|
+
*
|
|
266
|
+
* @return true if the part of speech is NOUN, false otherwise.
|
|
267
|
+
*/
|
|
268
|
+
isNoun(): boolean{
|
|
269
|
+
return this.getPos() == "NOUN";
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* The isVerb method returns true if the part of speech is VERB, false otherwise.
|
|
274
|
+
*
|
|
275
|
+
* @return true if the part of speech is VERB, false otherwise.
|
|
276
|
+
*/
|
|
277
|
+
isVerb(): boolean{
|
|
278
|
+
return this.getPos() == "VERB";
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* The isRootVerb method returns true if the part of speech of root is BERV, false otherwise.
|
|
283
|
+
*
|
|
284
|
+
* @return true if the part of speech of root is VERB, false otherwise.
|
|
285
|
+
*/
|
|
286
|
+
isRootVerb(): boolean{
|
|
287
|
+
return this.getRootPos() == "VERB";
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* The isAdjective method returns true if the part of speech is ADJ, false otherwise.
|
|
292
|
+
*
|
|
293
|
+
* @return true if the part of speech is ADJ, false otherwise.
|
|
294
|
+
*/
|
|
295
|
+
isAdjective(): boolean{
|
|
296
|
+
return this.getPos() == "ADJ";
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* The isProperNoun method returns true if the first inflectional group's MorphologicalTag is a PROPERNOUN, false otherwise.
|
|
301
|
+
*
|
|
302
|
+
* @return true if the first inflectional group's MorphologicalTag is a PROPERNOUN, false otherwise.
|
|
303
|
+
*/
|
|
304
|
+
isProperNoun(): boolean{
|
|
305
|
+
return this.getInflectionalGroup(0).containsTag(MorphologicalTag.PROPERNOUN);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* The isPunctuation method returns true if the first inflectional group's MorphologicalTag is a PUNCTUATION, false otherwise.
|
|
310
|
+
*
|
|
311
|
+
* @return true if the first inflectional group's MorphologicalTag is a PUNCTUATION, false otherwise.
|
|
312
|
+
*/
|
|
313
|
+
isPunctuation(): boolean{
|
|
314
|
+
return this.getInflectionalGroup(0).containsTag(MorphologicalTag.PUNCTUATION);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* The isCardinal method returns true if the first inflectional group's MorphologicalTag is a CARDINAL, false otherwise.
|
|
319
|
+
*
|
|
320
|
+
* @return true if the first inflectional group's MorphologicalTag is a CARDINAL, false otherwise.
|
|
321
|
+
*/
|
|
322
|
+
isCardinal(): boolean{
|
|
323
|
+
return this.getInflectionalGroup(0).containsTag(MorphologicalTag.CARDINAL);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* The isOrdinal method returns true if the first inflectional group's MorphologicalTag is a ORDINAL, false otherwise.
|
|
328
|
+
*
|
|
329
|
+
* @return true if the first inflectional group's MorphologicalTag is a ORDINAL, false otherwise.
|
|
330
|
+
*/
|
|
331
|
+
isOrdinal(): boolean{
|
|
332
|
+
return this.getInflectionalGroup(0).containsTag(MorphologicalTag.ORDINAL);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* The isReal method returns true if the first inflectional group's MorphologicalTag is a REAL, false otherwise.
|
|
337
|
+
*
|
|
338
|
+
* @return true if the first inflectional group's MorphologicalTag is a REAL, false otherwise.
|
|
339
|
+
*/
|
|
340
|
+
isReal(): boolean{
|
|
341
|
+
return this.getInflectionalGroup(0).containsTag(MorphologicalTag.REAL);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* The isNumber method returns true if the first inflectional group's MorphologicalTag is REAL or CARDINAL, false otherwise.
|
|
346
|
+
*
|
|
347
|
+
* @return true if the first inflectional group's MorphologicalTag is a REAL or CARDINAL, false otherwise.
|
|
348
|
+
*/
|
|
349
|
+
isNumber(): boolean{
|
|
350
|
+
return this.isReal() || this.isCardinal();
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* The isTime method returns true if the first inflectional group's MorphologicalTag is a TIME, false otherwise.
|
|
355
|
+
*
|
|
356
|
+
* @return true if the first inflectional group's MorphologicalTag is a TIME, false otherwise.
|
|
357
|
+
*/
|
|
358
|
+
isTime(): boolean{
|
|
359
|
+
return this.getInflectionalGroup(0).containsTag(MorphologicalTag.TIME);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* The isDate method returns true if the first inflectional group's MorphologicalTag is a DATE, false otherwise.
|
|
364
|
+
*
|
|
365
|
+
* @return true if the first inflectional group's MorphologicalTag is a DATE, false otherwise.
|
|
366
|
+
*/
|
|
367
|
+
isDate(): boolean{
|
|
368
|
+
return this.getInflectionalGroup(0).containsTag(MorphologicalTag.DATE);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* The isHashTag method returns true if the first inflectional group's MorphologicalTag is a HASHTAG, false otherwise.
|
|
373
|
+
*
|
|
374
|
+
* @return true if the first inflectional group's MorphologicalTag is a HASHTAG, false otherwise.
|
|
375
|
+
*/
|
|
376
|
+
isHashTag(): boolean{
|
|
377
|
+
return this.getInflectionalGroup(0).containsTag(MorphologicalTag.HASHTAG);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* The isEmail method returns true if the first inflectional group's MorphologicalTag is a EMAIL, false otherwise.
|
|
382
|
+
*
|
|
383
|
+
* @return true if the first inflectional group's MorphologicalTag is a EMAIL, false otherwise.
|
|
384
|
+
*/
|
|
385
|
+
isEmail(): boolean{
|
|
386
|
+
return this.getInflectionalGroup(0).containsTag(MorphologicalTag.EMAIL);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* The isPercent method returns true if the first inflectional group's MorphologicalTag is a PERCENT, false otherwise.
|
|
391
|
+
*
|
|
392
|
+
* @return true if the first inflectional group's MorphologicalTag is a PERCENT, false otherwise.
|
|
393
|
+
*/
|
|
394
|
+
isPercent(): boolean{
|
|
395
|
+
return this.getInflectionalGroup(0).containsTag(MorphologicalTag.PERCENT);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* The isFraction method returns true if the first inflectional group's MorphologicalTag is a FRACTION, false otherwise.
|
|
400
|
+
*
|
|
401
|
+
* @return true if the first inflectional group's MorphologicalTag is a FRACTION, false otherwise.
|
|
402
|
+
*/
|
|
403
|
+
isFraction(): boolean{
|
|
404
|
+
return this.getInflectionalGroup(0).containsTag(MorphologicalTag.FRACTION);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* The isRange method returns true if the first inflectional group's MorphologicalTag is a RANGE, false otherwise.
|
|
409
|
+
*
|
|
410
|
+
* @return true if the first inflectional group's MorphologicalTag is a RANGE, false otherwise.
|
|
411
|
+
*/
|
|
412
|
+
isRange(): boolean{
|
|
413
|
+
return this.getInflectionalGroup(0).containsTag(MorphologicalTag.RANGE);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* The isPlural method returns true if {@link InflectionalGroup}'s MorphologicalTags are from the agreement plural
|
|
418
|
+
* or possessive plural, i.e A1PL, A2PL, A3PL, P1PL, P2PL or P3PL, and false otherwise.
|
|
419
|
+
*
|
|
420
|
+
* @return true if {@link InflectionalGroup}'s MorphologicalTags are from the agreement plural or possessive plural.
|
|
421
|
+
*/
|
|
422
|
+
isPlural(): boolean{
|
|
423
|
+
for (let inflectionalGroup of this.inflectionalGroups){
|
|
424
|
+
if (inflectionalGroup.containsPlural()) {
|
|
425
|
+
return true;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* The isAuxiliary method returns true if the root equals to the et, ol, or yap, and false otherwise.
|
|
433
|
+
*
|
|
434
|
+
* @return true if the root equals to the et, ol, or yap, and false otherwise.
|
|
435
|
+
*/
|
|
436
|
+
isAuxiliary(): boolean{
|
|
437
|
+
return this.root.getName() == "et" || this.root.getName() == "ol" || this.root.getName() == "yap";
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* The containsTag method takes a MorphologicalTag as an input and loops through the inflectionalGroups {@link ArrayList},
|
|
442
|
+
* returns true if the input matches with on of the tags in the IG, false otherwise.
|
|
443
|
+
*
|
|
444
|
+
* @param tag checked tag
|
|
445
|
+
* @return true if the input matches with on of the tags in the IG, false otherwise.
|
|
446
|
+
*/
|
|
447
|
+
containsTag(tag: MorphologicalTag): boolean{
|
|
448
|
+
for (let inflectionalGroup of this.inflectionalGroups) {
|
|
449
|
+
if (inflectionalGroup.containsTag(tag)) {
|
|
450
|
+
return true;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
return false;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* The getTreePos method returns the tree pos tag of a morphological analysis.
|
|
458
|
+
*
|
|
459
|
+
* @return Tree pos tag of the morphological analysis in string form.
|
|
460
|
+
*/
|
|
461
|
+
getTreePos(): string{
|
|
462
|
+
if (this.isProperNoun()){
|
|
463
|
+
return "NP";
|
|
464
|
+
} else {
|
|
465
|
+
if (this.root.getName() == "değil"){
|
|
466
|
+
return "NEG";
|
|
467
|
+
} else {
|
|
468
|
+
if (this.isVerb()){
|
|
469
|
+
if (this.lastIGContainsTag(MorphologicalTag.ZERO)){
|
|
470
|
+
return "NOMP";
|
|
471
|
+
} else {
|
|
472
|
+
return "VP";
|
|
473
|
+
}
|
|
474
|
+
} else {
|
|
475
|
+
if (this.isAdjective()){
|
|
476
|
+
return "ADJP";
|
|
477
|
+
} else {
|
|
478
|
+
if (this.isNoun() || this.isPercent()){
|
|
479
|
+
return "NP";
|
|
480
|
+
} else {
|
|
481
|
+
if (this.containsTag(MorphologicalTag.ADVERB)){
|
|
482
|
+
return "ADVP";
|
|
483
|
+
} else {
|
|
484
|
+
if (this.isNumber() || this.isFraction()){
|
|
485
|
+
return "NUM";
|
|
486
|
+
} else {
|
|
487
|
+
if (this.containsTag(MorphologicalTag.POSTPOSITION)){
|
|
488
|
+
return "PP";
|
|
489
|
+
} else {
|
|
490
|
+
if (this.containsTag(MorphologicalTag.CONJUNCTION)){
|
|
491
|
+
return "CONJP";
|
|
492
|
+
} else {
|
|
493
|
+
if (this.containsTag(MorphologicalTag.DETERMINER)){
|
|
494
|
+
return "DP";
|
|
495
|
+
} else {
|
|
496
|
+
if (this.containsTag(MorphologicalTag.INTERJECTION)){
|
|
497
|
+
return "INTJP";
|
|
498
|
+
} else {
|
|
499
|
+
if (this.containsTag(MorphologicalTag.QUESTIONPRONOUN)){
|
|
500
|
+
return "WP";
|
|
501
|
+
} else {
|
|
502
|
+
if (this.containsTag(MorphologicalTag.PRONOUN)){
|
|
503
|
+
return "NP";
|
|
504
|
+
} else {
|
|
505
|
+
if (this.isPunctuation()){
|
|
506
|
+
switch (this.root.getName()){
|
|
507
|
+
case "!":
|
|
508
|
+
case "?":
|
|
509
|
+
return ".";
|
|
510
|
+
case ";":
|
|
511
|
+
case "-":
|
|
512
|
+
case "--":
|
|
513
|
+
return ":";
|
|
514
|
+
case "(":
|
|
515
|
+
case "-LRB-":
|
|
516
|
+
case "-lrb-":
|
|
517
|
+
return "-LRB-";
|
|
518
|
+
case ")":
|
|
519
|
+
case "-RRB-":
|
|
520
|
+
case "-rrb-":
|
|
521
|
+
return "-RRB-";
|
|
522
|
+
default:
|
|
523
|
+
return this.root.getName();
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return "-XXX-";
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
private getPronType(): string{
|
|
543
|
+
let lemma = this.root.getName();
|
|
544
|
+
if (this.containsTag(MorphologicalTag.DETERMINER)){
|
|
545
|
+
return "Art";
|
|
546
|
+
}
|
|
547
|
+
if (lemma == "kendi" || this.containsTag(MorphologicalTag.PERSONALPRONOUN)){
|
|
548
|
+
return "Prs";
|
|
549
|
+
}
|
|
550
|
+
if (lemma == "birbiri" || lemma == "birbirleri"){
|
|
551
|
+
return "Rcp";
|
|
552
|
+
}
|
|
553
|
+
if (lemma == "birçoğu" || lemma == "hep" || lemma == "kimse"
|
|
554
|
+
|| lemma == "bazı" || lemma == "biri" || lemma == "çoğu"
|
|
555
|
+
|| lemma == "hepsi" || lemma == "diğeri" || lemma == "tümü"
|
|
556
|
+
|| lemma == "herkes" || lemma == "kimi" || lemma == "öbür"
|
|
557
|
+
|| lemma == "öteki" || lemma == "birkaçı" || lemma == "topu"
|
|
558
|
+
|| lemma == "başkası"){
|
|
559
|
+
return "Ind";
|
|
560
|
+
}
|
|
561
|
+
if (lemma == "hiçbiri"){
|
|
562
|
+
return "Neg";
|
|
563
|
+
}
|
|
564
|
+
if (lemma == "kim" || lemma == "nere" || lemma == "ne"
|
|
565
|
+
|| lemma == "hangi" || lemma == "nasıl" || lemma == "kaç"
|
|
566
|
+
|| lemma == "mi" || lemma == "mı" || lemma == "mu" || lemma == "mü"){
|
|
567
|
+
return "Int";
|
|
568
|
+
}
|
|
569
|
+
if (this.containsTag(MorphologicalTag.DEMONSTRATIVEPRONOUN)){
|
|
570
|
+
return "Dem";
|
|
571
|
+
}
|
|
572
|
+
return undefined;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
private getNumType(): string{
|
|
576
|
+
let lemma = this.root.getName();
|
|
577
|
+
if (lemma == "%" || this.containsTag(MorphologicalTag.TIME)){
|
|
578
|
+
return "Ord";
|
|
579
|
+
}
|
|
580
|
+
if (this.containsTag(MorphologicalTag.ORDINAL) || lemma == "kaçıncı"){
|
|
581
|
+
return "Ord";
|
|
582
|
+
}
|
|
583
|
+
if (this.containsTag(MorphologicalTag.DISTRIBUTIVE)){
|
|
584
|
+
return "Dist";
|
|
585
|
+
}
|
|
586
|
+
if (this.containsTag(MorphologicalTag.CARDINAL) || this.containsTag(MorphologicalTag.NUMBER) || lemma == "kaç"){
|
|
587
|
+
return "Card";
|
|
588
|
+
}
|
|
589
|
+
return undefined;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
private getReflex(): string{
|
|
593
|
+
let lemma = this.root.getName();
|
|
594
|
+
if (lemma == "kendi"){
|
|
595
|
+
return "Yes";
|
|
596
|
+
}
|
|
597
|
+
return undefined;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
private getNumber(): string{
|
|
601
|
+
if (this.containsTag(MorphologicalTag.A1SG) || this.containsTag(MorphologicalTag.A2SG) ||
|
|
602
|
+
this.containsTag(MorphologicalTag.A3SG)){
|
|
603
|
+
return "Sing";
|
|
604
|
+
}
|
|
605
|
+
if (this.containsTag(MorphologicalTag.A1PL) || this.containsTag(MorphologicalTag.A2PL) ||
|
|
606
|
+
this.containsTag(MorphologicalTag.A3PL)){
|
|
607
|
+
return "Plur";
|
|
608
|
+
}
|
|
609
|
+
return undefined;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
private getPossessiveNumber(): string{
|
|
613
|
+
if (this.containsTag(MorphologicalTag.P1SG) || this.containsTag(MorphologicalTag.P2SG) ||
|
|
614
|
+
this.containsTag(MorphologicalTag.P3SG)){
|
|
615
|
+
return "Sing";
|
|
616
|
+
}
|
|
617
|
+
if (this.containsTag(MorphologicalTag.P1PL) || this.containsTag(MorphologicalTag.P2PL) ||
|
|
618
|
+
this.containsTag(MorphologicalTag.P3PL)){
|
|
619
|
+
return "Plur";
|
|
620
|
+
}
|
|
621
|
+
return undefined;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
private getCase(): string{
|
|
625
|
+
if (this.containsTag(MorphologicalTag.ACCUSATIVE) || this.containsTag(MorphologicalTag.PCACCUSATIVE)){
|
|
626
|
+
return "Acc";
|
|
627
|
+
}
|
|
628
|
+
if (this.containsTag(MorphologicalTag.DATIVE) || this.containsTag(MorphologicalTag.PCDATIVE)){
|
|
629
|
+
return "Dat";
|
|
630
|
+
}
|
|
631
|
+
if (this.containsTag(MorphologicalTag.GENITIVE) || this.containsTag(MorphologicalTag.PCGENITIVE)){
|
|
632
|
+
return "Gen";
|
|
633
|
+
}
|
|
634
|
+
if (this.containsTag(MorphologicalTag.LOCATIVE)){
|
|
635
|
+
return "Loc";
|
|
636
|
+
}
|
|
637
|
+
if (this.containsTag(MorphologicalTag.INSTRUMENTAL) || this.containsTag(MorphologicalTag.PCINSTRUMENTAL)){
|
|
638
|
+
return "Ins";
|
|
639
|
+
}
|
|
640
|
+
if (this.containsTag(MorphologicalTag.ABLATIVE) || this.containsTag(MorphologicalTag.PCABLATIVE)){
|
|
641
|
+
return "Abl";
|
|
642
|
+
}
|
|
643
|
+
if (this.containsTag(MorphologicalTag.NOMINATIVE) || this.containsTag(MorphologicalTag.PCNOMINATIVE)){
|
|
644
|
+
return "Nom";
|
|
645
|
+
}
|
|
646
|
+
return undefined;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
private getDefinite(): string{
|
|
650
|
+
let lemma = this.root.getName();
|
|
651
|
+
if (this.containsTag(MorphologicalTag.DETERMINER)){
|
|
652
|
+
if (lemma == "bir" || lemma == "bazı" || lemma == "birkaç"){
|
|
653
|
+
return "Ind";
|
|
654
|
+
}
|
|
655
|
+
if (lemma == "her" || lemma == "bu" || lemma == "şu" || lemma == "o" || lemma == "bütün"){
|
|
656
|
+
return "Def";
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
return undefined;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
private getDegree(): string{
|
|
663
|
+
let lemma = this.root.getName();
|
|
664
|
+
if (lemma == "daha"){
|
|
665
|
+
return "Cmp";
|
|
666
|
+
}
|
|
667
|
+
if (lemma == "en" && !this.isNoun()){
|
|
668
|
+
return "Sup";
|
|
669
|
+
}
|
|
670
|
+
return undefined;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
private getPolarity(): string{
|
|
674
|
+
if (this.containsTag(MorphologicalTag.POSITIVE)){
|
|
675
|
+
return "Pos";
|
|
676
|
+
}
|
|
677
|
+
if (this.containsTag(MorphologicalTag.NEGATIVE)){
|
|
678
|
+
return "Neg";
|
|
679
|
+
}
|
|
680
|
+
return undefined;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
private getPerson(): string{
|
|
684
|
+
if (this.containsTag(MorphologicalTag.A1SG) || this.containsTag(MorphologicalTag.A1PL)){
|
|
685
|
+
return "1";
|
|
686
|
+
}
|
|
687
|
+
if (this.containsTag(MorphologicalTag.A2SG) || this.containsTag(MorphologicalTag.A2PL)){
|
|
688
|
+
return "2";
|
|
689
|
+
}
|
|
690
|
+
if (this.containsTag(MorphologicalTag.A3SG) || this.containsTag(MorphologicalTag.A3PL)){
|
|
691
|
+
return "3";
|
|
692
|
+
}
|
|
693
|
+
return undefined;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
private getPossessivePerson(): string{
|
|
697
|
+
if (this.containsTag(MorphologicalTag.P1SG) || this.containsTag(MorphologicalTag.P1PL)){
|
|
698
|
+
return "1";
|
|
699
|
+
}
|
|
700
|
+
if (this.containsTag(MorphologicalTag.P2SG) || this.containsTag(MorphologicalTag.P2PL)){
|
|
701
|
+
return "2";
|
|
702
|
+
}
|
|
703
|
+
if (this.containsTag(MorphologicalTag.P3SG) || this.containsTag(MorphologicalTag.P3PL)){
|
|
704
|
+
return "3";
|
|
705
|
+
}
|
|
706
|
+
return undefined;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
private getVoice(): string{
|
|
710
|
+
if (this.containsTag(MorphologicalTag.CAUSATIVE) && this.containsTag(MorphologicalTag.PASSIVE)){
|
|
711
|
+
return "CauPass";
|
|
712
|
+
}
|
|
713
|
+
if (this.containsTag(MorphologicalTag.PASSIVE)){
|
|
714
|
+
return "Pass";
|
|
715
|
+
}
|
|
716
|
+
if (this.containsTag(MorphologicalTag.RECIPROCAL)){
|
|
717
|
+
return "Rcp";
|
|
718
|
+
}
|
|
719
|
+
if (this.containsTag(MorphologicalTag.CAUSATIVE)){
|
|
720
|
+
return "Cau";
|
|
721
|
+
}
|
|
722
|
+
if (this.containsTag(MorphologicalTag.REFLEXIVE)){
|
|
723
|
+
return "Rfl";
|
|
724
|
+
}
|
|
725
|
+
return undefined;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
private getAspect(): string{
|
|
729
|
+
if (this.containsTag(MorphologicalTag.PASTTENSE) || this.containsTag(MorphologicalTag.NARRATIVE) ||
|
|
730
|
+
this.containsTag(MorphologicalTag.FUTURE)){
|
|
731
|
+
return "Perf";
|
|
732
|
+
}
|
|
733
|
+
if (this.containsTag(MorphologicalTag.PROGRESSIVE1) || this.containsTag(MorphologicalTag.PROGRESSIVE2)){
|
|
734
|
+
return "Prog";
|
|
735
|
+
}
|
|
736
|
+
if (this.containsTag(MorphologicalTag.AORIST)){
|
|
737
|
+
return "Hab";
|
|
738
|
+
}
|
|
739
|
+
if (this.containsTag(MorphologicalTag.HASTILY)){
|
|
740
|
+
return "Rapid";
|
|
741
|
+
}
|
|
742
|
+
if (this.containsTag(MorphologicalTag.START) || this.containsTag(MorphologicalTag.STAY) ||
|
|
743
|
+
this.containsTag(MorphologicalTag.REPEAT)){
|
|
744
|
+
return "Dur";
|
|
745
|
+
}
|
|
746
|
+
return undefined;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
private getTense(): string{
|
|
750
|
+
if (this.containsTag(MorphologicalTag.PASTTENSE)){
|
|
751
|
+
return "Past";
|
|
752
|
+
}
|
|
753
|
+
if (this.containsTag(MorphologicalTag.FUTURE)){
|
|
754
|
+
return "Fut";
|
|
755
|
+
}
|
|
756
|
+
if (this.containsTag(MorphologicalTag.NARRATIVE) && this.containsTag(MorphologicalTag.PASTTENSE)){
|
|
757
|
+
return "Pqp";
|
|
758
|
+
}
|
|
759
|
+
if (!this.containsTag(MorphologicalTag.PASTTENSE) && !this.containsTag(MorphologicalTag.FUTURE)){
|
|
760
|
+
return "Pres";
|
|
761
|
+
}
|
|
762
|
+
return undefined;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
private getMood(): string{
|
|
766
|
+
if ((this.containsTag(MorphologicalTag.COPULA) || this.containsTag(MorphologicalTag.AORIST)) &&
|
|
767
|
+
this.containsTag(MorphologicalTag.NECESSITY) && this.containsTag(MorphologicalTag.ABLE)){
|
|
768
|
+
return "GenNecPot";
|
|
769
|
+
}
|
|
770
|
+
if (this.containsTag(MorphologicalTag.CONDITIONAL) && (this.containsTag(MorphologicalTag.COPULA) ||
|
|
771
|
+
this.containsTag(MorphologicalTag.AORIST)) && this.containsTag(MorphologicalTag.ABLE)){
|
|
772
|
+
return "CndGenPot";
|
|
773
|
+
}
|
|
774
|
+
if ((this.containsTag(MorphologicalTag.COPULA) || this.containsTag(MorphologicalTag.AORIST)) &&
|
|
775
|
+
this.containsTag(MorphologicalTag.NECESSITY)){
|
|
776
|
+
return "GenNec";
|
|
777
|
+
}
|
|
778
|
+
if (this.containsTag(MorphologicalTag.NECESSITY) && this.containsTag(MorphologicalTag.ABLE)){
|
|
779
|
+
return "NecPot";
|
|
780
|
+
}
|
|
781
|
+
if ((this.containsTag(MorphologicalTag.COPULA) || this.containsTag(MorphologicalTag.AORIST)) &&
|
|
782
|
+
this.containsTag(MorphologicalTag.ABLE)){
|
|
783
|
+
return "GenPot";
|
|
784
|
+
}
|
|
785
|
+
if (this.containsTag(MorphologicalTag.DESIRE) && this.containsTag(MorphologicalTag.ABLE)){
|
|
786
|
+
return "DesPot";
|
|
787
|
+
}
|
|
788
|
+
if (this.containsTag(MorphologicalTag.CONDITIONAL) && this.containsTag(MorphologicalTag.ABLE)){
|
|
789
|
+
return "CndPot";
|
|
790
|
+
}
|
|
791
|
+
if (this.containsTag(MorphologicalTag.CONDITIONAL) && (this.containsTag(MorphologicalTag.COPULA) ||
|
|
792
|
+
this.containsTag(MorphologicalTag.AORIST))){
|
|
793
|
+
return "CndGen";
|
|
794
|
+
}
|
|
795
|
+
if (this.containsTag(MorphologicalTag.IMPERATIVE)){
|
|
796
|
+
return "Imp";
|
|
797
|
+
}
|
|
798
|
+
if (this.containsTag(MorphologicalTag.CONDITIONAL)){
|
|
799
|
+
return "Cnd";
|
|
800
|
+
}
|
|
801
|
+
if (this.containsTag(MorphologicalTag.DESIRE)){
|
|
802
|
+
return "Des";
|
|
803
|
+
}
|
|
804
|
+
if (this.containsTag(MorphologicalTag.OPTATIVE)){
|
|
805
|
+
return "Opt";
|
|
806
|
+
}
|
|
807
|
+
if (this.containsTag(MorphologicalTag.NECESSITY)){
|
|
808
|
+
return "Nec";
|
|
809
|
+
}
|
|
810
|
+
if (this.containsTag(MorphologicalTag.ABLE)){
|
|
811
|
+
return "Pot";
|
|
812
|
+
}
|
|
813
|
+
if (this.containsTag(MorphologicalTag.PASTTENSE) || this.containsTag(MorphologicalTag.NARRATIVE) ||
|
|
814
|
+
this.containsTag(MorphologicalTag.PROGRESSIVE1) || this.containsTag(MorphologicalTag.PROGRESSIVE2) ||
|
|
815
|
+
this.containsTag(MorphologicalTag.FUTURE)){
|
|
816
|
+
return "Ind";
|
|
817
|
+
}
|
|
818
|
+
if ((this.containsTag(MorphologicalTag.COPULA) || this.containsTag(MorphologicalTag.AORIST))){
|
|
819
|
+
return "Gen";
|
|
820
|
+
}
|
|
821
|
+
if (this.containsTag(MorphologicalTag.ZERO) && !this.containsTag(MorphologicalTag.A3PL)){
|
|
822
|
+
return "Gen";
|
|
823
|
+
}
|
|
824
|
+
return undefined;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
private getVerbForm(): string{
|
|
828
|
+
if (this.containsTag(MorphologicalTag.PASTPARTICIPLE) || this.containsTag(MorphologicalTag.FUTUREPARTICIPLE) ||
|
|
829
|
+
this.containsTag(MorphologicalTag.PRESENTPARTICIPLE)){
|
|
830
|
+
return "Part";
|
|
831
|
+
}
|
|
832
|
+
if (this.containsTag(MorphologicalTag.INFINITIVE) || this.containsTag(MorphologicalTag.INFINITIVE2)){
|
|
833
|
+
return "Vnoun";
|
|
834
|
+
}
|
|
835
|
+
if (this.containsTag(MorphologicalTag.SINCEDOINGSO) || this.containsTag(MorphologicalTag.WITHOUTHAVINGDONESO) ||
|
|
836
|
+
this.containsTag(MorphologicalTag.WITHOUTBEINGABLETOHAVEDONESO) || this.containsTag(MorphologicalTag.BYDOINGSO) ||
|
|
837
|
+
this.containsTag(MorphologicalTag.AFTERDOINGSO) || this.containsTag(MorphologicalTag.INFINITIVE3)){
|
|
838
|
+
return "Conv";
|
|
839
|
+
}
|
|
840
|
+
if (this.containsTag(MorphologicalTag.COPULA) || this.containsTag(MorphologicalTag.ABLE) ||
|
|
841
|
+
this.containsTag(MorphologicalTag.AORIST) || this.containsTag(MorphologicalTag.PROGRESSIVE2) ||
|
|
842
|
+
this.containsTag(MorphologicalTag.DESIRE) || this.containsTag(MorphologicalTag.NECESSITY) ||
|
|
843
|
+
this.containsTag(MorphologicalTag.CONDITIONAL) || this.containsTag(MorphologicalTag.IMPERATIVE) ||
|
|
844
|
+
this.containsTag(MorphologicalTag.OPTATIVE) || this.containsTag(MorphologicalTag.PASTTENSE) ||
|
|
845
|
+
this.containsTag(MorphologicalTag.NARRATIVE) || this.containsTag(MorphologicalTag.PROGRESSIVE1) ||
|
|
846
|
+
this.containsTag(MorphologicalTag.FUTURE) || (this.containsTag(MorphologicalTag.ZERO) &&
|
|
847
|
+
!this.containsTag(MorphologicalTag.A3PL))){
|
|
848
|
+
return "Fin";
|
|
849
|
+
}
|
|
850
|
+
return undefined;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
getUniversalDependencyFeatures(uPos: string): Array<string>{
|
|
854
|
+
let featureList = new Array<string>();
|
|
855
|
+
let pronType = this.getPronType();
|
|
856
|
+
if (pronType != undefined && uPos.toUpperCase() != "NOUN" && uPos.toUpperCase() != "ADJ" && uPos.toUpperCase() != "VERB" && uPos.toUpperCase() != "CCONJ" && uPos.toUpperCase() != "PROPN"){
|
|
857
|
+
featureList.push("PronType=" + pronType);
|
|
858
|
+
}
|
|
859
|
+
let numType = this.getNumType();
|
|
860
|
+
if (numType != undefined && uPos.toUpperCase() != "VERB" && uPos.toUpperCase() != "NOUN" && uPos.toUpperCase() != "ADV"){
|
|
861
|
+
featureList.push("NumType=" + numType);
|
|
862
|
+
}
|
|
863
|
+
let reflex = this.getReflex();
|
|
864
|
+
if (reflex != undefined && uPos.toUpperCase() != "ADJ" && uPos.toUpperCase() != "VERB"){
|
|
865
|
+
featureList.push("Reflex=" + reflex);
|
|
866
|
+
}
|
|
867
|
+
let degree = this.getDegree();
|
|
868
|
+
if (degree != undefined && uPos.toUpperCase() != "ADJ"){
|
|
869
|
+
featureList.push("Degree=" + degree);
|
|
870
|
+
}
|
|
871
|
+
if (this.isNoun() || this.isVerb()){
|
|
872
|
+
let number = this.getNumber();
|
|
873
|
+
if (number != undefined){
|
|
874
|
+
featureList.push("Number=" + number);
|
|
875
|
+
}
|
|
876
|
+
let possessiveNumber = this.getPossessiveNumber();
|
|
877
|
+
if (possessiveNumber != undefined){
|
|
878
|
+
featureList.push("Number[psor]=" + possessiveNumber);
|
|
879
|
+
}
|
|
880
|
+
let person = this.getPerson();
|
|
881
|
+
if (person != undefined && uPos.toUpperCase() != "PROPN"){
|
|
882
|
+
featureList.push("Person=" + person);
|
|
883
|
+
}
|
|
884
|
+
let possessivePerson = this.getPossessivePerson();
|
|
885
|
+
if (possessivePerson != undefined && uPos.toUpperCase() != "PROPN"){
|
|
886
|
+
featureList.push("Person[psor]=" + possessivePerson);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
if (this.isNoun()) {
|
|
890
|
+
let case_ = this.getCase();
|
|
891
|
+
if (case_ != undefined){
|
|
892
|
+
featureList.push("Case=" + case_);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
if (this.containsTag(MorphologicalTag.DETERMINER)){
|
|
896
|
+
let definite = this.getDefinite();
|
|
897
|
+
if (definite != undefined){
|
|
898
|
+
featureList.push("Definite=" + definite);
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
if (this.isVerb()){
|
|
902
|
+
let polarity = this.getPolarity();
|
|
903
|
+
if (polarity != undefined){
|
|
904
|
+
featureList.push("Polarity=" + polarity);
|
|
905
|
+
}
|
|
906
|
+
let voice = this.getVoice();
|
|
907
|
+
if (voice != undefined){
|
|
908
|
+
featureList.push("Voice=" + voice);
|
|
909
|
+
}
|
|
910
|
+
let aspect = this.getAspect();
|
|
911
|
+
if (aspect != undefined && uPos.toUpperCase() != "PROPN"){
|
|
912
|
+
featureList.push("Aspect=" + aspect);
|
|
913
|
+
}
|
|
914
|
+
let tense = this.getTense();
|
|
915
|
+
if (tense != undefined && uPos.toUpperCase() != "PROPN"){
|
|
916
|
+
featureList.push("Tense=" + tense);
|
|
917
|
+
}
|
|
918
|
+
let mood = this.getMood();
|
|
919
|
+
if (mood != undefined && uPos.toUpperCase() != "PROPN"){
|
|
920
|
+
featureList.push("Mood=" + mood);
|
|
921
|
+
}
|
|
922
|
+
let verbForm = this.getVerbForm();
|
|
923
|
+
if (verbForm != undefined && uPos.toUpperCase() != "PROPN"){
|
|
924
|
+
featureList.push("VerbForm=" + verbForm);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
featureList.sort();
|
|
928
|
+
return featureList;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
getUniversalDependencyPos(): string{
|
|
932
|
+
let lemma = this.root.getName();
|
|
933
|
+
if (lemma == "değil"){
|
|
934
|
+
return "AUX";
|
|
935
|
+
}
|
|
936
|
+
if (this.isProperNoun()){
|
|
937
|
+
return "PROPN";
|
|
938
|
+
}
|
|
939
|
+
if (this.isNoun()){
|
|
940
|
+
return "NOUN";
|
|
941
|
+
}
|
|
942
|
+
if (this.isAdjective()){
|
|
943
|
+
return "ADJ";
|
|
944
|
+
}
|
|
945
|
+
if (this.getPos() == "ADV"){
|
|
946
|
+
return "ADV";
|
|
947
|
+
}
|
|
948
|
+
if (this.containsTag(MorphologicalTag.INTERJECTION)){
|
|
949
|
+
return "INTJ";
|
|
950
|
+
}
|
|
951
|
+
if (this.isVerb()){
|
|
952
|
+
return "VERB";
|
|
953
|
+
}
|
|
954
|
+
if (this.isPunctuation() || this.isHashTag()){
|
|
955
|
+
return "PUNCT";
|
|
956
|
+
}
|
|
957
|
+
if (this.containsTag(MorphologicalTag.DETERMINER)){
|
|
958
|
+
return "DET";
|
|
959
|
+
}
|
|
960
|
+
if (this.isNumber() || this.isDate() || this.isTime() || this.isOrdinal() || this.isFraction() || lemma == "%"){
|
|
961
|
+
return "NUM";
|
|
962
|
+
}
|
|
963
|
+
if (this.getPos() == "PRON"){
|
|
964
|
+
return "PRON";
|
|
965
|
+
}
|
|
966
|
+
if (this.getPos() == "POSTP"){
|
|
967
|
+
return "ADP";
|
|
968
|
+
}
|
|
969
|
+
if (this.getPos() == "QUES"){
|
|
970
|
+
return "AUX";
|
|
971
|
+
}
|
|
972
|
+
if (this.getPos() == "CONJ"){
|
|
973
|
+
if (lemma == "ki" || lemma == "eğer" || lemma == "diye"){
|
|
974
|
+
return "SCONJ";
|
|
975
|
+
} else {
|
|
976
|
+
return "CCONJ";
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
return "X";
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
* The overridden toString method gets the root and the first inflectional group as a result {@link String} then concatenates
|
|
984
|
+
* with ^DB+ and the following inflectional groups.
|
|
985
|
+
*
|
|
986
|
+
* @return result {@link String}.
|
|
987
|
+
*/
|
|
988
|
+
toString(): string{
|
|
989
|
+
let result = this.root.getName() + "+" + this.inflectionalGroups[0].toString();
|
|
990
|
+
for (let i = 1; i < this.inflectionalGroups.length; i++){
|
|
991
|
+
result = result + "^DB+" + this.inflectionalGroups[i].toString();
|
|
992
|
+
}
|
|
993
|
+
return result;
|
|
994
|
+
}
|
|
995
|
+
}
|