nlptoolkit-morphologicalanalysis 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +144 -0
  2. package/dist/Corpus/DisambiguatedWord.d.ts +20 -0
  3. package/dist/Corpus/DisambiguatedWord.js +38 -0
  4. package/dist/Corpus/DisambiguatedWord.js.map +1 -0
  5. package/dist/Corpus/DisambiguationCorpus.d.ts +4 -0
  6. package/dist/Corpus/DisambiguationCorpus.js +54 -0
  7. package/dist/Corpus/DisambiguationCorpus.js.map +1 -0
  8. package/dist/MorphologicalAnalysis/FiniteStateMachine.d.ts +63 -0
  9. package/dist/MorphologicalAnalysis/FiniteStateMachine.js +178 -0
  10. package/dist/MorphologicalAnalysis/FiniteStateMachine.js.map +1 -0
  11. package/dist/MorphologicalAnalysis/FsmMorphologicalAnalyzer.d.ts +399 -0
  12. package/dist/MorphologicalAnalysis/FsmMorphologicalAnalyzer.js +1255 -0
  13. package/dist/MorphologicalAnalysis/FsmMorphologicalAnalyzer.js.map +1 -0
  14. package/dist/MorphologicalAnalysis/FsmParse.d.ts +290 -0
  15. package/dist/MorphologicalAnalysis/FsmParse.js +684 -0
  16. package/dist/MorphologicalAnalysis/FsmParse.js.map +1 -0
  17. package/dist/MorphologicalAnalysis/FsmParseList.d.ts +96 -0
  18. package/dist/MorphologicalAnalysis/FsmParseList.js +242 -0
  19. package/dist/MorphologicalAnalysis/FsmParseList.js.map +1 -0
  20. package/dist/MorphologicalAnalysis/InflectionalGroup.d.ts +77 -0
  21. package/dist/MorphologicalAnalysis/InflectionalGroup.js +213 -0
  22. package/dist/MorphologicalAnalysis/InflectionalGroup.js.map +1 -0
  23. package/dist/MorphologicalAnalysis/MetamorphicParse.d.ts +63 -0
  24. package/dist/MorphologicalAnalysis/MetamorphicParse.js +592 -0
  25. package/dist/MorphologicalAnalysis/MetamorphicParse.js.map +1 -0
  26. package/dist/MorphologicalAnalysis/MorphologicalParse.d.ts +301 -0
  27. package/dist/MorphologicalAnalysis/MorphologicalParse.js +969 -0
  28. package/dist/MorphologicalAnalysis/MorphologicalParse.js.map +1 -0
  29. package/dist/MorphologicalAnalysis/MorphologicalTag.d.ts +510 -0
  30. package/dist/MorphologicalAnalysis/MorphologicalTag.js +525 -0
  31. package/dist/MorphologicalAnalysis/MorphologicalTag.js.map +1 -0
  32. package/dist/MorphologicalAnalysis/State.d.ts +40 -0
  33. package/dist/MorphologicalAnalysis/State.js +64 -0
  34. package/dist/MorphologicalAnalysis/State.js.map +1 -0
  35. package/dist/MorphologicalAnalysis/Transition.d.ts +159 -0
  36. package/dist/MorphologicalAnalysis/Transition.js +751 -0
  37. package/dist/MorphologicalAnalysis/Transition.js.map +1 -0
  38. package/index.js +12 -0
  39. package/package.json +30 -0
  40. package/penntreebank.txt +208431 -0
  41. package/source/Corpus/DisambiguatedWord.ts +29 -0
  42. package/source/Corpus/DisambiguationCorpus.ts +39 -0
  43. package/source/MorphologicalAnalysis/FiniteStateMachine.ts +165 -0
  44. package/source/MorphologicalAnalysis/FsmMorphologicalAnalyzer.ts +1256 -0
  45. package/source/MorphologicalAnalysis/FsmParse.ts +664 -0
  46. package/source/MorphologicalAnalysis/FsmParseList.ts +238 -0
  47. package/source/MorphologicalAnalysis/InflectionalGroup.ts +210 -0
  48. package/source/MorphologicalAnalysis/MetamorphicParse.ts +589 -0
  49. package/source/MorphologicalAnalysis/MorphologicalParse.ts +995 -0
  50. package/source/MorphologicalAnalysis/MorphologicalTag.ts +510 -0
  51. package/source/MorphologicalAnalysis/State.ts +59 -0
  52. package/source/MorphologicalAnalysis/Transition.ts +733 -0
  53. package/source/tsconfig.json +13 -0
  54. package/tests/DisambiguationCorpusTest.ts +12 -0
  55. package/tests/FiniteStateMachineTest.ts +87 -0
  56. package/tests/FsmMorphologicalAnalyzerTest.ts +204 -0
  57. package/tests/FsmParseListTest.ts +90 -0
  58. package/tests/FsmParseTest.ts +66 -0
  59. package/tests/InflectionalGroupTest.ts +84 -0
  60. package/tests/MorphologicalParseTest.ts +152 -0
  61. package/tests/TransitionTest.ts +174 -0
  62. package/tsconfig.json +15 -0
  63. package/turkish_dictionary.txt +62120 -0
  64. package/turkish_finite_state_machine.xml +1887 -0
  65. package/turkish_misspellings.txt +148932 -0
