tinyfix-tr 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +139 -2
- package/dist/pkg/src/context.d.ts +13 -0
- package/dist/pkg/src/context.js +80 -0
- package/dist/pkg/src/data.d.ts +53 -0
- package/dist/pkg/src/data.js +498 -0
- package/dist/pkg/src/engine.d.ts +39 -0
- package/dist/pkg/src/engine.js +357 -0
- package/dist/pkg/src/index.d.ts +30 -0
- package/dist/pkg/src/index.js +85 -0
- package/dist/pkg/src/protocol.d.ts +64 -0
- package/dist/pkg/src/protocol.js +1 -0
- package/dist/pkg/src/types.d.ts +184 -0
- package/dist/pkg/src/types.js +16 -0
- package/dist/pkg/src/worker.d.ts +11 -0
- package/dist/pkg/src/worker.js +111 -0
- package/dist/pkg/src/workerClient.d.ts +3 -0
- package/dist/pkg/src/workerClient.js +202 -0
- package/dist/src/context-vocab.d.ts +1 -0
- package/dist/src/context-vocab.js +2 -0
- package/dist/src/context.d.ts +92 -0
- package/dist/src/context.js +390 -0
- package/dist/src/corrector.d.ts +338 -0
- package/dist/src/corrector.js +2684 -0
- package/dist/src/known.d.ts +88 -0
- package/dist/src/known.js +286 -0
- package/dist/src/lexicon-binary.d.ts +85 -0
- package/dist/src/lexicon-binary.js +805 -0
- package/dist/src/lexicon.d.ts +24 -0
- package/dist/src/lexicon.js +79 -0
- package/dist/src/morphology/analyzer.d.ts +30 -0
- package/dist/src/morphology/analyzer.js +311 -0
- package/dist/src/morphology/binary.d.ts +22 -0
- package/dist/src/morphology/binary.js +372 -0
- package/dist/src/morphology/dictionary.d.ts +21 -0
- package/dist/src/morphology/dictionary.js +559 -0
- package/dist/src/morphology/fuzzy.d.ts +44 -0
- package/dist/src/morphology/fuzzy.js +599 -0
- package/dist/src/morphology/index.d.ts +40 -0
- package/dist/src/morphology/index.js +81 -0
- package/dist/src/morphology/morphotactics.d.ts +148 -0
- package/dist/src/morphology/morphotactics.js +1871 -0
- package/dist/src/morphology/phonetics.d.ts +71 -0
- package/dist/src/morphology/phonetics.js +309 -0
- package/dist/src/morphology/prior.d.ts +61 -0
- package/dist/src/morphology/prior.js +457 -0
- package/dist/src/morphology/types.d.ts +110 -0
- package/dist/src/morphology/types.js +32 -0
- package/dist/src/rules/proper-names.d.ts +145 -0
- package/dist/src/rules/proper-names.js +1217 -0
- package/dist/src/rules/turkish-rules.d.ts +126 -0
- package/dist/src/rules/turkish-rules.js +365 -0
- package/dist/src/sentence.d.ts +83 -0
- package/dist/src/sentence.js +2408 -0
- package/dist/src/turkish.d.ts +20 -0
- package/dist/src/turkish.js +94 -0
- package/package.json +60 -4
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { type ContextModel } from "./context.ts";
|
|
2
|
+
import type { KnownMisspellings } from "./known.ts";
|
|
3
|
+
import { Lexicon } from "./lexicon.ts";
|
|
4
|
+
import { type FuzzyMorphCandidate } from "./morphology/fuzzy.ts";
|
|
5
|
+
/** One change to the text: replace [start, end) with replacement. */
|
|
6
|
+
export interface Correction {
|
|
7
|
+
start: number;
|
|
8
|
+
end: number;
|
|
9
|
+
original: string;
|
|
10
|
+
replacement: string;
|
|
11
|
+
kind: CandidateKind;
|
|
12
|
+
/** How much better the replacement fits than what was typed, in natural-log count units. */
|
|
13
|
+
margin: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* marks: Turkish letters typed without their marks ("cok" for "çok").
|
|
17
|
+
* apostrophe: a suffix on a name without its apostrophe ("Ankaraya").
|
|
18
|
+
* split: two words written as one ("birşey", "geldinmi", "diyorki").
|
|
19
|
+
* join: one word written as two ("hiç bir", "oysa ki", "ev de").
|
|
20
|
+
* typo: a slip of the fingers that made a word that doesn't exist ("gelyorum").
|
|
21
|
+
* known: a listed, corpus-checked misspelling ("herkez", "malesef", "hiç bir").
|
|
22
|
+
* context: chosen by the context model between real words ("bende" / "ben de", "oldu" / "öldü").
|
|
23
|
+
*/
|
|
24
|
+
/** Morphological analysis shape returned by TurkishMorphology.analyze() (optional on WordValidator). */
|
|
25
|
+
export interface WordAnalysis {
|
|
26
|
+
readonly stem: string;
|
|
27
|
+
readonly pos: string;
|
|
28
|
+
readonly morphemes: readonly string[];
|
|
29
|
+
}
|
|
30
|
+
/** Why an untouched word was flagged as a likely misspelling. */
|
|
31
|
+
export type FlagReason = "invalid" | "rare";
|
|
32
|
+
/** A suspicious word left untouched by auto-fix, with ranked suggestions (up to 5). */
|
|
33
|
+
export interface SpellFlag {
|
|
34
|
+
start: number;
|
|
35
|
+
end: number;
|
|
36
|
+
original: string;
|
|
37
|
+
suggestions: string[];
|
|
38
|
+
reason: FlagReason;
|
|
39
|
+
}
|
|
40
|
+
/** Tells whether a lowercase form is a real Turkish word by its suffixes (src/morphology). */
|
|
41
|
+
export interface WordValidator {
|
|
42
|
+
isWord(form: string): boolean;
|
|
43
|
+
analyze?(form: string): readonly WordAnalysis[];
|
|
44
|
+
priorCount?(form: string): number;
|
|
45
|
+
fuzzySearch?(form: string, maxEdits?: number, maxResults?: number): readonly FuzzyMorphCandidate[];
|
|
46
|
+
}
|
|
47
|
+
/** contraction: a spoken-style contraction spelled out ("noldu" -> "ne oldu"), only when Settings.contractions is on. */
|
|
48
|
+
/** punct: sentence punctuation and capitals ("merhaba.ben" -> "Merhaba. Ben"), only when Settings.sentenceCase is on. */
|
|
49
|
+
export type CandidateKind = "marks" | "apostrophe" | "split" | "join" | "typo" | "known" | "context" | "contraction" | "punct";
|
|
50
|
+
export interface Settings {
|
|
51
|
+
/** Minimum margin per kind of change. Higher is more careful. */
|
|
52
|
+
threshold: Record<CandidateKind, number>;
|
|
53
|
+
/** Fixed cost of each kind of change, subtracted from the candidate's score. */
|
|
54
|
+
cost: Record<CandidateKind, number>;
|
|
55
|
+
/** The best candidate must beat the runner-up (a different text) by this much. */
|
|
56
|
+
ambiguity: number;
|
|
57
|
+
/** Words seen less often than this may be slips of the fingers. */
|
|
58
|
+
knownWord: number;
|
|
59
|
+
/**
|
|
60
|
+
* Spell out spoken-style contractions ("noldu" -> "ne oldu", "burda" -> "burada"). Off by default: they are often
|
|
61
|
+
* written on purpose. When off, such words are left exactly as typed, not taken for slips.
|
|
62
|
+
*/
|
|
63
|
+
contractions: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Add a missing space after a sentence end and capitalize the first word of a sentence ("merhaba.ben" ->
|
|
66
|
+
* "Merhaba. Ben"). Off in the bench settings so earlier measurements stay comparable; the package turns it on.
|
|
67
|
+
*/
|
|
68
|
+
sentenceCase: boolean;
|
|
69
|
+
/** Threshold for a slip-of-the-fingers fix when the typed word is unseen and the morphology layer rejects it. */
|
|
70
|
+
typoInvalidThreshold: number;
|
|
71
|
+
/** Extra cost for joining a word with a following "de/da" ("yerler de" -> "yerlerde"). */
|
|
72
|
+
deDaJoinCost: number;
|
|
73
|
+
/** A slip in the last this many letters of a word costs typoEndCost more: those letters are usually a suffix. */
|
|
74
|
+
typoEndWindow: number;
|
|
75
|
+
typoEndCost: number;
|
|
76
|
+
/**
|
|
77
|
+
* For an unseen word that Turkish rules reject: cost of reading a letter as an extra key when it is neither a duplicate
|
|
78
|
+
* nor a keyboard neighbor ("ağldı" is a missed "a" in "ağladı", not a stray "ğ" in "aldı").
|
|
79
|
+
*/
|
|
80
|
+
typoFarExtra: number;
|
|
81
|
+
/** For an unseen invalid word: cost of one vowel typed for another ("nuler" -> "neler"); 0 turns it off. */
|
|
82
|
+
typoVowelSwap: number;
|
|
83
|
+
/**
|
|
84
|
+
* For an unseen invalid word: a rare valid inflected form borrows this share of its stem's count ("arkadaşlarımla"
|
|
85
|
+
* from "arkadaşlarım"), so long correct forms aren't lost for being rare as a whole; 0 turns it off.
|
|
86
|
+
*/
|
|
87
|
+
typoStemShare: number;
|
|
88
|
+
/** Minimum count for an adjacent-swap fix of an unseen-looking 3-letter word ("bka" -> "bak"). */
|
|
89
|
+
shortSwapMinCount: number;
|
|
90
|
+
/** Real words seen at least this often are judged by the context model when one is loaded. */
|
|
91
|
+
contextWord: number;
|
|
92
|
+
/** A count-based fix is dropped when the context model prefers what was typed by at least this much. */
|
|
93
|
+
contextVeto: number;
|
|
94
|
+
/** Minimum context-model margin over core's typo pick to switch to a competing valid typo candidate. */
|
|
95
|
+
contextTypoOverride?: number;
|
|
96
|
+
/** Minimum context-model margin between best and runner-up to resolve an ambiguous untouched typo. */
|
|
97
|
+
contextTypoAmbigGap?: number;
|
|
98
|
+
/** Minimum context-model margin over the invalid typed word to resolve an ambiguous untouched typo. */
|
|
99
|
+
contextTypoAmbigVsTyped?: number;
|
|
100
|
+
/** Minimum context-model margin over the invalid typed word to rescue a below-threshold typo candidate. */
|
|
101
|
+
contextTypoRescue?: number;
|
|
102
|
+
/** Minimum margin for the neural context model (`kind: "name"`) to disambiguate an ambiguous proper name. */
|
|
103
|
+
contextNameThreshold?: number;
|
|
104
|
+
/** Per-regime additive offsets on top of `threshold.context`. */
|
|
105
|
+
contextOffsets?: {
|
|
106
|
+
marksAscii?: number;
|
|
107
|
+
marksMarked?: number;
|
|
108
|
+
marksMarkedOnMarked?: number;
|
|
109
|
+
deDaSplit?: number;
|
|
110
|
+
deDaJoin?: number;
|
|
111
|
+
kiSplit?: number;
|
|
112
|
+
kiJoin?: number;
|
|
113
|
+
miSplit?: number;
|
|
114
|
+
miJoin?: number;
|
|
115
|
+
};
|
|
116
|
+
/** In text that already uses Turkish letters, a word seen this often is taken as meant ("uç" stays "uç")... */
|
|
117
|
+
knownMarked: number;
|
|
118
|
+
/** ...unless the marked form is this much more common (log ratio): "cogu" is still "çoğu". */
|
|
119
|
+
markedOverride: number;
|
|
120
|
+
/** A name must be seen this often, mostly capitalized, before a suffix after it gets an apostrophe. */
|
|
121
|
+
minName: number;
|
|
122
|
+
}
|
|
123
|
+
export declare const CAREFUL: Settings;
|
|
124
|
+
export interface Token {
|
|
125
|
+
text: string;
|
|
126
|
+
start: number;
|
|
127
|
+
end: number;
|
|
128
|
+
isWord: boolean;
|
|
129
|
+
}
|
|
130
|
+
/** What the corrector knows about where a word sits. */
|
|
131
|
+
export interface WordContext {
|
|
132
|
+
atSentenceStart: boolean;
|
|
133
|
+
/** The rest of the text uses Turkish letters, so the writer has them on the keyboard. */
|
|
134
|
+
textHasMarks: boolean;
|
|
135
|
+
/** A question mark comes later in the same sentence. */
|
|
136
|
+
questionAhead: boolean;
|
|
137
|
+
/** Lowercased previous word when separated by a single space (using its corrected form if changed). */
|
|
138
|
+
prevWord?: string;
|
|
139
|
+
/** True when the previous word was a mid-sentence capitalized word (likely a proper name). */
|
|
140
|
+
prevIsName?: boolean;
|
|
141
|
+
/** True when the previous word started with an uppercase letter (including sentence start). */
|
|
142
|
+
prevCapitalized?: boolean;
|
|
143
|
+
/** True when the next word token is isolated (not glued to hyphens, digits, dots, etc.). */
|
|
144
|
+
nextIsolated?: boolean;
|
|
145
|
+
/** True when another word in the same sentence is unmistakably Turkish typed without marks. */
|
|
146
|
+
sentenceHasAsciiTurkish?: boolean;
|
|
147
|
+
}
|
|
148
|
+
export declare function tokenize(text: string): Token[];
|
|
149
|
+
export interface CorrectOptions {
|
|
150
|
+
/**
|
|
151
|
+
* [start, end) ranges whose Turkish letters were put there by autocorrect, not typed by the user. They don't count
|
|
152
|
+
* as evidence that the user types with Turkish letters, so "hic bir sey" still gets "sey" fixed after "hiç" was.
|
|
153
|
+
*/
|
|
154
|
+
autoMarked?: readonly (readonly [number, number])[];
|
|
155
|
+
/**
|
|
156
|
+
* Optional original typed tokens for spans already rewritten by an earlier core typing pass (e.g. "hber" -> "her"),
|
|
157
|
+
* allowing the background context pass to re-evaluate the original typo once the full sentence is available.
|
|
158
|
+
*/
|
|
159
|
+
priorTypoOriginals?: readonly {
|
|
160
|
+
readonly start: number;
|
|
161
|
+
readonly end: number;
|
|
162
|
+
readonly original: string;
|
|
163
|
+
}[];
|
|
164
|
+
}
|
|
165
|
+
export declare class Corrector {
|
|
166
|
+
private readonly lexicon;
|
|
167
|
+
private readonly known?;
|
|
168
|
+
private readonly morphology?;
|
|
169
|
+
settings: Settings;
|
|
170
|
+
constructor(lexicon: Lexicon, settings?: Settings, known?: KnownMisspellings, morphology?: WordValidator);
|
|
171
|
+
/** A word the lexicon has rarely or never seen, but that Turkish suffix rules accept ("getirsek", "kitabımı"). */
|
|
172
|
+
private isRealWord;
|
|
173
|
+
/** True when a stem takes both front locative and front ablative (filters accidental Dat collisions like "varit" -> "varde"). */
|
|
174
|
+
private hasFrontLocative;
|
|
175
|
+
/** True when a stem takes both back locative and back ablative. */
|
|
176
|
+
private hasBackLocative;
|
|
177
|
+
/** True when a -ca/-ce/-ça/-çe stem is derived from a proper/nationality stem ("Danimarkaca", "Türkçe", "Hırvatça"). */
|
|
178
|
+
private isDerivedLanguageStem;
|
|
179
|
+
/** True when a stem is blocked from taking an apostrophe by TDK rules (respecting morphology for -ca/-ce names like "Karaca"). */
|
|
180
|
+
private isBlockedApostropheStem;
|
|
181
|
+
/** True when a form has a bare Noun/Adj/Adv root analysis (used for separate Noun+etmek compound verb splits). */
|
|
182
|
+
private isBareNominalRoot;
|
|
183
|
+
/** True when `word` is an inflected verb form of `auxStem` ("et", "ol", "geç", "vur", ...). */
|
|
184
|
+
private isVerbFormOf;
|
|
185
|
+
/** True when `word` has a finite conjugated verb analysis (never part of an OOV noun compound). */
|
|
186
|
+
private isFiniteVerb;
|
|
187
|
+
/**
|
|
188
|
+
* True when morphology only parses a candidate apostrophe stem as an already-inflected or derived form
|
|
189
|
+
* ("japonların", "yunanlardan", "ankaradan", "türkçeden"), never as an uninflected bare root.
|
|
190
|
+
* Bare personal names that coincide with lowercase inflected words ("Emre", "Selin", "Güler") are preserved.
|
|
191
|
+
*/
|
|
192
|
+
private isInflectedApostropheStem;
|
|
193
|
+
/**
|
|
194
|
+
* Extra morphological/lexical guard for unseen (count === 0) unique mark restorations on long lowercase words:
|
|
195
|
+
* keeps genuine Turkish inflections ("yukleyince", "sisirmesinden", "dalgakiranlarla") while blocking Latin/foreign
|
|
196
|
+
* terms that accidentally match nominal 1st/2nd person copula readings ("alveolusun" -> "alveolüsün").
|
|
197
|
+
*/
|
|
198
|
+
private isSafeUnseenMarkVariant;
|
|
199
|
+
private withSentenceRules;
|
|
200
|
+
/**
|
|
201
|
+
* True when `word` (when `sentenceCase` is enabled) is an unseen lowercase proper name or honorific with an
|
|
202
|
+
* inflectional suffix ("nerminin", "emrenin", "kocaelide", "orhan beyde", "gönül hanımda") that should be
|
|
203
|
+
* handled by TDK proper-name rules instead of being overwritten by a typo/split fix ("merminin", "emrinin", "bey de").
|
|
204
|
+
*/
|
|
205
|
+
private isLowercaseProperForSentence;
|
|
206
|
+
/** Returns the corrected text and the list of changes made. */
|
|
207
|
+
correct(text: string, options?: CorrectOptions): {
|
|
208
|
+
text: string;
|
|
209
|
+
corrections: Correction[];
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Like correct(), but also flags every suspicious untouched word (rejected by morphology or very rare near a
|
|
213
|
+
* much stronger valid word) with up to 5 ranked suggestions.
|
|
214
|
+
*/
|
|
215
|
+
inspect(text: string, options?: CorrectOptions): {
|
|
216
|
+
text: string;
|
|
217
|
+
corrections: Correction[];
|
|
218
|
+
flags: SpellFlag[];
|
|
219
|
+
};
|
|
220
|
+
private runCorePass;
|
|
221
|
+
/**
|
|
222
|
+
* Like correct(), but contested real-word ambiguities ("bende" / "ben de", "oldu" / "öldü", "sevgimi" / "sevgi mi")
|
|
223
|
+
* and ambiguous/contested typo candidates ("yllar" -> "yıllar"/"yollar", "hber" -> "her"/"haber") are scored in
|
|
224
|
+
* sentence context by the context model. Core behavior without a context model is unchanged.
|
|
225
|
+
*/
|
|
226
|
+
correctAsync(text: string, model: ContextModel, options?: CorrectOptions): Promise<{
|
|
227
|
+
text: string;
|
|
228
|
+
corrections: Correction[];
|
|
229
|
+
}>;
|
|
230
|
+
/**
|
|
231
|
+
* Like inspect(), using the context model both to resolve ambiguities and to re-rank flag suggestions in sentence context.
|
|
232
|
+
*/
|
|
233
|
+
inspectAsync(text: string, model: ContextModel, options?: CorrectOptions): Promise<{
|
|
234
|
+
text: string;
|
|
235
|
+
corrections: Correction[];
|
|
236
|
+
flags: SpellFlag[];
|
|
237
|
+
}>;
|
|
238
|
+
private runAsyncPass;
|
|
239
|
+
/**
|
|
240
|
+
* Returns morphologically valid typo/mark candidates (sorted by core score) for an invalid/rare word,
|
|
241
|
+
* along with core margin, threshold, slip cost, and mark-variant flag.
|
|
242
|
+
* Used by `correctAsync()` and Stage 2 training data generation.
|
|
243
|
+
*/
|
|
244
|
+
typoCandidatesFor(typed: string, context: WordContext, nextTyped?: string, maxCandidates?: number): {
|
|
245
|
+
text: string;
|
|
246
|
+
kind: CandidateKind;
|
|
247
|
+
margin: number;
|
|
248
|
+
threshold: number;
|
|
249
|
+
slipCost: number;
|
|
250
|
+
isMarkVariant: boolean;
|
|
251
|
+
}[];
|
|
252
|
+
/** Places where the typed span and another real-word reading compete, for the context model to judge. */
|
|
253
|
+
private contestedSpans;
|
|
254
|
+
/** True when a standalone question particle (mi/mı/mu/mü...) already appears later in the same sentence. */
|
|
255
|
+
private questionParticleAhead;
|
|
256
|
+
/**
|
|
257
|
+
* Words that were clearly typed without Turkish letters ("anlamadim", "sey"): unseen or nearly so as typed, but
|
|
258
|
+
* common with marks. A sentence with one is treated as typed without Turkish letters, even when other words in the
|
|
259
|
+
* text have them, so "hic" next to "anlamadim" still becomes "hiç".
|
|
260
|
+
*/
|
|
261
|
+
private asciiEvidence;
|
|
262
|
+
/** The next word when only a single space separates it from this one. */
|
|
263
|
+
private nextWord;
|
|
264
|
+
private questionAhead;
|
|
265
|
+
/** Words glued to "@", "/", digits or dots between letters are parts of addresses, handles or code. */
|
|
266
|
+
private isIsolated;
|
|
267
|
+
/** Decides on one word, optionally joined with the next. Returns null to leave it alone. */
|
|
268
|
+
check(typed: string, context: WordContext, nextTyped?: string): {
|
|
269
|
+
replacement: string;
|
|
270
|
+
kind: CandidateKind;
|
|
271
|
+
margin: number;
|
|
272
|
+
joinsNext: boolean;
|
|
273
|
+
} | null;
|
|
274
|
+
/**
|
|
275
|
+
* "bende geldim" -> "ben de geldim": a pronoun glued to "de" followed by a finite verb of the same person is the
|
|
276
|
+
* conjunction, never the locative ("Kitap bende kaldı" keeps "bende": the verb there is third person).
|
|
277
|
+
*/
|
|
278
|
+
private pronounAlso;
|
|
279
|
+
/** A listed misspelling wins over everything else when the fix is clearly more common than what was typed. */
|
|
280
|
+
private knownFix;
|
|
281
|
+
private candidates;
|
|
282
|
+
/** Strict 3-letter typo recovery ("bne" -> "ben", "ane" -> "anne"): requires invalid stem, valid very frequent target. */
|
|
283
|
+
private addShortWordTypos;
|
|
284
|
+
/** Recovers glued question particles with a 1-edit slip ("biliyormusunm?" -> "biliyor musun?"). */
|
|
285
|
+
private addQuestionParticleTypoSplits;
|
|
286
|
+
/** Resolves one half of a long glued two-word error (optionally restoring missing Turkish marks). */
|
|
287
|
+
private resolveGluedPart;
|
|
288
|
+
/** Splits two glued words (even with missing Turkish marks: "yapmıyorsunanlamadim" -> "yapmıyorsun anlamadım"). */
|
|
289
|
+
private addTwoWordGluedSplits;
|
|
290
|
+
/** Cautious 2-vowel-drop recovery between consonant clusters ("gelyorm" -> "geliyorum", "çalışıyrm" -> "çalışıyorum"). */
|
|
291
|
+
private addDoubleVowelDrops;
|
|
292
|
+
/** Restores "mi/mu/misin/..." marks from the preceding word's vowels in ASCII-typed sentences. */
|
|
293
|
+
private addQuestionHarmony;
|
|
294
|
+
/** "birsey" -> "bir şey" from how often the pair is seen; "geldinmi", "arenasıda", "diyorki" from grammar and stem. */
|
|
295
|
+
private addSplits;
|
|
296
|
+
/** "Ankaraya" -> "Ankara'ya" when the form is seen, or when "ankara" is a name and "ya" a suffix that takes one. */
|
|
297
|
+
private addApostrophes;
|
|
298
|
+
/** "hiç bir" -> "hiçbir", "oysa ki" -> "oysaki", "ev de" -> "evde", "vaz geçtim" -> "vazgeçtim", "ann e" -> "anne". */
|
|
299
|
+
private joinCandidate;
|
|
300
|
+
/** Count of the longest shorter prefix (4+ letters) that is itself a seen real word: "arkadaşlarım" for "arkadaşlarımla". */
|
|
301
|
+
private stemCount;
|
|
302
|
+
/**
|
|
303
|
+
* Empirical-Bayes effective frequency combining observed corpus count with the principled morphological
|
|
304
|
+
* generative prior `C(lemma, pos) * P(morphemes | pos)` so unseen/rare valid inflections ("düzenlemiyor",
|
|
305
|
+
* "kullandığımda") rank accurately without inflating bizarre stacked derivations.
|
|
306
|
+
*/
|
|
307
|
+
private effectiveCount;
|
|
308
|
+
/** True when every morphological reading of `word` is accusative ("hatalarını", "arabayı", "kitabını"). */
|
|
309
|
+
private isUnambiguousAccusative;
|
|
310
|
+
/** True when every finite verb reading of `word` is passive or intransitive -lAn ("düzenleniyor"). */
|
|
311
|
+
private isPurelyPassiveVerb;
|
|
312
|
+
/**
|
|
313
|
+
* True when `word` is a productive, harmonized nominal inflection of a corpus-attested noun/loanword
|
|
314
|
+
* root missing from Zemberek's static dictionary (e.g. "özgeçmişimi" = "özgeçmiş"+"imi", "tripodlar" = "tripod"+"lar").
|
|
315
|
+
* Never activates for roots Zemberek already knows, so real Turkish root typos are never shielded.
|
|
316
|
+
*/
|
|
317
|
+
private isAttestedOovInflection;
|
|
318
|
+
/** Detects whether an untouched token should be flagged, returning the SpellFlag or null. */
|
|
319
|
+
private detectFlag;
|
|
320
|
+
/**
|
|
321
|
+
* Procedural misspelling detector for words not auto-fixed by `check()`.
|
|
322
|
+
* Separates `invalid` (rejected by morphology & unseen) from `rare` (rejected by morphology, very rare,
|
|
323
|
+
* and close to a much stronger valid Turkish word) while protecting proper names, acronyms, foreign/scientific
|
|
324
|
+
* words, apostrophe forms, contractions, and productive inflections of attested OOV nouns.
|
|
325
|
+
*/
|
|
326
|
+
private detectFlagDetailed;
|
|
327
|
+
/**
|
|
328
|
+
* Builds and ranks up to 5 suggestions for a suspicious word using:
|
|
329
|
+
* 1. Existing rule candidates (marks, splits, apostrophes, short typos, 1-edit lexicon typos, double vowel drops),
|
|
330
|
+
* 2. Fast 1-edit mark-folded fuzzy morphological search (catches unseen valid forms + mark-loss + 1 typo),
|
|
331
|
+
* 3. 2-edit mark-folded fuzzy morphological search when 1-edit doesn't yield strong candidates (double omissions / 2 typos),
|
|
332
|
+
* 4. Principled scoring with empirical-Bayes morphological prior, Turkish keyboard edit cost, bigram support,
|
|
333
|
+
* and Turkish accusative-passive case-voice agreement.
|
|
334
|
+
*/
|
|
335
|
+
private rankedSuggestionsFor;
|
|
336
|
+
/** Words one edit away, with a cost for edits that are unlikely on a Turkish Q keyboard. */
|
|
337
|
+
private oneEdit;
|
|
338
|
+
}
|