tdk-api-wrapper 1.6.0 → 1.7.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 +21 -1
- package/dist/chunk-MELLECWT.mjs +279 -0
- package/dist/cli.js +2444 -2114
- package/dist/cli.mjs +11 -4
- package/dist/index.d.mts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +277 -2
- package/dist/index.mjs +7 -1
- package/dist/mcp-NAXIX4TQ.mjs +9 -0
- package/package.json +33 -5
- package/.github/workflows/publish.yml +0 -41
- package/src/cli.ts +0 -535
- package/src/errors.ts +0 -38
- package/src/index.ts +0 -4
- package/src/morphology.ts +0 -333
- package/src/tdk.ts +0 -2056
- package/src/types.ts +0 -185
- package/test/grammar.test.js +0 -52
- package/test/morphology.test.js +0 -140
- package/test/proofread.test.js +0 -88
- package/test/tools.test.js +0 -51
- package/tsconfig.json +0 -11
package/src/types.ts
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
export interface Author {
|
|
2
|
-
yazar_id: string;
|
|
3
|
-
tam_adi: string;
|
|
4
|
-
kisa_adi: string;
|
|
5
|
-
ekno: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface Example {
|
|
9
|
-
ornek_id: string;
|
|
10
|
-
anlam_id: string;
|
|
11
|
-
ornek_sira: string;
|
|
12
|
-
ornek: string;
|
|
13
|
-
kac: string;
|
|
14
|
-
yazar_id: string;
|
|
15
|
-
yazar_vd: string;
|
|
16
|
-
yazar?: Author[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface Feature {
|
|
20
|
-
ozellik_id: string;
|
|
21
|
-
tur: string;
|
|
22
|
-
tam_adi: string;
|
|
23
|
-
kisa_adi: string;
|
|
24
|
-
ekno: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface Meaning {
|
|
28
|
-
anlam_id: string;
|
|
29
|
-
madde_id: string;
|
|
30
|
-
anlam_sira: string;
|
|
31
|
-
fiil: string;
|
|
32
|
-
tipkes: string;
|
|
33
|
-
anlam: string;
|
|
34
|
-
anlam_html: string | null;
|
|
35
|
-
gos: string;
|
|
36
|
-
gos_kelime: string;
|
|
37
|
-
gos_kultur: string;
|
|
38
|
-
orneklerListe?: Example[];
|
|
39
|
-
ozelliklerListe?: Feature[];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface Proverb {
|
|
43
|
-
madde_id: string;
|
|
44
|
-
madde: string;
|
|
45
|
-
on_taki: string | null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface WordInfo {
|
|
49
|
-
madde_id: string;
|
|
50
|
-
kac: string;
|
|
51
|
-
kelime_no: string;
|
|
52
|
-
cesit: string;
|
|
53
|
-
anlam_gor: string;
|
|
54
|
-
on_taki: string | null;
|
|
55
|
-
on_taki_html: string | null;
|
|
56
|
-
madde: string;
|
|
57
|
-
madde_html: string | null;
|
|
58
|
-
cesit_say: string;
|
|
59
|
-
anlam_say: string;
|
|
60
|
-
taki: string;
|
|
61
|
-
cogul_mu: string;
|
|
62
|
-
ozel_mi: string;
|
|
63
|
-
egik_mi: string;
|
|
64
|
-
lisan_kodu: string;
|
|
65
|
-
lisan: string;
|
|
66
|
-
telaffuz_html: string | null;
|
|
67
|
-
telaffuz: string;
|
|
68
|
-
birlesikler: string | null;
|
|
69
|
-
font: string | null;
|
|
70
|
-
madde_duz: string;
|
|
71
|
-
gosterim_tarihi: string | null;
|
|
72
|
-
anlamlarListe?: Meaning[];
|
|
73
|
-
atasozu?: Proverb[];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface DailyContent {
|
|
77
|
-
kelime: { madde: string; anlam: string }[];
|
|
78
|
-
atasoz: { madde: string; anlam: string }[];
|
|
79
|
-
kural: { adi: string; url: string }[];
|
|
80
|
-
syyd: { id: string; yanliskelime: string; dogrukelime: string }[];
|
|
81
|
-
karistirma: { id: string; yanlis: string; dogru: string }[];
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface SpellCheckResult {
|
|
85
|
-
isCorrect: boolean;
|
|
86
|
-
word: string;
|
|
87
|
-
suggestion?: string;
|
|
88
|
-
isInflected?: boolean;
|
|
89
|
-
root?: string;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export interface StemResult {
|
|
93
|
-
word: string;
|
|
94
|
-
root: string;
|
|
95
|
-
isInflected: boolean;
|
|
96
|
-
candidates?: string[];
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface WordOfTheDay {
|
|
100
|
-
word: string;
|
|
101
|
-
meanings: string[];
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export interface DailyPick {
|
|
105
|
-
type: "kelime" | "atasoz";
|
|
106
|
-
madde: string;
|
|
107
|
-
anlam: string;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export interface TDKRule {
|
|
111
|
-
adi: string;
|
|
112
|
-
url: string;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export interface WordComparisonSide {
|
|
116
|
-
word: string;
|
|
117
|
-
meaningCount: number;
|
|
118
|
-
origin: string | null;
|
|
119
|
-
syllables: string[];
|
|
120
|
-
harmony: boolean;
|
|
121
|
-
labialHarmony?: boolean;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export interface WordComparison {
|
|
125
|
-
a: WordComparisonSide;
|
|
126
|
-
b: WordComparisonSide;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export interface WordAnalysis {
|
|
130
|
-
word: string;
|
|
131
|
-
found: boolean;
|
|
132
|
-
meaning: string | null;
|
|
133
|
-
origin: string | null;
|
|
134
|
-
root?: string;
|
|
135
|
-
isInflected?: boolean;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export interface ProofreadIssue {
|
|
139
|
-
type: "spelling" | "conjunction_da" | "conjunction_ki" | "question_particle";
|
|
140
|
-
word: string;
|
|
141
|
-
startIndex: number;
|
|
142
|
-
endIndex: number;
|
|
143
|
-
suggestion?: string;
|
|
144
|
-
message: string;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export interface ProofreadResult {
|
|
148
|
-
text: string;
|
|
149
|
-
issues: ProofreadIssue[];
|
|
150
|
-
isCorrect: boolean;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export interface PatternSearchOptions {
|
|
154
|
-
maxResults?: number;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export interface AnagramOptions {
|
|
158
|
-
exactLength?: boolean;
|
|
159
|
-
maxResults?: number;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export interface RhymeOptions {
|
|
163
|
-
minLetters?: number;
|
|
164
|
-
maxResults?: number;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export interface TDKConfig {
|
|
168
|
-
timeoutMs?: number;
|
|
169
|
-
retries?: number;
|
|
170
|
-
cache?: boolean;
|
|
171
|
-
maxCacheSize?: number;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export interface KubbealtiEntry {
|
|
175
|
-
kelime: string;
|
|
176
|
-
anlam: string;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export interface WiktionaryEntry {
|
|
180
|
-
raw: string;
|
|
181
|
-
sections: Record<string, string>;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export type TDKResponse = WordInfo[] | { error: string };
|
|
185
|
-
|
package/test/grammar.test.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const assert = require("node:assert");
|
|
2
|
-
const { TDK } = require("../dist/index.js");
|
|
3
|
-
|
|
4
|
-
async function runTests() {
|
|
5
|
-
console.log("=== Running Grammar & Phonology Unit Tests ===");
|
|
6
|
-
|
|
7
|
-
// 1. Büyük Ünlü Uyumu (Major Vowel Harmony)
|
|
8
|
-
console.log("1. Testing checkVowelHarmony (Büyük Ünlü Uyumu)...");
|
|
9
|
-
assert.strictEqual(TDK.checkVowelHarmony("adım"), true);
|
|
10
|
-
assert.strictEqual(TDK.checkVowelHarmony("kapı"), true);
|
|
11
|
-
assert.strictEqual(TDK.checkVowelHarmony("gözlük"), true);
|
|
12
|
-
assert.strictEqual(TDK.checkVowelHarmony("otobüs"), false);
|
|
13
|
-
assert.strictEqual(TDK.checkVowelHarmony("kalem"), false);
|
|
14
|
-
assert.strictEqual(TDK.checkVowelHarmony("kitap"), false);
|
|
15
|
-
assert.strictEqual(TDK.checkVowelHarmony("ev"), true);
|
|
16
|
-
console.log(" ✓ checkVowelHarmony passed.");
|
|
17
|
-
|
|
18
|
-
// 2. Küçük Ünlü Uyumu (Minor Vowel / Labial Harmony)
|
|
19
|
-
console.log("2. Testing checkLabialHarmony (Küçük Ünlü Uyumu)...");
|
|
20
|
-
assert.strictEqual(TDK.checkLabialHarmony("elma"), true);
|
|
21
|
-
assert.strictEqual(TDK.checkLabialHarmony("kalem"), true);
|
|
22
|
-
assert.strictEqual(TDK.checkLabialHarmony("odun"), true);
|
|
23
|
-
assert.strictEqual(TDK.checkLabialHarmony("kömür"), true);
|
|
24
|
-
assert.strictEqual(TDK.checkLabialHarmony("çocuk"), true);
|
|
25
|
-
assert.strictEqual(TDK.checkLabialHarmony("armut"), false);
|
|
26
|
-
assert.strictEqual(TDK.checkLabialHarmony("yağmur"), false);
|
|
27
|
-
assert.strictEqual(TDK.checkLabialHarmony("tavuk"), false);
|
|
28
|
-
assert.strictEqual(TDK.checkLabialHarmony("doktor"), false);
|
|
29
|
-
assert.strictEqual(TDK.checkLabialHarmony("horoz"), false);
|
|
30
|
-
assert.strictEqual(TDK.checkLabialHarmony("müzik"), false);
|
|
31
|
-
assert.strictEqual(TDK.checkLabialHarmony("ev"), true);
|
|
32
|
-
console.log(" ✓ checkLabialHarmony passed.");
|
|
33
|
-
|
|
34
|
-
// 3. Heceleme (Syllabification)
|
|
35
|
-
console.log("3. Testing syllabicate...");
|
|
36
|
-
assert.deepStrictEqual(TDK.syllabicate("kalem"), ["ka", "lem"]);
|
|
37
|
-
assert.deepStrictEqual(TDK.syllabicate("ilkokul"), ["il", "ko", "kul"]);
|
|
38
|
-
assert.deepStrictEqual(TDK.syllabicate("muvaffakiyet"), ["mu", "vaf", "fa", "ki", "yet"]);
|
|
39
|
-
assert.deepStrictEqual(TDK.syllabicate("elektrik"), ["e", "lek", "trik"]);
|
|
40
|
-
assert.deepStrictEqual(TDK.syllabicate("kontrol"), ["kon", "trol"]);
|
|
41
|
-
assert.deepStrictEqual(TDK.syllabicate("orkestra"), ["or", "kes", "tra"]);
|
|
42
|
-
assert.deepStrictEqual(TDK.syllabicate("kral"), ["kral"]);
|
|
43
|
-
assert.deepStrictEqual(TDK.syllabicate("tren"), ["tren"]);
|
|
44
|
-
console.log(" ✓ syllabicate passed.");
|
|
45
|
-
|
|
46
|
-
console.log("\n All grammar & phonology tests passed successfully!");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
runTests().catch((err) => {
|
|
50
|
-
console.error("Test failed:", err);
|
|
51
|
-
process.exit(1);
|
|
52
|
-
});
|
package/test/morphology.test.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
const assert = require("node:assert");
|
|
2
|
-
const {
|
|
3
|
-
TDK,
|
|
4
|
-
getStemCandidates,
|
|
5
|
-
restoreConsonantSoftening,
|
|
6
|
-
restoreVowelDrop,
|
|
7
|
-
restoreInfinitive,
|
|
8
|
-
restoreGemination,
|
|
9
|
-
restoreVowelNarrowing,
|
|
10
|
-
} = require("../dist/index.js");
|
|
11
|
-
|
|
12
|
-
async function runTests() {
|
|
13
|
-
console.log("=== Running Morphology Unit & Integration Tests ===");
|
|
14
|
-
|
|
15
|
-
// 1. Phonology helpers
|
|
16
|
-
console.log("1. Testing phonology helper functions...");
|
|
17
|
-
assert.deepStrictEqual(restoreConsonantSoftening("kitab"), ["kitap"]);
|
|
18
|
-
assert.deepStrictEqual(restoreConsonantSoftening("çocuğ"), ["çocuk"]);
|
|
19
|
-
assert.deepStrictEqual(restoreConsonantSoftening("ağac"), ["ağaç"]);
|
|
20
|
-
assert.deepStrictEqual(restoreConsonantSoftening("kanad"), ["kanat"]);
|
|
21
|
-
assert.deepStrictEqual(restoreConsonantSoftening("reng"), ["renk"]);
|
|
22
|
-
assert.deepStrictEqual(restoreVowelDrop("akl"), ["akıl"]);
|
|
23
|
-
assert.deepStrictEqual(restoreVowelDrop("şehr"), ["şehir"]);
|
|
24
|
-
assert.deepStrictEqual(restoreVowelDrop("omz"), ["omuz"]);
|
|
25
|
-
assert.deepStrictEqual(restoreInfinitive("oku"), ["okumak"]);
|
|
26
|
-
assert.deepStrictEqual(restoreInfinitive("gel"), ["gelmek"]);
|
|
27
|
-
assert.deepStrictEqual(restoreGemination("hakk"), ["hak"]);
|
|
28
|
-
assert.deepStrictEqual(restoreGemination("hiss"), ["his"]);
|
|
29
|
-
assert.deepStrictEqual(restoreGemination("redd"), ["red", "ret"]);
|
|
30
|
-
assert.deepStrictEqual(restoreGemination("aff"), ["af"]);
|
|
31
|
-
assert.deepStrictEqual(restoreVowelNarrowing("başlı"), ["başla"]);
|
|
32
|
-
assert.deepStrictEqual(restoreVowelNarrowing("bekli"), ["bekle"]);
|
|
33
|
-
assert.deepStrictEqual(restoreVowelNarrowing("di"), ["de"]);
|
|
34
|
-
assert.deepStrictEqual(restoreVowelNarrowing("yi"), ["ye"]);
|
|
35
|
-
console.log(" ✓ Phonology helpers passed.");
|
|
36
|
-
|
|
37
|
-
// 2. Candidate generation
|
|
38
|
-
console.log("2. Testing getStemCandidates...");
|
|
39
|
-
const c1 = getStemCandidates("halılarımızın");
|
|
40
|
-
assert(c1.includes("halı"), "halılarımızın must contain halı");
|
|
41
|
-
|
|
42
|
-
const c2 = getStemCandidates("kitabımız");
|
|
43
|
-
assert(c2.includes("kitap"), "kitabımız must contain kitap");
|
|
44
|
-
|
|
45
|
-
const c3 = getStemCandidates("çocuğa");
|
|
46
|
-
assert(c3.includes("çocuk"), "çocuğa must contain çocuk");
|
|
47
|
-
|
|
48
|
-
const c4 = getStemCandidates("şehre");
|
|
49
|
-
assert(c4.includes("şehir"), "şehre must contain şehir");
|
|
50
|
-
|
|
51
|
-
const c5 = getStemCandidates("aklımızda");
|
|
52
|
-
assert(c5.includes("akıl"), "aklımızda must contain akıl");
|
|
53
|
-
|
|
54
|
-
const c6 = getStemCandidates("okuyoruz");
|
|
55
|
-
assert(c6.includes("okumak"), "okuyoruz must contain okumak");
|
|
56
|
-
|
|
57
|
-
const c7 = getStemCandidates("gideceğiz");
|
|
58
|
-
assert(c7.includes("gitmek"), "gideceğiz must contain gitmek");
|
|
59
|
-
|
|
60
|
-
const c8 = getStemCandidates("İstanbul'da");
|
|
61
|
-
assert(c8.includes("istanbul"), "İstanbul'da must contain istanbul");
|
|
62
|
-
console.log(" ✓ Candidate generation passed.");
|
|
63
|
-
|
|
64
|
-
// 3. TDK.isHeadword
|
|
65
|
-
console.log("3. Testing TDK.isHeadword...");
|
|
66
|
-
assert.strictEqual(await TDK.isHeadword("halı"), true);
|
|
67
|
-
assert.strictEqual(await TDK.isHeadword("kitap"), true);
|
|
68
|
-
assert.strictEqual(await TDK.isHeadword("okumak"), true);
|
|
69
|
-
assert.strictEqual(await TDK.isHeadword("gelmek"), true);
|
|
70
|
-
assert.strictEqual(await TDK.isHeadword("asdfqwertyzzz"), false);
|
|
71
|
-
console.log(" ✓ TDK.isHeadword passed.");
|
|
72
|
-
|
|
73
|
-
// 4. TDK.findRoot
|
|
74
|
-
console.log("4. Testing TDK.findRoot...");
|
|
75
|
-
assert.strictEqual(await TDK.findRoot("halılarımızın"), "halı");
|
|
76
|
-
assert.strictEqual(await TDK.findRoot("kitabımız"), "kitap");
|
|
77
|
-
assert.strictEqual(await TDK.findRoot("okuyoruz"), "okumak");
|
|
78
|
-
assert.strictEqual(await TDK.findRoot("çocukların"), "çocuk");
|
|
79
|
-
assert.strictEqual(await TDK.findRoot("kitap"), "kitap");
|
|
80
|
-
assert.strictEqual(await TDK.findRoot("hakkımızda"), "hak");
|
|
81
|
-
assert.strictEqual(await TDK.findRoot("başlıyor"), "başlamak");
|
|
82
|
-
assert.strictEqual(await TDK.findRoot("diyor"), "demek");
|
|
83
|
-
console.log(" ✓ TDK.findRoot passed.");
|
|
84
|
-
|
|
85
|
-
// 5. TDK.stem
|
|
86
|
-
console.log("5. Testing TDK.stem...");
|
|
87
|
-
const stem1 = await TDK.stem("halılarımızın");
|
|
88
|
-
assert(stem1 !== null);
|
|
89
|
-
assert.strictEqual(stem1.root, "halı");
|
|
90
|
-
assert.strictEqual(stem1.isInflected, true);
|
|
91
|
-
|
|
92
|
-
const stem2 = await TDK.stem("kitap");
|
|
93
|
-
assert(stem2 !== null);
|
|
94
|
-
assert.strictEqual(stem2.root, "kitap");
|
|
95
|
-
assert.strictEqual(stem2.isInflected, false);
|
|
96
|
-
|
|
97
|
-
const stem3 = await TDK.stem("hakkımızda");
|
|
98
|
-
assert(stem3 !== null);
|
|
99
|
-
assert.strictEqual(stem3.root, "hak");
|
|
100
|
-
assert.strictEqual(stem3.isInflected, true);
|
|
101
|
-
console.log(" ✓ TDK.stem passed.");
|
|
102
|
-
|
|
103
|
-
// 6. TDK.checkSpelling with morphology fallback
|
|
104
|
-
console.log("6. Testing TDK.checkSpelling with morphology fallback...");
|
|
105
|
-
const sp1 = await TDK.checkSpelling("halılarımızın");
|
|
106
|
-
assert.strictEqual(sp1.isCorrect, true);
|
|
107
|
-
assert.strictEqual(sp1.isInflected, true);
|
|
108
|
-
assert.strictEqual(sp1.root, "halı");
|
|
109
|
-
|
|
110
|
-
const sp2 = await TDK.checkSpelling("kitabımız");
|
|
111
|
-
assert.strictEqual(sp2.isCorrect, true);
|
|
112
|
-
assert.strictEqual(sp2.isInflected, true);
|
|
113
|
-
assert.strictEqual(sp2.root, "kitap");
|
|
114
|
-
|
|
115
|
-
const sp3 = await TDK.checkSpelling("yanlız");
|
|
116
|
-
assert.strictEqual(sp3.isCorrect, false);
|
|
117
|
-
assert.strictEqual(sp3.suggestion, "yalnız");
|
|
118
|
-
|
|
119
|
-
const sp4 = await TDK.checkSpelling("asdfxyz12345");
|
|
120
|
-
assert.strictEqual(sp4.isCorrect, false);
|
|
121
|
-
|
|
122
|
-
// Keyboard-aware ranking: "swlam" -> "selam" because w and e are horizontal
|
|
123
|
-
// neighbours on a Turkish Q keyboard (w->a is only a diagonal slip, so "salam" loses).
|
|
124
|
-
const sp5 = await TDK.checkSpelling("swlam");
|
|
125
|
-
assert.strictEqual(sp5.isCorrect, false);
|
|
126
|
-
assert.strictEqual(sp5.suggestion, "selam");
|
|
127
|
-
|
|
128
|
-
// Neighbouring-key substitution beats an equidistant headword: s and a are adjacent.
|
|
129
|
-
const sp6 = await TDK.checkSpelling("arabs");
|
|
130
|
-
assert.strictEqual(sp6.isCorrect, false);
|
|
131
|
-
assert.strictEqual(sp6.suggestion, "araba");
|
|
132
|
-
console.log(" ✓ TDK.checkSpelling passed.");
|
|
133
|
-
|
|
134
|
-
console.log("\n All morphology tests passed successfully!");
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
runTests().catch((err) => {
|
|
138
|
-
console.error("Test failed:", err);
|
|
139
|
-
process.exit(1);
|
|
140
|
-
});
|
package/test/proofread.test.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
const assert = require("node:assert");
|
|
2
|
-
const { TDK } = require("../dist/index.js");
|
|
3
|
-
|
|
4
|
-
async function runTests() {
|
|
5
|
-
console.log("=== Running Proofread Unit & Integration Tests ===");
|
|
6
|
-
|
|
7
|
-
// 1. Question Particle 'mi/mı/mu/mü'
|
|
8
|
-
console.log("1. Testing question particle detection...");
|
|
9
|
-
const q1 = await TDK.proofread("Sen dün okula gittinmi?");
|
|
10
|
-
assert.strictEqual(q1.isCorrect, false);
|
|
11
|
-
assert.strictEqual(q1.issues.length, 1);
|
|
12
|
-
assert.strictEqual(q1.issues[0].type, "question_particle");
|
|
13
|
-
assert.strictEqual(q1.issues[0].suggestion, "gittin mi");
|
|
14
|
-
console.log(" ✓ Question particle passed.");
|
|
15
|
-
|
|
16
|
-
// 2. Conjunction 'da/de'
|
|
17
|
-
console.log("2. Testing conjunction da/de detection...");
|
|
18
|
-
const d1 = await TDK.proofread("Sen gitsende ben kalacağım.");
|
|
19
|
-
assert.strictEqual(d1.isCorrect, false);
|
|
20
|
-
assert.strictEqual(d1.issues.length, 1);
|
|
21
|
-
assert.strictEqual(d1.issues[0].type, "conjunction_da");
|
|
22
|
-
assert.strictEqual(d1.issues[0].suggestion, "gitsen de");
|
|
23
|
-
|
|
24
|
-
// Normal locative 'evde' should NOT trigger issue
|
|
25
|
-
const d2 = await TDK.proofread("Bugün evde oturdum.");
|
|
26
|
-
assert.strictEqual(d2.isCorrect, true);
|
|
27
|
-
assert.strictEqual(d2.issues.length, 0);
|
|
28
|
-
console.log(" ✓ Conjunction da/de passed.");
|
|
29
|
-
|
|
30
|
-
// 3. Conjunction 'ki'
|
|
31
|
-
console.log("3. Testing conjunction ki detection...");
|
|
32
|
-
const k1 = await TDK.proofread("Anladımki beni dinlemiyorsun.");
|
|
33
|
-
assert.strictEqual(k1.isCorrect, false);
|
|
34
|
-
assert.strictEqual(k1.issues.length, 1);
|
|
35
|
-
assert.strictEqual(k1.issues[0].type, "conjunction_ki");
|
|
36
|
-
assert.strictEqual(k1.issues[0].suggestion, "anladım ki");
|
|
37
|
-
|
|
38
|
-
// SOMBAHÇEMİ exceptions like 'çünkü', 'oysaki' should NOT trigger issue
|
|
39
|
-
const k2 = await TDK.proofread("Oysaki seni çok sevmiştim çünkü güzeldin.");
|
|
40
|
-
assert.strictEqual(k2.isCorrect, true);
|
|
41
|
-
assert.strictEqual(k2.issues.length, 0);
|
|
42
|
-
console.log(" ✓ Conjunction ki passed.");
|
|
43
|
-
|
|
44
|
-
// 4. Combined sentence
|
|
45
|
-
console.log("4. Testing combined sentence proofread...");
|
|
46
|
-
const combo = await TDK.proofread("Gördümki gelmedin, bilsende gelirdin ve yaptınmı?");
|
|
47
|
-
assert.strictEqual(combo.isCorrect, false);
|
|
48
|
-
assert.strictEqual(combo.issues.length, 3);
|
|
49
|
-
assert.strictEqual(combo.issues.some((i) => i.type === "conjunction_ki"), true);
|
|
50
|
-
assert.strictEqual(combo.issues.some((i) => i.type === "conjunction_da"), true);
|
|
51
|
-
assert.strictEqual(combo.issues.some((i) => i.type === "question_particle"), true);
|
|
52
|
-
console.log(" ✓ Combined proofread passed.");
|
|
53
|
-
|
|
54
|
-
// 5. Şey detachment check (herşey, hersey, birşeyler -> her şey, bir şeyler)
|
|
55
|
-
console.log("5. Testing -şey detachment...");
|
|
56
|
-
const s1 = await TDK.proofread("burda herşey yolunda");
|
|
57
|
-
assert.strictEqual(s1.isCorrect, false);
|
|
58
|
-
assert.strictEqual(s1.issues.length, 2);
|
|
59
|
-
assert.strictEqual(s1.issues[0].word, "burda");
|
|
60
|
-
assert.strictEqual(s1.issues[0].suggestion, "burada");
|
|
61
|
-
assert.strictEqual(s1.issues[1].word, "herşey");
|
|
62
|
-
assert.strictEqual(s1.issues[1].suggestion, "her şey");
|
|
63
|
-
|
|
64
|
-
const s2 = await TDK.proofread("hersey çok güzel");
|
|
65
|
-
assert.strictEqual(s2.isCorrect, false);
|
|
66
|
-
assert.strictEqual(s2.issues[0].word, "hersey");
|
|
67
|
-
assert.strictEqual(s2.issues[0].suggestion, "her şey");
|
|
68
|
-
console.log(" ✓ -şey detachment passed.");
|
|
69
|
-
|
|
70
|
-
// 6. Erroneously separated compound phrases (hiç bir, bir çok, git gide)
|
|
71
|
-
console.log("6. Testing compound phrases...");
|
|
72
|
-
const p1 = await TDK.proofread("hiç bir şey bilmiyor");
|
|
73
|
-
assert.strictEqual(p1.isCorrect, false);
|
|
74
|
-
assert.strictEqual(p1.issues[0].word, "hiç bir");
|
|
75
|
-
assert.strictEqual(p1.issues[0].suggestion, "hiçbir");
|
|
76
|
-
|
|
77
|
-
const p2 = await TDK.proofread("yada gelme");
|
|
78
|
-
assert.strictEqual(p2.isCorrect, false);
|
|
79
|
-
assert.strictEqual(p2.issues[0].suggestion, "ya da");
|
|
80
|
-
console.log(" ✓ Compound phrases passed.");
|
|
81
|
-
|
|
82
|
-
console.log("\n All proofread tests passed successfully!");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
runTests().catch((err) => {
|
|
86
|
-
console.error("Test failed:", err);
|
|
87
|
-
process.exit(1);
|
|
88
|
-
});
|
package/test/tools.test.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
const assert = require("node:assert");
|
|
2
|
-
const { TDK, TDKClient } = require("../dist/index.js");
|
|
3
|
-
|
|
4
|
-
async function runTests() {
|
|
5
|
-
console.log("=== Running Linguistic Tools & Client Tests ===");
|
|
6
|
-
|
|
7
|
-
// 1. Pattern / Wildcard Search
|
|
8
|
-
console.log("1. Testing patternSearch...");
|
|
9
|
-
const p1 = await TDK.patternSearch("k_l_m");
|
|
10
|
-
assert(p1.includes("kalem"), "k_l_m must contain kalem");
|
|
11
|
-
assert(p1.includes("kilim"), "k_l_m must contain kilim");
|
|
12
|
-
|
|
13
|
-
const p2 = await TDK.patternSearch("*istan");
|
|
14
|
-
assert(p2.some((w) => w.toLowerCase().endsWith("istan")), "*istan must match words ending with istan");
|
|
15
|
-
console.log(" ✓ patternSearch passed.");
|
|
16
|
-
|
|
17
|
-
// 2. Anagram Solver
|
|
18
|
-
console.log("2. Testing findAnagrams...");
|
|
19
|
-
const a1 = await TDK.findAnagrams("kalem");
|
|
20
|
-
assert(a1.includes("kelam"), "Anagrams of kalem must contain kelam");
|
|
21
|
-
assert(a1.includes("kemal"), "Anagrams of kalem must contain kemal");
|
|
22
|
-
console.log(" ✓ findAnagrams passed.");
|
|
23
|
-
|
|
24
|
-
// 3. Rhyme Finder
|
|
25
|
-
console.log("3. Testing findRhymes...");
|
|
26
|
-
const r1 = await TDK.findRhymes("bahar");
|
|
27
|
-
assert(r1.includes("sonbahar") || r1.includes("ilkbahar") || r1.includes("buhar"));
|
|
28
|
-
console.log(" ✓ findRhymes passed.");
|
|
29
|
-
|
|
30
|
-
// 4. Configuration & TDKClient
|
|
31
|
-
console.log("4. Testing TDK.configure and TDKClient...");
|
|
32
|
-
TDK.configure({ timeoutMs: 10000, retries: 2, maxCacheSize: 500 });
|
|
33
|
-
|
|
34
|
-
const client = new TDKClient({ timeoutMs: 5000, cache: true });
|
|
35
|
-
assert.strictEqual(typeof client.getWord, "function");
|
|
36
|
-
assert.strictEqual(typeof client.checkSpelling, "function");
|
|
37
|
-
assert.strictEqual(typeof client.findRoot, "function");
|
|
38
|
-
assert.strictEqual(typeof client.proofread, "function");
|
|
39
|
-
assert.strictEqual(typeof client.patternSearch, "function");
|
|
40
|
-
assert.strictEqual(typeof client.findAnagrams, "function");
|
|
41
|
-
assert.strictEqual(typeof client.findRhymes, "function");
|
|
42
|
-
assert.strictEqual(typeof client.checkLabialHarmony, "function");
|
|
43
|
-
console.log(" ✓ TDKClient passed.");
|
|
44
|
-
|
|
45
|
-
console.log("\n All linguistic tools & client tests passed successfully!");
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
runTests().catch((err) => {
|
|
49
|
-
console.error("Test failed:", err);
|
|
50
|
-
process.exit(1);
|
|
51
|
-
});
|