@@ -0,0 +1,159 @@
1
+ import { State } from "./State";
2
+ import { TxtWord } from "nlptoolkit-dictionary/dist/Dictionary/TxtWord";
3
+ import { FsmParse } from "./FsmParse";
4
+ export declare class Transition {
5
+ private readonly _toState;
6
+ private readonly _with;
7
+ private readonly withName;
8
+ private formationToCheck;
9
+ private readonly _toPos;
10
+ /**
11
+ * Another constructor of {@link Transition} class which takes a {@link State}, and three {@link String}s as input. Then it
12
+ * initializes toState, with, withName and toPos variables with given inputs.
13
+ *
14
+ * @param toState {@link State} input.
15
+ * @param _with String input.
16
+ * @param withName String input.
17
+ * @param toPos String input.
18
+ */
19
+ constructor(_with: string, withName?: string, toState?: State, toPos?: string);
20
+ /**
21
+ * Getter for the toState variable.
22
+ *
23
+ * @return toState variable.
24
+ */
25
+ toState(): State;
26
+ /**
27
+ * Getter for the toPos variable.
28
+ *
29
+ * @return toPos variable.
30
+ */
31
+ toPos(): string;
32
+ /**
33
+ * The transitionPossible method takes two {@link String} as inputs; currentSurfaceForm and realSurfaceForm. If the
34
+ * length of the given currentSurfaceForm is greater than the given realSurfaceForm, it directly returns true. If not,
35
+ * it takes a substring from given realSurfaceForm with the size of currentSurfaceForm. Then checks for the characters of
36
+ * with variable.
37
+ * <p>
38
+ * If the character of with that makes transition is C, it returns true if the substring contains c or ç.
39
+ * If the character of with that makes transition is D, it returns true if the substring contains d or t.
40
+ * If the character of with that makes transition is A, it returns true if the substring contains a or e.
41
+ * If the character of with that makes transition is K, it returns true if the substring contains k, g or ğ.
42
+ * If the character of with that makes transition is other than the ones above, it returns true if the substring
43
+ * contains the same character as with.
44
+ *
45
+ * @param currentSurfaceForm {@link String} input.
46
+ * @param realSurfaceForm {@link String} input.
47
+ * @return true when the transition is possible according to Turkish grammar, false otherwise.
48
+ */
49
+ transitionPossible(currentSurfaceForm: string, realSurfaceForm: string): boolean;
50
+ /**
51
+ * The transitionPossible method takes a {@link FsmParse} currentFsmParse as an input. It then checks some special cases;
52
+ *
53
+ * @param currentFsmParse Parse to be checked
54
+ * @return true if transition is possible false otherwise
55
+ */
56
+ transitionPossibleFromParse(currentFsmParse: FsmParse): boolean;
57
+ transitionPossibleFromRoot(root: TxtWord, fromState: State): boolean;
58
+ /**
59
+ * The beforeLastVowel method takes a {@link String} stem as an input. It loops through the given stem and returns
60
+ * the second last vowel.
61
+ *
62
+ * @param stem String input.
63
+ * @return Vowel before the last vowel.
64
+ */
65
+ private beforeLastVowel;
66
+ /**
67
+ * The lastVowel method takes a {@link String} stem as an input. It loops through the given stem and returns
68
+ * the last vowel.
69
+ *
70
+ * @param stem String input.
71
+ * @return the last vowel.
72
+ */
73
+ private lastVowel;
74
+ /**
75
+ * The lastPhoneme method takes a {@link String} stem as an input. It then returns the last phoneme of the given stem.
76
+ *
77
+ * @param stem String input.
78
+ * @return the last phoneme.
79
+ */
80
+ private lastPhoneme;
81
+ /**
82
+ * The withFirstChar method returns the first character of the with variable.
83
+ *
84
+ * @return the first character of the with variable.
85
+ */
86
+ private withFirstChar;
87
+ /**
88
+ * The startWithVowelorConsonantDrops method checks for some cases. If the first character of with variable is "nsy",
89
+ * and with variable does not equal to one of the Strings; "ylA, ysA, ymHs, yDH, yken", it returns true. If
90
+ * <p>
91
+ * Or, if the first character of with variable is 'A, H: or any other vowels, it returns true.
92
+ *
93
+ * @return true if it starts with vowel or consonant drops, false otherwise.
94
+ */
95
+ private startWithVowelorConsonantDrops;
96
+ /**
97
+ * The softenDuringSuffixation method takes a {@link TxtWord} root as an input. It checks two cases; first case returns
98
+ * true if the given root is nominal or adjective and has one of the flags "IS_SD, IS_B_SD, IS_SDD" and with variable
99
+ * equals o one of the Strings "Hm, nDAn, ncA, nDA, yA, yHm, yHz, yH, nH, nA, nHn, H, sH, Hn, HnHz, HmHz".
100
+ * <p>
101
+ * And the second case returns true if the given root is verb and has the "F_SD" flag, also with variable starts with
102
+ * "Hyor" or equals one of the Strings "yHs, yAn, yA, yAcAk, yAsH, yHncA, yHp, yAlH, yArAk, yAdur, yHver, yAgel, yAgor,
103
+ * yAbil, yAyaz, yAkal, yAkoy, yAmA, yHcH, HCH, Hr, Hs, Hn, yHn", yHnHz, Ar, Hl").
104
+ *
105
+ * @param root {@link TxtWord} input.
106
+ * @return true if there is softening during suffixation of the given root, false otherwise.
107
+ */
108
+ softenDuringSuffixation(root: TxtWord): boolean;
109
+ /**
110
+ * The makeTransition method takes a {@link TxtWord} root and s {@link String} stem as inputs. If given root is a verb,
111
+ * it makes transition with given root and stem with the verbal root state. If given root is not verb, it makes transition
112
+ * with given root and stem and the nominal root state.
113
+ *
114
+ * @param root {@link TxtWord} input.
115
+ * @param stem String input.
116
+ * @param startState Start state to make the transition.
117
+ * @return String type output that has the transition.
118
+ */
119
+ makeTransition(root: TxtWord, stem: string, startState?: State): string;
120
+ private resolveD;
121
+ private resolveA;
122
+ private resolveH;
123
+ /**
124
+ * The resolveC method takes a {@link String} formation as an input. If the last phoneme is on of the "çfhkpsşt", it
125
+ * concatenates given formation with 'ç', if not it concatenates given formation with 'c'.
126
+ *
127
+ * @param formation {@link String} input.
128
+ * @return resolved String.
129
+ */
130
+ private resolveC;
131
+ /**
132
+ * The resolveS method takes a {@link String} formation as an input. It then concatenates given formation with 's'.
133
+ *
134
+ * @param formation {@link String} input.
135
+ * @return resolved String.
136
+ */
137
+ private resolveS;
138
+ /**
139
+ * The resolveSh method takes a {@link String} formation as an input. If the last character is a vowel, it concatenates
140
+ * given formation with ş, if the last character is not a vowel, and not 't' it directly returns given formation, but if it
141
+ * is equal to 't', it transforms it to 'd'.
142
+ *
143
+ * @param formation {@link String} input.
144
+ * @return resolved String.
145
+ */
146
+ private resolveSh;
147
+ /**
148
+ * An overridden toString method which returns the with variable.
149
+ *
150
+ * @return with variable.
151
+ */
152
+ toString(): string;
153
+ /**
154
+ * The with method returns the withName variable.
155
+ *
156
+ * @return the withName variable.
157
+ */
158
+ getWith(): string;
159
+ }