tdk-api-wrapper 1.5.0 → 1.5.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/dist/{chunk-7KJHYRJZ.mjs → chunk-NEC5MIQM.mjs} +311 -12
- package/dist/cli.js +316 -13
- package/dist/cli.mjs +6 -2
- package/dist/index.js +311 -12
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/cli.ts +6 -1
- package/src/morphology.ts +9 -0
- package/src/tdk.ts +344 -37
- package/test/proofread.test.js +28 -0
package/dist/cli.js
CHANGED
|
@@ -560,6 +560,13 @@ function getStemCandidates(word2, minStemLength = 2, maxDepth = 4) {
|
|
|
560
560
|
seen.add(apostropheStem);
|
|
561
561
|
}
|
|
562
562
|
}
|
|
563
|
+
const bareInfinitives = restoreInfinitive(normalized);
|
|
564
|
+
for (const inf of bareInfinitives) {
|
|
565
|
+
if (!seen.has(inf) && inf !== normalized) {
|
|
566
|
+
seen.add(inf);
|
|
567
|
+
candidatesWithWeight.push({ candidate: inf, baseLength: normalized.length });
|
|
568
|
+
}
|
|
569
|
+
}
|
|
563
570
|
let frontier = [normalized];
|
|
564
571
|
for (let depth = 0; depth < maxDepth; depth++) {
|
|
565
572
|
const nextFrontier = [];
|
|
@@ -609,6 +616,159 @@ var path = __toESM(require("path"));
|
|
|
609
616
|
var os = __toESM(require("os"));
|
|
610
617
|
var https = __toESM(require("https"));
|
|
611
618
|
var tls = __toESM(require("tls"));
|
|
619
|
+
var COMMON_MISSPELLINGS = {
|
|
620
|
+
// -şey ile biten ve ayrı yazılması zorunlu söz öbekleri
|
|
621
|
+
her\u015Fey: "her \u015Fey",
|
|
622
|
+
hersey: "her \u015Fey",
|
|
623
|
+
bir\u015Fey: "bir \u015Fey",
|
|
624
|
+
birsey: "bir \u015Fey",
|
|
625
|
+
hi\u00E7bir\u015Fey: "hi\xE7bir \u015Fey",
|
|
626
|
+
hicbirsey: "hi\xE7bir \u015Fey",
|
|
627
|
+
\u00E7ok\u015Fey: "\xE7ok \u015Fey",
|
|
628
|
+
coksey: "\xE7ok \u015Fey",
|
|
629
|
+
\u015Feyler: "\u015Feyler",
|
|
630
|
+
seyler: "\u015Feyler",
|
|
631
|
+
herhangibir\u015Fey: "herhangi bir \u015Fey",
|
|
632
|
+
herhangibirsey: "herhangi bir \u015Fey",
|
|
633
|
+
// Sıkça birleşik yazılan ama ayrı yazılması gereken sözler
|
|
634
|
+
herg\u00FCn: "her g\xFCn",
|
|
635
|
+
hergun: "her g\xFCn",
|
|
636
|
+
herzaman: "her zaman",
|
|
637
|
+
heran: "her an",
|
|
638
|
+
heryer: "her yer",
|
|
639
|
+
herbiri: "her biri",
|
|
640
|
+
pek\u00E7ok: "pek \xE7ok",
|
|
641
|
+
pekcok: "pek \xE7ok",
|
|
642
|
+
pekaz: "pek az",
|
|
643
|
+
yada: "ya da",
|
|
644
|
+
tabiki: "tabii ki",
|
|
645
|
+
tabiiki: "tabii ki",
|
|
646
|
+
sa\u011Fol: "sa\u011F ol",
|
|
647
|
+
sagol: "sa\u011F ol",
|
|
648
|
+
sa\u011Folun: "sa\u011F olun",
|
|
649
|
+
sagolun: "sa\u011F olun",
|
|
650
|
+
ho\u015F\u00E7akal: "ho\u015F\xE7a kal",
|
|
651
|
+
hoscakal: "ho\u015F\xE7a kal",
|
|
652
|
+
ho\u015Fgeldin: "ho\u015F geldin",
|
|
653
|
+
hosgeldin: "ho\u015F geldin",
|
|
654
|
+
ho\u015Fgeldiniz: "ho\u015F geldiniz",
|
|
655
|
+
hosgeldiniz: "ho\u015F geldiniz",
|
|
656
|
+
ho\u015Fbulduk: "ho\u015F bulduk",
|
|
657
|
+
hosbulduk: "ho\u015F bulduk",
|
|
658
|
+
yan\u0131s\u0131ra: "yan\u0131 s\u0131ra",
|
|
659
|
+
yanisira: "yan\u0131 s\u0131ra",
|
|
660
|
+
pe\u015Fis\u0131ra: "pe\u015Fi s\u0131ra",
|
|
661
|
+
pesisira: "pe\u015Fi s\u0131ra",
|
|
662
|
+
ard\u0131s\u0131ra: "ard\u0131 s\u0131ra",
|
|
663
|
+
ardisira: "ard\u0131 s\u0131ra",
|
|
664
|
+
artarda: "art arda",
|
|
665
|
+
y\u00FCzy\u00FCze: "y\xFCz y\xFCze",
|
|
666
|
+
yuzyuze: "y\xFCz y\xFCze",
|
|
667
|
+
elele: "el ele",
|
|
668
|
+
g\u00F6zg\u00F6ze: "g\xF6z g\xF6ze",
|
|
669
|
+
ba\u015Fba\u015Fa: "ba\u015F ba\u015Fa",
|
|
670
|
+
basbasa: "ba\u015F ba\u015Fa",
|
|
671
|
+
yanyana: "yan yana",
|
|
672
|
+
i\u00E7i\u00E7e: "i\xE7 i\xE7e",
|
|
673
|
+
icice: "i\xE7 i\xE7e",
|
|
674
|
+
\u00FCst\u00FCste: "\xFCst \xFCste",
|
|
675
|
+
ustuste: "\xFCst \xFCste",
|
|
676
|
+
altalta: "alt alta",
|
|
677
|
+
\u00F6ns\u00F6z: "\xF6n s\xF6z",
|
|
678
|
+
onsoz: "\xF6n s\xF6z",
|
|
679
|
+
\u00F6nyarg\u0131: "\xF6n yarg\u0131",
|
|
680
|
+
onyargi: "\xF6n yarg\u0131",
|
|
681
|
+
farketmek: "fark etmek",
|
|
682
|
+
farketti: "fark etti",
|
|
683
|
+
farkettim: "fark ettim",
|
|
684
|
+
farkeder: "fark eder",
|
|
685
|
+
farketmez: "fark etmez",
|
|
686
|
+
terketmek: "terk etmek",
|
|
687
|
+
terketti: "terk etti",
|
|
688
|
+
ay\u0131rdetmek: "ay\u0131rt etmek",
|
|
689
|
+
ay\u0131rtetmek: "ay\u0131rt etmek",
|
|
690
|
+
arzetmek: "arz etmek",
|
|
691
|
+
arzederim: "arz ederim",
|
|
692
|
+
varolmak: "var olmak",
|
|
693
|
+
yokolmak: "yok olmak",
|
|
694
|
+
haketmek: "hak etmek",
|
|
695
|
+
haketti: "hak etti",
|
|
696
|
+
hakkaten: "hakikaten",
|
|
697
|
+
hi\u00E7kimse: "hi\xE7 kimse",
|
|
698
|
+
hickimse: "hi\xE7 kimse",
|
|
699
|
+
// Ünlü düşmesi yapılmaması gereken yer bildiren sözler (TDK Kural 15)
|
|
700
|
+
burda: "burada",
|
|
701
|
+
burdan: "buradan",
|
|
702
|
+
\u015Furda: "\u015Furada",
|
|
703
|
+
surda: "\u015Furada",
|
|
704
|
+
\u015Furdan: "\u015Furadan",
|
|
705
|
+
surdan: "\u015Furadan",
|
|
706
|
+
orda: "orada",
|
|
707
|
+
ordan: "oradan",
|
|
708
|
+
i\u00E7erde: "i\xE7eride",
|
|
709
|
+
icerde: "i\xE7eride",
|
|
710
|
+
i\u00E7erden: "i\xE7eriden",
|
|
711
|
+
icerden: "i\xE7eriden",
|
|
712
|
+
d\u0131\u015Farda: "d\u0131\u015Far\u0131da",
|
|
713
|
+
disarda: "d\u0131\u015Far\u0131da",
|
|
714
|
+
d\u0131\u015Fardan: "d\u0131\u015Far\u0131dan",
|
|
715
|
+
disardan: "d\u0131\u015Far\u0131dan",
|
|
716
|
+
yukarda: "yukar\u0131da",
|
|
717
|
+
yukardan: "yukar\u0131dan",
|
|
718
|
+
// Sıkça yanlış yazılan sözcükler
|
|
719
|
+
herkez: "herkes",
|
|
720
|
+
yanl\u0131z: "yaln\u0131z",
|
|
721
|
+
yaln\u0131\u015F: "yanl\u0131\u015F",
|
|
722
|
+
orjinal: "orijinal",
|
|
723
|
+
labaratuar: "laboratuvar",
|
|
724
|
+
laboratuar: "laboratuvar",
|
|
725
|
+
\u015F\u00F6f\u00F6r: "\u015Fof\xF6r",
|
|
726
|
+
sofor: "\u015Fof\xF6r",
|
|
727
|
+
egzos: "egzoz",
|
|
728
|
+
eksoz: "egzoz",
|
|
729
|
+
ekzoz: "egzoz",
|
|
730
|
+
kiprik: "kirpik",
|
|
731
|
+
kirbit: "kibrit",
|
|
732
|
+
klavuz: "k\u0131lavuz",
|
|
733
|
+
k\u0131ravat: "kravat",
|
|
734
|
+
s\u00FCpriz: "s\xFCrpriz",
|
|
735
|
+
supriz: "s\xFCrpriz",
|
|
736
|
+
raslant\u0131: "rastlant\u0131",
|
|
737
|
+
hastahane: "hastane",
|
|
738
|
+
pastahane: "pastane",
|
|
739
|
+
postahane: "postane",
|
|
740
|
+
eczahane: "eczane",
|
|
741
|
+
meyva: "meyve",
|
|
742
|
+
sarm\u0131sak: "sar\u0131msak",
|
|
743
|
+
dinazor: "dinozor",
|
|
744
|
+
pantalon: "pantolon",
|
|
745
|
+
tesbih: "tespih",
|
|
746
|
+
ah\u00E7\u0131: "a\u015F\xE7\u0131",
|
|
747
|
+
matba: "matbaa",
|
|
748
|
+
idda: "iddia",
|
|
749
|
+
iddaa: "iddia",
|
|
750
|
+
muhattap: "muhatap",
|
|
751
|
+
tra\u015F: "t\u0131ra\u015F",
|
|
752
|
+
karn\u0131bahar: "karnabahar",
|
|
753
|
+
kareografi: "koreografi",
|
|
754
|
+
poa\u00E7a: "po\u011Fa\xE7a",
|
|
755
|
+
poha\u00E7a: "po\u011Fa\xE7a",
|
|
756
|
+
\u015Farz: "\u015Farj",
|
|
757
|
+
sarj: "\u015Farj",
|
|
758
|
+
makina: "makine",
|
|
759
|
+
m\u00FCsade: "m\xFCsaade",
|
|
760
|
+
entellekt\u00FCel: "entelekt\xFCel",
|
|
761
|
+
inisiyatif: "inisiyatif",
|
|
762
|
+
insiyatif: "inisiyatif",
|
|
763
|
+
sezeryan: "sezaryen",
|
|
764
|
+
dok\u00FCman: "dok\xFCman",
|
|
765
|
+
d\u00F6k\u00FCman: "dok\xFCman",
|
|
766
|
+
erozyon: "erozyon",
|
|
767
|
+
erizyon: "erozyon",
|
|
768
|
+
anane: "anneanne",
|
|
769
|
+
babaanne: "babaanne"
|
|
770
|
+
};
|
|
771
|
+
var SEY_EXCEPTIONS = /* @__PURE__ */ new Set(["d\xFC\u015Fey", "e\u015Fey", "konsey", "jersey", "\u015Fey"]);
|
|
612
772
|
var TDK = class {
|
|
613
773
|
static BASE_URL = "https://sozluk.gov.tr";
|
|
614
774
|
static AUDIO_API_HOST = "api.sozluk.gov.tr";
|
|
@@ -1172,25 +1332,45 @@ yDFx8r7i9vIJU5HS3moZLkYWAOilMaV9N56A9Bgb6dNcHkvg3NoaYA==
|
|
|
1172
1332
|
* Checks spelling and returns suggestions if wrong.
|
|
1173
1333
|
*/
|
|
1174
1334
|
static async checkSpelling(word2) {
|
|
1335
|
+
if (!word2 || word2.trim() === "") {
|
|
1336
|
+
return { isCorrect: false, word: word2 };
|
|
1337
|
+
}
|
|
1338
|
+
const cleanWord = word2.trim().toLocaleLowerCase("tr-TR");
|
|
1175
1339
|
const results = await this.getWord(word2);
|
|
1176
1340
|
if (results.length > 0) {
|
|
1177
1341
|
return { isCorrect: true, word: word2 };
|
|
1178
1342
|
}
|
|
1343
|
+
if (COMMON_MISSPELLINGS[cleanWord]) {
|
|
1344
|
+
return { isCorrect: false, word: word2, suggestion: COMMON_MISSPELLINGS[cleanWord] };
|
|
1345
|
+
}
|
|
1346
|
+
const seyMatch = cleanWord.match(/^(.+?)(?:şey|sey)([ıiuaeüodekmnl]+)?$/);
|
|
1347
|
+
if (seyMatch && !SEY_EXCEPTIONS.has(cleanWord)) {
|
|
1348
|
+
let prefix = seyMatch[1];
|
|
1349
|
+
const suffix = seyMatch[2] || "";
|
|
1350
|
+
if (prefix === "hicbir")
|
|
1351
|
+
prefix = "hi\xE7bir";
|
|
1352
|
+
if (prefix === "cok")
|
|
1353
|
+
prefix = "\xE7ok";
|
|
1354
|
+
return {
|
|
1355
|
+
isCorrect: false,
|
|
1356
|
+
word: word2,
|
|
1357
|
+
suggestion: `${prefix} \u015Fey${suffix}`
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1179
1360
|
const daily = await this.getDailyContent();
|
|
1180
1361
|
if (daily) {
|
|
1181
|
-
const syydMatch = daily.syyd.find((s) => s.yanliskelime.toLocaleLowerCase("tr-TR") ===
|
|
1362
|
+
const syydMatch = daily.syyd.find((s) => s.yanliskelime.toLocaleLowerCase("tr-TR") === cleanWord);
|
|
1182
1363
|
if (syydMatch) {
|
|
1183
1364
|
return { isCorrect: false, word: word2, suggestion: syydMatch.dogrukelime };
|
|
1184
1365
|
}
|
|
1185
|
-
const mixMatch = daily.karistirma.find((s) => s.yanlis.toLocaleLowerCase("tr-TR") ===
|
|
1366
|
+
const mixMatch = daily.karistirma.find((s) => s.yanlis.toLocaleLowerCase("tr-TR") === cleanWord);
|
|
1186
1367
|
if (mixMatch) {
|
|
1187
1368
|
return { isCorrect: false, word: word2, suggestion: mixMatch.dogru };
|
|
1188
1369
|
}
|
|
1189
1370
|
}
|
|
1190
1371
|
const root = await this.findRoot(word2);
|
|
1191
1372
|
if (root) {
|
|
1192
|
-
const
|
|
1193
|
-
const isInflected = root !== cleanWord2;
|
|
1373
|
+
const isInflected = root !== cleanWord;
|
|
1194
1374
|
return {
|
|
1195
1375
|
isCorrect: true,
|
|
1196
1376
|
word: word2,
|
|
@@ -1201,24 +1381,32 @@ yDFx8r7i9vIJU5HS3moZLkYWAOilMaV9N56A9Bgb6dNcHkvg3NoaYA==
|
|
|
1201
1381
|
if (this.autocompleteCache.length === 0) {
|
|
1202
1382
|
this.autocompleteCache = await this.fetchAutocompleteData();
|
|
1203
1383
|
}
|
|
1204
|
-
const
|
|
1384
|
+
for (const candidate of this.autocompleteCache) {
|
|
1385
|
+
if (candidate.includes(" ")) {
|
|
1386
|
+
const candidateNoSpace = candidate.replace(/\s+/g, "").toLocaleLowerCase("tr-TR");
|
|
1387
|
+
if (candidateNoSpace === cleanWord) {
|
|
1388
|
+
return { isCorrect: false, word: word2, suggestion: candidate };
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1205
1392
|
let best = null;
|
|
1206
1393
|
for (const candidate of this.autocompleteCache) {
|
|
1207
1394
|
if (candidate.includes(" ") || candidate !== candidate.toLocaleLowerCase("tr-TR"))
|
|
1208
1395
|
continue;
|
|
1209
1396
|
if (Math.abs(candidate.length - cleanWord.length) > 2)
|
|
1210
1397
|
continue;
|
|
1211
|
-
const
|
|
1212
|
-
if (
|
|
1398
|
+
const rawDist = this.damerauLevenshtein(cleanWord, candidate);
|
|
1399
|
+
if (rawDist === 0)
|
|
1213
1400
|
continue;
|
|
1214
1401
|
const firstMismatch = candidate[0] === cleanWord[0] ? 0 : 1;
|
|
1215
1402
|
const lengthMismatch = candidate.length === cleanWord.length ? 0 : 1;
|
|
1403
|
+
const distance = rawDist + (firstMismatch > 0 ? 1.2 : 0);
|
|
1216
1404
|
const better = !best || distance < best.distance || distance === best.distance && firstMismatch < best.firstMismatch || distance === best.distance && firstMismatch === best.firstMismatch && lengthMismatch < best.lengthMismatch;
|
|
1217
1405
|
if (better) {
|
|
1218
|
-
best = { candidate, distance, firstMismatch, lengthMismatch };
|
|
1406
|
+
best = { candidate, distance, rawDist, firstMismatch, lengthMismatch };
|
|
1219
1407
|
}
|
|
1220
1408
|
}
|
|
1221
|
-
if (best && best.
|
|
1409
|
+
if (best && best.rawDist <= 2 && (best.firstMismatch === 0 || best.rawDist <= 1)) {
|
|
1222
1410
|
return { isCorrect: false, word: word2, suggestion: best.candidate };
|
|
1223
1411
|
}
|
|
1224
1412
|
return { isCorrect: false, word: word2 };
|
|
@@ -1971,6 +2159,73 @@ yDFx8r7i9vIJU5HS3moZLkYWAOilMaV9N56A9Bgb6dNcHkvg3NoaYA==
|
|
|
1971
2159
|
"me\u011Ferki",
|
|
1972
2160
|
"illaki"
|
|
1973
2161
|
]);
|
|
2162
|
+
const PHRASE_MISTAKES = [
|
|
2163
|
+
{
|
|
2164
|
+
regex: /\bhiç\s+bir\b/gi,
|
|
2165
|
+
suggestion: "hi\xE7bir",
|
|
2166
|
+
message: "'hi\xE7bir' belgisiz s\u0131fat\u0131 biti\u015Fik yaz\u0131lmal\u0131d\u0131r.",
|
|
2167
|
+
type: "spelling"
|
|
2168
|
+
},
|
|
2169
|
+
{
|
|
2170
|
+
regex: /\bbir\s+çok\b/gi,
|
|
2171
|
+
suggestion: "bir\xE7ok",
|
|
2172
|
+
message: "'bir\xE7ok' belgisiz s\u0131fat\u0131/zamiri biti\u015Fik yaz\u0131lmal\u0131d\u0131r.",
|
|
2173
|
+
type: "spelling"
|
|
2174
|
+
},
|
|
2175
|
+
{
|
|
2176
|
+
regex: /\bbir\s+kaç\b/gi,
|
|
2177
|
+
suggestion: "birka\xE7",
|
|
2178
|
+
message: "'birka\xE7' belgisiz s\u0131fat\u0131/zamiri biti\u015Fik yaz\u0131lmal\u0131d\u0131r.",
|
|
2179
|
+
type: "spelling"
|
|
2180
|
+
},
|
|
2181
|
+
{
|
|
2182
|
+
regex: /\bbir\s+az\b/gi,
|
|
2183
|
+
suggestion: "biraz",
|
|
2184
|
+
message: "'biraz' s\xF6zc\xFC\u011F\xFC biti\u015Fik yaz\u0131lmal\u0131d\u0131r.",
|
|
2185
|
+
type: "spelling"
|
|
2186
|
+
},
|
|
2187
|
+
{
|
|
2188
|
+
regex: /\bher\s+hangi\b/gi,
|
|
2189
|
+
suggestion: "herhangi",
|
|
2190
|
+
message: "'herhangi' s\xF6zc\xFC\u011F\xFC biti\u015Fik yaz\u0131lmal\u0131d\u0131r.",
|
|
2191
|
+
type: "spelling"
|
|
2192
|
+
},
|
|
2193
|
+
{
|
|
2194
|
+
regex: /\bgit\s+gide\b/gi,
|
|
2195
|
+
suggestion: "gitgide",
|
|
2196
|
+
message: "'gitgide' zarf\u0131 biti\u015Fik yaz\u0131lmal\u0131d\u0131r.",
|
|
2197
|
+
type: "spelling"
|
|
2198
|
+
},
|
|
2199
|
+
{
|
|
2200
|
+
regex: /\bbirden\s+bire\b/gi,
|
|
2201
|
+
suggestion: "birdenbire",
|
|
2202
|
+
message: "'birdenbire' zarf\u0131 biti\u015Fik yaz\u0131lmal\u0131d\u0131r.",
|
|
2203
|
+
type: "spelling"
|
|
2204
|
+
},
|
|
2205
|
+
{
|
|
2206
|
+
regex: /\brast\s+gele\b/gi,
|
|
2207
|
+
suggestion: "rastgele",
|
|
2208
|
+
message: "'rastgele' zarf\u0131 biti\u015Fik yaz\u0131lmal\u0131d\u0131r.",
|
|
2209
|
+
type: "spelling"
|
|
2210
|
+
}
|
|
2211
|
+
];
|
|
2212
|
+
const coveredRanges = [];
|
|
2213
|
+
for (const pm of PHRASE_MISTAKES) {
|
|
2214
|
+
let pmMatch;
|
|
2215
|
+
while ((pmMatch = pm.regex.exec(text)) !== null) {
|
|
2216
|
+
const start = pmMatch.index;
|
|
2217
|
+
const end = start + pmMatch[0].length;
|
|
2218
|
+
coveredRanges.push({ start, end });
|
|
2219
|
+
issues.push({
|
|
2220
|
+
type: pm.type,
|
|
2221
|
+
word: pmMatch[0],
|
|
2222
|
+
startIndex: start,
|
|
2223
|
+
endIndex: end,
|
|
2224
|
+
suggestion: pm.suggestion,
|
|
2225
|
+
message: pm.message
|
|
2226
|
+
});
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
1974
2229
|
const tokenRegex = /[\p{L}0-9'’]+/gu;
|
|
1975
2230
|
let match;
|
|
1976
2231
|
while ((match = tokenRegex.exec(text)) !== null) {
|
|
@@ -1980,6 +2235,8 @@ yDFx8r7i9vIJU5HS3moZLkYWAOilMaV9N56A9Bgb6dNcHkvg3NoaYA==
|
|
|
1980
2235
|
const lower = rawWord.toLocaleLowerCase("tr-TR");
|
|
1981
2236
|
if (/^\d+$/.test(lower))
|
|
1982
2237
|
continue;
|
|
2238
|
+
if (coveredRanges.some((r) => startIndex >= r.start && endIndex <= r.end))
|
|
2239
|
+
continue;
|
|
1983
2240
|
let flagged = false;
|
|
1984
2241
|
const questionMatch = lower.match(/^(.+?)(m[ıiuü](?:sin|sın|sun|sün|siniz|sınız|sunuz|sünüz|yiz|yız|yuz|yüz|m|k)?)$/);
|
|
1985
2242
|
if (questionMatch) {
|
|
@@ -2005,7 +2262,7 @@ yDFx8r7i9vIJU5HS3moZLkYWAOilMaV9N56A9Bgb6dNcHkvg3NoaYA==
|
|
|
2005
2262
|
if (!SOMBAHCEMI.has(lower)) {
|
|
2006
2263
|
if (!await this.isHeadword(lower)) {
|
|
2007
2264
|
const root = await this.findRoot(base);
|
|
2008
|
-
const isVerb =
|
|
2265
|
+
const isVerb = (base === "demek" || base === "kald\u0131" || base === "yeter" || base === "bilmem" || VERB_CONJUGATION_REGEX.test(base)) && (root ? root.endsWith("mek") || root.endsWith("mak") : true);
|
|
2009
2266
|
if (isVerb) {
|
|
2010
2267
|
issues.push({
|
|
2011
2268
|
type: "conjunction_ki",
|
|
@@ -2025,7 +2282,7 @@ yDFx8r7i9vIJU5HS3moZLkYWAOilMaV9N56A9Bgb6dNcHkvg3NoaYA==
|
|
|
2025
2282
|
const ending = lower.slice(-2);
|
|
2026
2283
|
if (!await this.isHeadword(lower)) {
|
|
2027
2284
|
const root = await this.findRoot(base);
|
|
2028
|
-
const isVerb =
|
|
2285
|
+
const isVerb = VERB_CONJUGATION_REGEX.test(base) && (root ? root.endsWith("mek") || root.endsWith("mak") : false);
|
|
2029
2286
|
if (isVerb) {
|
|
2030
2287
|
const correctEnding = ending.startsWith("t") ? ending === "te" ? "de" : "da" : ending;
|
|
2031
2288
|
issues.push({
|
|
@@ -2040,6 +2297,47 @@ yDFx8r7i9vIJU5HS3moZLkYWAOilMaV9N56A9Bgb6dNcHkvg3NoaYA==
|
|
|
2040
2297
|
}
|
|
2041
2298
|
}
|
|
2042
2299
|
}
|
|
2300
|
+
const seyMatch = lower.match(/^(.+?)(?:şey|sey)([ıiuaeüodekmnl]+)?$/);
|
|
2301
|
+
if (!flagged && seyMatch && !SEY_EXCEPTIONS.has(lower)) {
|
|
2302
|
+
let prefix = seyMatch[1];
|
|
2303
|
+
const suffix = seyMatch[2] || "";
|
|
2304
|
+
if (prefix === "hicbir")
|
|
2305
|
+
prefix = "hi\xE7bir";
|
|
2306
|
+
if (prefix === "cok")
|
|
2307
|
+
prefix = "\xE7ok";
|
|
2308
|
+
issues.push({
|
|
2309
|
+
type: "spelling",
|
|
2310
|
+
word: rawWord,
|
|
2311
|
+
startIndex,
|
|
2312
|
+
endIndex,
|
|
2313
|
+
suggestion: `${prefix} \u015Fey${suffix}`,
|
|
2314
|
+
message: "'\u015Fey' s\xF6zc\xFC\u011F\xFC kendinden \xF6nceki kelimeden ayr\u0131 yaz\u0131lmal\u0131d\u0131r."
|
|
2315
|
+
});
|
|
2316
|
+
flagged = true;
|
|
2317
|
+
}
|
|
2318
|
+
if (!flagged && lower === "yada") {
|
|
2319
|
+
issues.push({
|
|
2320
|
+
type: "spelling",
|
|
2321
|
+
word: rawWord,
|
|
2322
|
+
startIndex,
|
|
2323
|
+
endIndex,
|
|
2324
|
+
suggestion: "ya da",
|
|
2325
|
+
message: "'ya da' ba\u011Flac\u0131 her zaman ayr\u0131 yaz\u0131l\u0131r."
|
|
2326
|
+
});
|
|
2327
|
+
flagged = true;
|
|
2328
|
+
}
|
|
2329
|
+
if (!flagged && (lower === "burda" || lower === "\u015Furda" || lower === "surda" || lower === "orda" || lower === "i\xE7erde" || lower === "icerde" || lower === "d\u0131\u015Farda" || lower === "disarda" || lower === "yukarda")) {
|
|
2330
|
+
const correct = COMMON_MISSPELLINGS[lower] || lower;
|
|
2331
|
+
issues.push({
|
|
2332
|
+
type: "spelling",
|
|
2333
|
+
word: rawWord,
|
|
2334
|
+
startIndex,
|
|
2335
|
+
endIndex,
|
|
2336
|
+
suggestion: correct,
|
|
2337
|
+
message: `'${rawWord}' s\xF6zc\xFC\u011F\xFCnde \xFCnl\xFC d\xFC\u015Fmesi yap\u0131lmaz.`
|
|
2338
|
+
});
|
|
2339
|
+
flagged = true;
|
|
2340
|
+
}
|
|
2043
2341
|
if (!flagged) {
|
|
2044
2342
|
const check = await this.checkSpelling(rawWord);
|
|
2045
2343
|
if (!check.isCorrect) {
|
|
@@ -2049,11 +2347,12 @@ yDFx8r7i9vIJU5HS3moZLkYWAOilMaV9N56A9Bgb6dNcHkvg3NoaYA==
|
|
|
2049
2347
|
startIndex,
|
|
2050
2348
|
endIndex,
|
|
2051
2349
|
suggestion: check.suggestion,
|
|
2052
|
-
message: check.suggestion ? `'${rawWord}' yanl\u0131\u015F yaz\u0131lm\u0131\u015F olabilir
|
|
2350
|
+
message: check.suggestion ? `'${rawWord}' yanl\u0131\u015F yaz\u0131lm\u0131\u015F olabilir.` : `'${rawWord}' s\xF6zl\xFCkte bulunamad\u0131.`
|
|
2053
2351
|
});
|
|
2054
2352
|
}
|
|
2055
2353
|
}
|
|
2056
2354
|
}
|
|
2355
|
+
issues.sort((a, b) => a.startIndex - b.startIndex);
|
|
2057
2356
|
return {
|
|
2058
2357
|
text,
|
|
2059
2358
|
issues,
|
|
@@ -2111,7 +2410,7 @@ var KNOWN_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
2111
2410
|
]);
|
|
2112
2411
|
var command = args[0];
|
|
2113
2412
|
var word = args.slice(1).join(" ");
|
|
2114
|
-
if (command && !KNOWN_COMMANDS.has(command) && command !== "--help" && command !== "-h") {
|
|
2413
|
+
if (command && !KNOWN_COMMANDS.has(command) && command !== "--help" && command !== "-h" && command !== "--version" && command !== "-v") {
|
|
2115
2414
|
word = args.join(" ");
|
|
2116
2415
|
command = "anlam";
|
|
2117
2416
|
}
|
|
@@ -2206,6 +2505,10 @@ async function run() {
|
|
|
2206
2505
|
console.log("Not: Komut belirtilmezse do\u011Frudan kelime anlam\u0131 aran\u0131r (\xF6rn: tdk selam)");
|
|
2207
2506
|
process.exit(1);
|
|
2208
2507
|
}
|
|
2508
|
+
if (command === "--version" || command === "-v") {
|
|
2509
|
+
console.log("tdk-api-wrapper v1.5.1");
|
|
2510
|
+
process.exit(0);
|
|
2511
|
+
}
|
|
2209
2512
|
if (command === "--help" || command === "-h") {
|
|
2210
2513
|
console.log("Kullan\u0131m: tdk [komut] <kelime> [--json]");
|
|
2211
2514
|
console.log(
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
TDK
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NEC5MIQM.mjs";
|
|
5
5
|
|
|
6
6
|
// src/cli.ts
|
|
7
7
|
var rawArgs = process.argv.slice(2);
|
|
@@ -52,7 +52,7 @@ var KNOWN_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
52
52
|
]);
|
|
53
53
|
var command = args[0];
|
|
54
54
|
var word = args.slice(1).join(" ");
|
|
55
|
-
if (command && !KNOWN_COMMANDS.has(command) && command !== "--help" && command !== "-h") {
|
|
55
|
+
if (command && !KNOWN_COMMANDS.has(command) && command !== "--help" && command !== "-h" && command !== "--version" && command !== "-v") {
|
|
56
56
|
word = args.join(" ");
|
|
57
57
|
command = "anlam";
|
|
58
58
|
}
|
|
@@ -147,6 +147,10 @@ async function run() {
|
|
|
147
147
|
console.log("Not: Komut belirtilmezse do\u011Frudan kelime anlam\u0131 aran\u0131r (\xF6rn: tdk selam)");
|
|
148
148
|
process.exit(1);
|
|
149
149
|
}
|
|
150
|
+
if (command === "--version" || command === "-v") {
|
|
151
|
+
console.log("tdk-api-wrapper v1.5.1");
|
|
152
|
+
process.exit(0);
|
|
153
|
+
}
|
|
150
154
|
if (command === "--help" || command === "-h") {
|
|
151
155
|
console.log("Kullan\u0131m: tdk [komut] <kelime> [--json]");
|
|
152
156
|
console.log(
|