tinyfix-tr 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +138 -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 +50 -0
- package/dist/pkg/src/data.js +495 -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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 imhalid
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,139 @@
|
|
|
1
|
-
#
|
|
1
|
+
# tinyfix-tr
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Tarayıcıda ve Node.js üzerinde **internetsiz** çalışan Türkçe otomatik düzeltme paketi. Sözlük ve kurallar cihazda çalışır; isteğe bağlı bağlam modeli (`context: true`) yalnızca istendiğinde dinamik `import()` ile `onnxruntime-web` yükler.
|
|
4
|
+
|
|
5
|
+
## Kurulum
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install tinyfix-tr
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Sıkıştırılmış tarayıcı veri dosyalarını (`lexicon.bin`, `morph.bin`, `known.tsv`, isteğe bağlı `manifest.json`) ve bağlam modelini kullanacaksanız `context.onnx` dosyasını uygulamanızda sunacağınız bir klasöre (örneğin `public/models/`) yerleştirin. Eski düz metin TSV dosyaları (`unigrams.tsv`, `bigrams.tsv`, `known.tsv`) geriye dönük uyumluluk için hâlâ desteklenir.
|
|
12
|
+
|
|
13
|
+
## Hızlı Başlangıç
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { loadTdkai } from "tinyfix-tr";
|
|
17
|
+
|
|
18
|
+
const tdkai = await loadTdkai({
|
|
19
|
+
baseUrl: "/models/",
|
|
20
|
+
worker: true,
|
|
21
|
+
context: true, // isteğe bağlı: context.onnx + onnxruntime-web
|
|
22
|
+
wasmPaths: "/ort/", // isteğe bağlı: ORT .wasm/.mjs dosyalarının konumu
|
|
23
|
+
onProgress: ({ ratio, stage, file }) => {
|
|
24
|
+
console.log(stage, file ?? "", Math.round(ratio * 100) + "%");
|
|
25
|
+
},
|
|
26
|
+
onWarning: (warning) => {
|
|
27
|
+
console.warn(warning);
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const duzeltilmis = await tdkai.fix("Bugün cok yorgunum, Ankaraya herkez geldi.");
|
|
32
|
+
// "Bugün çok yorgunum, Ankara'ya herkes geldi."
|
|
33
|
+
|
|
34
|
+
await tdkai.dispose();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`context: false` (varsayılan) iken `context.onnx` indirilmez ve `onnxruntime-web` hiç yüklenmez. `context: true` verildiğinde `context.onnx` bulunamazsa veya ONNX oturumu açılamazsa paket uyarı verir (`console.warn` ve `onWarning`) ve bağlam modeli olmadan sözlük kurallarıyla çalışmaya devam eder (`tdkai.hasContext === false`).
|
|
38
|
+
|
|
39
|
+
## Düzeltmeleri İnceleme ve Uygulama
|
|
40
|
+
|
|
41
|
+
`check` metodu, metinde yapılacak düzeltmeleri sıralı ve çakışmayan bir liste olarak döndürür:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
const metin = "Birşey söylemek istiyorum ama hiç bir fikrim yok.";
|
|
45
|
+
const duzeltmeler = await tdkai.check(metin);
|
|
46
|
+
/*
|
|
47
|
+
[
|
|
48
|
+
{ from: 0, to: 6, original: "Birşey", replacement: "Bir şey", kind: "bitisik-ayri", confidence: 0.986 },
|
|
49
|
+
{ from: 30, to: 37, original: "hiç bir", replacement: "hiçbir", kind: "bitisik-ayri", confidence: 0.955 },
|
|
50
|
+
]
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
const sonuc = tdkai.apply(metin, duzeltmeler);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Yazarken Düzeltme (`range`)
|
|
57
|
+
|
|
58
|
+
Kullanıcı bir kelimeyi bitirdiğinde (boşluk veya noktalama girildiğinde) tüm belgeyi yeniden denetlemek yerine yalnızca ilgili aralığı kontrol edebilirsiniz. Metnin geri kalanı bağlam (cümle başı, soru işareti, Türkçe harf kullanımı ve bağlam modeli penceresi) olarak okunur:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
const paragraf = "Sen geldinmi?";
|
|
62
|
+
const fixes = await tdkai.check(paragraf, {
|
|
63
|
+
range: [4, 12], // yalnızca "geldinmi" aralığı; "?" bağlam olarak okunur
|
|
64
|
+
kinds: ["turkce-karakter", "kesme", "bitisik-ayri", "yazim"],
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Kullanıcı bir düzeltmeyi geri aldığında aynı kelimeyi tekrar değiştirmemek için `ignore` çağırın:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
tdkai.ignore(fix.original);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Düzeltme Türleri (`FixKind`)
|
|
75
|
+
|
|
76
|
+
| Dış tür | Açıklama | Örnekler | İç motor karşılığı |
|
|
77
|
+
|---|---|---|---|
|
|
78
|
+
| `"turkce-karakter"` | Eksik Türkçe karakterler | `cok → çok`, `nasil → nasıl`, `oldu → öldü` | `marks`, harf değiştiren `context`/`known` |
|
|
79
|
+
| `"kesme"` | Özel adlara gelen eklerde eksik kesme işareti | `Ankaraya → Ankara'ya` | `apostrophe` |
|
|
80
|
+
| `"bitisik-ayri"` | Bitişik/ayrı yazım, soru eki, `de/da`, `ki` | `birşey → bir şey`, `hiç bir → hiçbir`, `bende → ben de` | `split`, `join`, boşluk değiştiren `context`/`known` |
|
|
81
|
+
| `"yazim"` | Klavye hataları ve bilinen yazım yanlışları | `herkez → herkes`, `malesef → maalesef`, `yapabiliur → yapabilir` | `typo`, tek kelimelik `known` |
|
|
82
|
+
|
|
83
|
+
## API
|
|
84
|
+
|
|
85
|
+
| Çağrı | Açıklama |
|
|
86
|
+
|---|---|
|
|
87
|
+
| `loadTdkai(options?)` | Sözlük (ve istenirse `context.onnx`) dosyalarını indirir ve bir `Tdkai` örneği döndürür. |
|
|
88
|
+
| `createTdkai(data, options?)` | Bellekteki ham TSV verisinden (isteğe bağlı `contextModel` ile) eşzamanlı olarak `Tdkai` oluşturur. |
|
|
89
|
+
| `tdkai.hasContext` | Bağlam modelinin etkin olarak yüklenip yüklenmediğini belirtir. |
|
|
90
|
+
| `tdkai.check(text, options?)` | Çakışmayan, sıralı `Fix[]` listesi döndürür. |
|
|
91
|
+
| `tdkai.apply(text, fixes)` | Düzeltmeleri metne uygular; konum veya metin uyuşmazsa hata fırlatır. |
|
|
92
|
+
| `tdkai.fix(text, options?)` | `check` ve `apply` adımlarını birlikte çalıştırır. |
|
|
93
|
+
| `tdkai.ignore(word)` | Belirtilen kelime veya ifadeyi bir daha değiştirmez (Türkçe büyük/küçük harf duyarsız). |
|
|
94
|
+
| `tdkai.unignore(word)` | Yoksayılan kelimeyi yeniden denetime açar. |
|
|
95
|
+
| `tdkai.setMode(mode)` | Hassasiyet kipini (`"careful"` veya `"balanced"`) günceller. |
|
|
96
|
+
| `tdkai.dispose()` | Kaynakları, varsa ONNX oturumunu ve Web Worker'ı sonlandırır. |
|
|
97
|
+
|
|
98
|
+
### `LoadOptions`
|
|
99
|
+
|
|
100
|
+
| Seçenek | Varsayılan | Açıklama |
|
|
101
|
+
|---|---|---|
|
|
102
|
+
| `baseUrl` | `"/models/"` | `lexicon.bin`, `morph.bin`, `known.tsv` (veya geriye dönük `unigrams.tsv`/`bigrams.tsv`) ve isteğe bağlı `context.onnx` dosyalarının bulunduğu adres. |
|
|
103
|
+
| `data` | — | Ağ isteği yerine bellekteki ikili (`BinaryData`) veya ham TSV (`RawData`) verisini kullanır. |
|
|
104
|
+
| `mode` | `"careful"` | `"careful"` motorun temkinli varsayılan ayarını, `"balanced"` biraz daha cesur eşikleri kullanır. |
|
|
105
|
+
| `worker` | `false` | `true` verilirse sözlük yükleme, bağlam modeli ve denetim ayrı bir Web Worker içinde çalışır. |
|
|
106
|
+
| `createWorker` | — | Özel `Worker` örneği sağlamak için isteğe bağlı kurucu işlev. |
|
|
107
|
+
| `context` | `false` | `true` verilirse `context.onnx` indirilir ve `onnxruntime-web` ile bağlam modeli açılır. |
|
|
108
|
+
| `wasmPaths` | ORT varsayılanı | `onnxruntime-web` `.wasm`/`.mjs` dosyalarının bulunduğu dizin URL'si. |
|
|
109
|
+
| `contextModel` | — | Testler veya özel çalışma zamanları için bellekteki `ContextModel` ya da `RunModel` işlevi. |
|
|
110
|
+
| `loadContextSession` | `createOnnxContextSession` | İndirilen `context.onnx` baytlarından oturum açan özel yükleyici. |
|
|
111
|
+
| `onProgress` | — | `{ ratio, loaded, total, stage, file }` ile yükleme ilerlemesini bildirir (`context.onnx` dahil). |
|
|
112
|
+
| `onWarning` | — | Bağlam modeli yüklenemediğinde oluşan uyarı metnini bildirir. |
|
|
113
|
+
| `fetch` | `globalThis.fetch` | İsteğe bağlı özel `fetch` işlevi. |
|
|
114
|
+
| `signal` | — | İndirmeyi iptal etmek için `AbortSignal`. |
|
|
115
|
+
| `ignored` | — | Başlangıçta yoksayılacak kelimeler listesi. |
|
|
116
|
+
|
|
117
|
+
### `CheckOptions`
|
|
118
|
+
|
|
119
|
+
| Seçenek | Varsayılan | Açıklama |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| `range` | Tüm metin | `[from, to)` aralığıyla kesişen düzeltmeler döndürülür; metnin kalanı bağlam olarak okunur. |
|
|
122
|
+
| `kinds` | Tüm türler | Yalnızca belirtilen `FixKind` türlerini döndürür. |
|
|
123
|
+
| `mode` | Örnek kipi | Yalnızca bu çağrı için geçici kip (`"careful"` / `"balanced"`). |
|
|
124
|
+
|
|
125
|
+
### Web Worker Girişi (`tdkai/worker`)
|
|
126
|
+
|
|
127
|
+
`loadTdkai({ worker: true })` modern paketleyicilerle (Vite, webpack) paketin kendi worker dosyasını otomatik başlatır. Worker dosyasını kendiniz bağlamak isterseniz `tdkai/worker` girişini doğrudan kullanabilirsiniz:
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
const worker = new Worker(new URL("tdkai/worker", import.meta.url), { type: "module" });
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Geliştirme
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
npm run check # TypeScript tür denetimi
|
|
137
|
+
npm test # Birim testleri (node --test)
|
|
138
|
+
npm run build # dist/ klasörüne derleme
|
|
139
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ContextModel, type RunModel } from "../../src/context.ts";
|
|
2
|
+
import type { ContextSession } from "./types.ts";
|
|
3
|
+
export interface OnnxContextOptions {
|
|
4
|
+
/** `onnxruntime-web` `.wasm`/`.mjs` dosyalarının bulunduğu dizin URL'si. */
|
|
5
|
+
wasmPaths?: string;
|
|
6
|
+
}
|
|
7
|
+
/** Bir `ContextModel` örneğini veya `RunModel` işlevini `ContextSession` arayüzüne sarar. */
|
|
8
|
+
export declare function wrapContextModel(modelOrRun: ContextModel | RunModel): ContextSession;
|
|
9
|
+
/**
|
|
10
|
+
* İndirilen `context.onnx` baytlarından `onnxruntime-web` WASM oturumu açar.
|
|
11
|
+
* `onnxruntime-web/wasm` yalnızca bu işlev çağrıldığında (yani `context: true` iken) dinamik `import()` ile yüklenir.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createOnnxContextSession(modelBytes: Uint8Array, options?: OnnxContextOptions): Promise<ContextSession>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ContextModel, FEATURE_DIM, LEGACY_FEATURE_DIM, SEQUENCE, sliceLegacyFeatures } from "../../src/context.js";
|
|
2
|
+
/** Bir `ContextModel` örneğini veya `RunModel` işlevini `ContextSession` arayüzüne sarar. */
|
|
3
|
+
export function wrapContextModel(modelOrRun) {
|
|
4
|
+
const model = typeof modelOrRun === "function" ? new ContextModel(modelOrRun) : modelOrRun;
|
|
5
|
+
return {
|
|
6
|
+
model,
|
|
7
|
+
dispose: async () => { },
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* İndirilen `context.onnx` baytlarından `onnxruntime-web` WASM oturumu açar.
|
|
12
|
+
* `onnxruntime-web/wasm` yalnızca bu işlev çağrıldığında (yani `context: true` iken) dinamik `import()` ile yüklenir.
|
|
13
|
+
*/
|
|
14
|
+
export async function createOnnxContextSession(modelBytes, options = {}) {
|
|
15
|
+
const ort = await import("onnxruntime-web/wasm");
|
|
16
|
+
if (options.wasmPaths !== undefined) {
|
|
17
|
+
ort.env.wasm.wasmPaths = options.wasmPaths;
|
|
18
|
+
}
|
|
19
|
+
// Cross-Origin Isolation (COOP/COEP) olmayan sayfalarda SharedArrayBuffer yoktur; tek iş parçacıklı WASM güvenlidir.
|
|
20
|
+
if (typeof crossOriginIsolated === "boolean" && !crossOriginIsolated) {
|
|
21
|
+
ort.env.wasm.numThreads = 1;
|
|
22
|
+
}
|
|
23
|
+
const session = await ort.InferenceSession.create(modelBytes, {
|
|
24
|
+
executionProviders: ["wasm"],
|
|
25
|
+
});
|
|
26
|
+
let released = false;
|
|
27
|
+
// onnxruntime-web WASM oturumu eşzamanlı session.run() çağrılarını desteklemez; çağrıları sıraya koyuyoruz.
|
|
28
|
+
let queue = Promise.resolve();
|
|
29
|
+
const enqueue = (task) => {
|
|
30
|
+
const next = queue.then(task, task);
|
|
31
|
+
queue = next.catch(() => { });
|
|
32
|
+
return next;
|
|
33
|
+
};
|
|
34
|
+
const wantsSubwords = session.inputNames.includes("subwords");
|
|
35
|
+
const wantsFeatures = session.inputNames.includes("features");
|
|
36
|
+
const run = (tokens, segments, n, features, subwords) => enqueue(async () => {
|
|
37
|
+
if (released) {
|
|
38
|
+
throw new Error("autr: Bağlam modeli kapatıldı (dispose edildi).");
|
|
39
|
+
}
|
|
40
|
+
const feeds = {};
|
|
41
|
+
if (wantsSubwords && subwords) {
|
|
42
|
+
feeds["subwords"] = new ort.Tensor("int64", subwords.subwords, [n, subwords.seqLen]);
|
|
43
|
+
feeds["sub_segments"] = new ort.Tensor("int64", subwords.subSegments, [n, subwords.seqLen]);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
feeds["tokens"] = new ort.Tensor("int64", tokens, [n, SEQUENCE]);
|
|
47
|
+
feeds["segments"] = new ort.Tensor("int64", segments, [n, SEQUENCE]);
|
|
48
|
+
}
|
|
49
|
+
if (wantsFeatures) {
|
|
50
|
+
const featArr = features ?? new Float32Array(n * FEATURE_DIM);
|
|
51
|
+
if (wantsSubwords) {
|
|
52
|
+
feeds["features"] = new ort.Tensor("float32", featArr, [n, FEATURE_DIM]);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
feeds["features"] = new ort.Tensor("float32", sliceLegacyFeatures(featArr, n), [n, LEGACY_FEATURE_DIM]);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const result = await session.run(feeds);
|
|
59
|
+
const output = result["scores"] ?? Object.values(result)[0];
|
|
60
|
+
if (!output) {
|
|
61
|
+
throw new Error("autr: Bağlam modeli beklenen 'scores' çıktısını döndürmedi.");
|
|
62
|
+
}
|
|
63
|
+
if (output.data instanceof Float32Array) {
|
|
64
|
+
return output.data;
|
|
65
|
+
}
|
|
66
|
+
throw new Error("autr: Bağlam modeli 'scores' çıktısı beklenen float32 türünde değil.");
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
model: new ContextModel(run, { subwordsOnly: wantsSubwords }),
|
|
70
|
+
dispose: async () => {
|
|
71
|
+
if (released)
|
|
72
|
+
return;
|
|
73
|
+
released = true;
|
|
74
|
+
await queue.catch(() => { });
|
|
75
|
+
if (typeof session.release === "function") {
|
|
76
|
+
await session.release();
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ContextModel, RunModel } from "../../src/context.ts";
|
|
2
|
+
import type { WordValidator } from "../../src/corrector.ts";
|
|
3
|
+
import { KnownMisspellings } from "../../src/known.ts";
|
|
4
|
+
import { Lexicon } from "../../src/lexicon.ts";
|
|
5
|
+
import { CONTEXT_MODEL_FILE } from "./types.ts";
|
|
6
|
+
import type { BinaryData, ContextSession, ContextSessionLoader, ProgressCallback, RawData, WarningCallback } from "./types.ts";
|
|
7
|
+
/** Zorunlu tarayıcı veri dosyaları (ikili sözlük + biçimbilim + bilinen yanlışlar). */
|
|
8
|
+
export declare const DATA_FILES: readonly ("lexicon.bin" | "morph.bin" | "known.tsv")[];
|
|
9
|
+
/** Eski düz metin TSV dosya listesi (geriye dönük uyumluluk için). */
|
|
10
|
+
export declare const LEGACY_DATA_FILES: readonly ("unigrams.tsv" | "bigrams.tsv" | "known.tsv")[];
|
|
11
|
+
export { CONTEXT_MODEL_FILE };
|
|
12
|
+
/** Varsayılan sözlük ve model dizini. */
|
|
13
|
+
export declare const DEFAULT_BASE_URL = "/models/";
|
|
14
|
+
export interface LoadedData {
|
|
15
|
+
lexicon: Lexicon;
|
|
16
|
+
known: KnownMisspellings;
|
|
17
|
+
morphology?: WordValidator;
|
|
18
|
+
contextSession?: ContextSession | null;
|
|
19
|
+
}
|
|
20
|
+
export interface FetchDataOptions {
|
|
21
|
+
fetch?: typeof globalThis.fetch;
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
onProgress?: ProgressCallback;
|
|
24
|
+
}
|
|
25
|
+
export interface ParseDataOptions {
|
|
26
|
+
minCount?: number;
|
|
27
|
+
minPair?: number;
|
|
28
|
+
yieldToMain?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface LoadDataOptions extends FetchDataOptions, ParseDataOptions {
|
|
31
|
+
baseUrl?: string | URL;
|
|
32
|
+
data?: RawData | BinaryData;
|
|
33
|
+
context?: boolean;
|
|
34
|
+
wasmPaths?: string | URL;
|
|
35
|
+
contextModel?: ContextModel | RunModel;
|
|
36
|
+
loadContextSession?: ContextSessionLoader;
|
|
37
|
+
onWarning?: WarningCallback;
|
|
38
|
+
}
|
|
39
|
+
/** Verilen bellek içi verinin ikili (`BinaryData`) biçimde olup olmadığını söyler. */
|
|
40
|
+
export declare function isBinaryData(data: RawData | BinaryData): data is BinaryData;
|
|
41
|
+
/** Göreli veya mutlak URL/yol değerini sona `/` ekleyerek çözümler. */
|
|
42
|
+
export declare function resolveBaseUrl(baseUrl?: string | URL): string;
|
|
43
|
+
/** `baseUrl` altından eski ham TSV dosyalarını (`unigrams.tsv`, `bigrams.tsv`, `known.tsv`) indirir. */
|
|
44
|
+
export declare function fetchRawData(baseUrl?: string | URL, options?: FetchDataOptions): Promise<RawData>;
|
|
45
|
+
/** Ham TSV metinlerini motorun kullandığı `Lexicon`, `KnownMisspellings` ve isteğe bağlı `TurkishMorphology` yapılarına dönüştürür. */
|
|
46
|
+
export declare function parseRawData(raw: RawData, options?: ParseDataOptions): Promise<LoadedData>;
|
|
47
|
+
/** Sıkıştırılmış ikili sözlük (`lexicon.bin` + `morph.bin` + `known.tsv`) verisini motorun yapılarına dönüştürür. */
|
|
48
|
+
export declare function parseBinaryData(binary: BinaryData, options?: ParseDataOptions): Promise<LoadedData>;
|
|
49
|
+
/** Sözlüğü, biçimbilimi (ve istenirse bağlam modelini) indirir, ayrıştırır ve yükleme ilerlemesini bildirir. */
|
|
50
|
+
export declare function loadData(options?: LoadDataOptions): Promise<LoadedData>;
|