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.
Files changed (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +139 -2
  3. package/dist/pkg/src/context.d.ts +13 -0
  4. package/dist/pkg/src/context.js +80 -0
  5. package/dist/pkg/src/data.d.ts +53 -0
  6. package/dist/pkg/src/data.js +498 -0
  7. package/dist/pkg/src/engine.d.ts +39 -0
  8. package/dist/pkg/src/engine.js +357 -0
  9. package/dist/pkg/src/index.d.ts +30 -0
  10. package/dist/pkg/src/index.js +85 -0
  11. package/dist/pkg/src/protocol.d.ts +64 -0
  12. package/dist/pkg/src/protocol.js +1 -0
  13. package/dist/pkg/src/types.d.ts +184 -0
  14. package/dist/pkg/src/types.js +16 -0
  15. package/dist/pkg/src/worker.d.ts +11 -0
  16. package/dist/pkg/src/worker.js +111 -0
  17. package/dist/pkg/src/workerClient.d.ts +3 -0
  18. package/dist/pkg/src/workerClient.js +202 -0
  19. package/dist/src/context-vocab.d.ts +1 -0
  20. package/dist/src/context-vocab.js +2 -0
  21. package/dist/src/context.d.ts +92 -0
  22. package/dist/src/context.js +390 -0
  23. package/dist/src/corrector.d.ts +338 -0
  24. package/dist/src/corrector.js +2684 -0
  25. package/dist/src/known.d.ts +88 -0
  26. package/dist/src/known.js +286 -0
  27. package/dist/src/lexicon-binary.d.ts +85 -0
  28. package/dist/src/lexicon-binary.js +805 -0
  29. package/dist/src/lexicon.d.ts +24 -0
  30. package/dist/src/lexicon.js +79 -0
  31. package/dist/src/morphology/analyzer.d.ts +30 -0
  32. package/dist/src/morphology/analyzer.js +311 -0
  33. package/dist/src/morphology/binary.d.ts +22 -0
  34. package/dist/src/morphology/binary.js +372 -0
  35. package/dist/src/morphology/dictionary.d.ts +21 -0
  36. package/dist/src/morphology/dictionary.js +559 -0
  37. package/dist/src/morphology/fuzzy.d.ts +44 -0
  38. package/dist/src/morphology/fuzzy.js +599 -0
  39. package/dist/src/morphology/index.d.ts +40 -0
  40. package/dist/src/morphology/index.js +81 -0
  41. package/dist/src/morphology/morphotactics.d.ts +148 -0
  42. package/dist/src/morphology/morphotactics.js +1871 -0
  43. package/dist/src/morphology/phonetics.d.ts +71 -0
  44. package/dist/src/morphology/phonetics.js +309 -0
  45. package/dist/src/morphology/prior.d.ts +61 -0
  46. package/dist/src/morphology/prior.js +457 -0
  47. package/dist/src/morphology/types.d.ts +110 -0
  48. package/dist/src/morphology/types.js +32 -0
  49. package/dist/src/rules/proper-names.d.ts +145 -0
  50. package/dist/src/rules/proper-names.js +1217 -0
  51. package/dist/src/rules/turkish-rules.d.ts +126 -0
  52. package/dist/src/rules/turkish-rules.js +365 -0
  53. package/dist/src/sentence.d.ts +83 -0
  54. package/dist/src/sentence.js +2408 -0
  55. package/dist/src/turkish.d.ts +20 -0
  56. package/dist/src/turkish.js +94 -0
  57. package/package.json +60 -4
@@ -0,0 +1,145 @@
1
+ /** Months and weekdays: capitalized per TDK ONLY when tied to a specific calendar date ("17 Aralık'a", "12 Haziran 2027 Cumartesi"). */
2
+ export declare const MONTHS: Set<string>;
3
+ export declare const WEEKDAYS: Set<string>;
4
+ /**
5
+ * TDK institution, organization, board, assembly, and workplace head words (singular/P3sg).
6
+ * Suffixes attached to these take NO apostrophe per TDK ("Türk Dil Kurumundan", "Ankara Üniversitesine",
7
+ * "Bakanlar Kurulunun", "Mavi Köşe Bakkaliyesinden").
8
+ * Exceptions: "Avrupa Birliği'ne" (TDK explicit exception) and "Rusya Federasyonu'na" (state name).
9
+ */
10
+ export declare const INSTITUTION_HEADS: Set<string>;
11
+ /** Officer/leader title heads immediately following a proper institution ("Türk Dil Kurumu Başkanı'na", "Ankara Üniversitesi Rektörü'ne"). */
12
+ export declare const OFFICER_TITLE_HEADS: Set<string>;
13
+ /** Optional preceding modifiers for a 2-word officer title after an institution ("Genel Müdürü", "Genel Başkanı", "Genel Sekreteri", "Başkan Yardımcısı"). */
14
+ export declare const OFFICER_TITLE_MODS: Set<string>;
15
+ /** Institution heads that need an explicit proper-name anchor before them to be capitalized (generic alone: "tıp fakültesi"). */
16
+ export declare const GENERIC_ALONE_INST_HEADS: Set<string>;
17
+ /** Generic modifier words that alone (without a proper-name anchor) form lowercase generic phrases like "tıp fakültesi", "devlet hastanesi", "ilçe belediyesi". */
18
+ export declare const GENERIC_INST_MODIFIERS: Set<string>;
19
+ /** Words that CANNOT serve as an unanchored first word of a compositional institution name (prepositions, verbs, determiners, adjectives). */
20
+ export declare const NON_INST_PREFIX: Set<string>;
21
+ /** TDK geographic, urban, and landmark head words that take capitalization AND apostrophe after a proper name. */
22
+ export declare const GEO_HEADS: Set<string>;
23
+ /** State/polity head words (capitalize + apostrophe after a proper name). */
24
+ export declare const STATE_HEADS: Set<string>;
25
+ /** Historical event/war/treaty/era head words (capitalize + apostrophe after a proper place/nationality). */
26
+ export declare const EVENT_HEADS: Set<string>;
27
+ /** Direction modifiers capitalized BEFORE a proper place ("Batı Anadolu", "Doğu Karadeniz"), never after ("Anadolu'nun batısı"). */
28
+ export declare const DIRECTIONS: Set<string>;
29
+ /** Abbreviated titles placed before a person name ("Prof. Dr. Halil İnalcık", "Av. Melike Sönmez", "Op. Dr. Sinan Güler"). */
30
+ export declare const PRE_TITLES_ABBR: Set<string>;
31
+ /** Unabbreviated titles & ranks capitalized before a person name ("Cumhurbaşkanı İsmet İnönü", "Albay Nurettin Şahin", "Bayan Elif Tan"). */
32
+ export declare const PRE_TITLES_FULL: Set<string>;
33
+ /** Official titles capitalized directly after "Sayın" ("Sayın Başkan", "Sayın Müdür", "Sayın Büyükelçi"; NOT "Sayın hocam"). */
34
+ export declare const SAYIN_TITLES: Set<string>;
35
+ /** First word of a 2-word official title after "Sayın" ("Sayın Genel Müdür", "Sayın Belediye Başkanı", "Sayın Cumhuriyet Başsavcısı"). */
36
+ export declare const SAYIN_COMPOUND_FIRST: Set<string>;
37
+ /** Second/third word continuing an official title after "Sayın" ("Müdür Yardımcısı", "Genel Sekreter", "Belediye Başkanı"). */
38
+ export declare const SAYIN_COMPOUND_TAIL: Set<string>;
39
+ /** Post-nominal honorific titles (capitalized AND take apostrophe after a person name: "Ayşe Hanım'a", "Orhan Bey'de"). */
40
+ export declare const POST_HONORIFICS: Set<string>;
41
+ /** Post-nominal occupational/historical titles capitalized + apostrophe after a person name ("Ahmet Hoca'ya", "Mehmet Usta'nın", "Ali Çavuş'un", "Seyit Onbaşı'yı", "Temel Kaptan'a"). */
42
+ export declare const POST_TITLES_WITH_APOS: Set<string>;
43
+ /** Kinship words after a person name: stay LOWERCASE per TDK ("Tülay ablama", "Zehra halamın"), while proving the previous word is a person name. */
44
+ export declare const KINSHIP_STEMS: Set<string>;
45
+ /** Nominative person-relationship/occupation descriptors right before a person name ("arkadaşım Melek", "kardeşim Ateş", "komşumuz Bahar'ın", "yazar Defne Arslan"). */
46
+ export declare const PERSON_REL_BEFORE: Set<string>;
47
+ /** Lowercase media/work type words following a capitalized work/publication title ("Varlık dergisine", "Muhsin Bey filmini"). */
48
+ export declare const MEDIA_TYPE_STEMS: Set<string>;
49
+ /** Language names (always capitalized, NEVER take an apostrophe before suffixes: "Türkçeyi", "Almancaya", "Yunancanın"). */
50
+ export declare const LANGUAGE_NAMES: Set<string>;
51
+ /** Religion/sect/ideology derived proper nouns with Turkish derivational suffixes (-lIk/-lI/-cI) that strictly take NO apostrophe per TDK ("Hristiyanlıkta", "Müslümanlık"). */
52
+ export declare const NO_APOS_RELIGION_OR_DERIVED: Set<string>;
53
+ /** Foreign/Arabic -izm/-iyet religion & movement names: capitalize without forcing apostrophe when joined ("hinduizmde" -> "Hinduizmde"),
54
+ * but NEVER strip an existing apostrophe ("İslamiyet'e", "Budizm'in", "Hinduizm'de" stay intact). */
55
+ export declare const OPTIONAL_APOS_ISM_IYET: Set<string>;
56
+ /** Proper names whose own root ends in -lar/-ler (places, ranges) and therefore DO keep an apostrophe. */
57
+ export declare const PLURAL_PLACE_KEEP_APOS: Set<string>;
58
+ /** Proper names whose own root ends in -lı/-li/-lık/-ca/-ce and therefore DO keep an apostrophe. */
59
+ export declare const DERIV_LOOKING_KEEP_APOS: Set<string>;
60
+ /** Returns true when `stem` is an institution head in context (accounting for TDK exceptions "Avrupa Birliği", "Rusya Federasyonu", "Kutup Dairesi", "Elçilerin İşleri"). */
61
+ export declare function isInstitutionHead(lowerStem: string, prevLower?: string): boolean;
62
+ /**
63
+ * Joins `stem + suffix` when removing a wrong apostrophe, applying Turkish final consonant softening
64
+ * (k->ğ, p->b, ç->c, t->d) before a vowel-initial suffix whenever appropriate ("Hristiyanlık'ın" -> "Hristiyanlığın",
65
+ * "Atatürkçülük'ün" -> "Atatürkçülüğün", "kitap'ı" -> "kitabı", "ağaç'a" -> "ağaca").
66
+ */
67
+ export declare function joinWithoutApostrophe(stem: string, suffix: string, isMorphWord: (lower: string) => boolean): string;
68
+ /**
69
+ * Validates and fixes Turkish inflectional/ordinal suffixes attached to a number ("1985te" -> "1985'te",
70
+ * "2023de" -> "2023'te", "1985'de" -> "1985'te", "1990larda" -> "1990'larda", "2nci" -> "2'nci").
71
+ * Returns the fixed suffix (to be placed after `'`) or null if untouched/invalid.
72
+ */
73
+ export declare function fixNumberSuffix(numStr: string, rawSuffix: string, hadApostrophe: boolean): string | null;
74
+ /** Suffix starts with a TDK derivational or plural suffix (never preceded by an apostrophe on non-acronym proper nouns). */
75
+ export declare const NON_APOSTROPHE_SUFFIX_RE: RegExp;
76
+ /**
77
+ * Valid Turkish inflectional suffixes that attach with an apostrophe to a bare proper noun.
78
+ * Covers case, possessive (+ case; mandatory buffer 'n' after 3sg -sI/-I), -ki (+ plural/case), instrumental, and copula/predicative endings.
79
+ */
80
+ export declare const PROPER_INFLECTIONAL_SUFFIX_RE: RegExp;
81
+ /**
82
+ * Valid Turkish inflectional suffix attached to a P3sg vowel-final head word (e.g. "Üniversitesi" + "nde",
83
+ * "Bakanlığı" + "na", "Parkı" + "nda", "Camisi" + "nin", "Gazete" + "de", "Savaşı" + "nı").
84
+ */
85
+ export declare const HEAD_SUFFIX_RE: RegExp;
86
+ /** Suffixes after a no-apostrophe proper noun (languages, nationalities, religions, derivations, plurals). */
87
+ export declare const NO_APOS_PROPER_SUFFIX_RE: RegExp;
88
+ export declare function isInverseFrontStem(stem: string): boolean;
89
+ /**
90
+ * Checks whether `suffix` phonologically attaches to `stem` (vowel harmony, buffer letters, voicing assimilation).
91
+ * When `acronym` is true, letter-by-letter pronunciation rules apply so harmony is relaxed.
92
+ */
93
+ export declare function isPhonologicallyValidProperSuffix(stem: string, suffix: string, options?: {
94
+ acronym?: boolean;
95
+ p3sgHead?: boolean;
96
+ }): boolean;
97
+ /**
98
+ * Restores ASCII-stripped Turkish vowels inside a suffix to harmonize with `stem` ("burak" + "in" -> "ın",
99
+ * "kibris" + "ta" -> "ta", "oya" + "nin" -> "nın", "turkiye" + "mizin" -> "mizin").
100
+ * Returns the harmonized suffix if valid, or null if the suffix cannot harmonize with `stem`.
101
+ */
102
+ export declare function harmonizeAsciiSuffix(stem: string, rawSuffix: string, options?: {
103
+ p3sgHead?: boolean;
104
+ }): string | null;
105
+ /** Checks if `word` is an inflected kinship word ("ablama", "halamın", "enişteme", "ninemin", "teyzem", "amcam"). */
106
+ export declare function isKinshipWord(lower: string): boolean;
107
+ /** Checks if `word` is an inflected media/work type word ("dergisine", "filmini", "dizisini", "romanını", "kitabını", "gazetesinde"). */
108
+ export declare function isMediaTypeWord(lower: string): boolean;
109
+ /** Capitalizes the first character of a Turkish word using Turkish casing (`i` -> `İ`, `ı` -> `I`). */
110
+ export declare function capTr(word: string): string;
111
+ export declare function foldTurkish(word: string): string;
112
+ /** True when a word looks like a bare or suffixed honorific ("bey", "beye", "beyi", "beyin", "beyde", "hanım", "hanımı", "hanımın", "hanımda", "efendiye", "paşanın", "ağa'nın"). */
113
+ export declare function splitHonorific(lower: string): {
114
+ head: string;
115
+ displayHead: string;
116
+ suffix: string;
117
+ hadApostrophe: boolean;
118
+ } | null;
119
+ /** Splits a post-nominal title (`POST_TITLES_WITH_APOS`: "hoca", "usta", "çavuş", "onbaşı", "kaptan", "öğretmen", ...) + optional inflectional suffix. */
120
+ export declare function splitPostTitle(lower: string): {
121
+ head: string;
122
+ displayHead: string;
123
+ suffix: string;
124
+ hadApostrophe: boolean;
125
+ } | null;
126
+ /** Splits an institution/geo/state/event head word + optional inflectional suffix ("üniversitesinde" -> head="üniversitesi", suffix="nde"). */
127
+ export declare function splitHeadWord(lower: string, headSet: ReadonlySet<string>): {
128
+ head: string;
129
+ suffix: string;
130
+ hadApostrophe: boolean;
131
+ } | null;
132
+ /** Splits a month or weekday name + optional inflectional suffix ("aralıka" -> "aralık" + "a", "pazartesinin" -> "pazartesi" + "nin"). */
133
+ export declare function splitCalendarWord(lower: string, set: ReadonlySet<string>): {
134
+ stem: string;
135
+ suffix: string;
136
+ hadApostrophe: boolean;
137
+ } | null;
138
+ /** Returns true when `word` is an internal lowercase conjunction inside a multi-word proper name ("ve", "ile", "ya", "veya", "de", "da"). */
139
+ export declare const TITLE_CONJUNCTIONS: Set<string>;
140
+ /** Optional contextual gate for multi-word canonical phrases that overlap with ordinary Turkish phrases. */
141
+ export type PhraseContext = "era" | "day" | "work";
142
+ /** Canonical multi-word Turkish holidays, special days, historical events/eras, and landmark/work phrases. */
143
+ export declare const CANONICAL_PHRASES: ReadonlyArray<readonly [display: string, apos: boolean, context?: PhraseContext]>;
144
+ /** Check if a lowercase string has any vowel. */
145
+ export declare function hasVowel(s: string): boolean;