Update README.md
Browse files
README.md
CHANGED
@@ -50,6 +50,185 @@ ds = load_dataset("abdulhade/Kurdishcorpus", split="train", streaming=True)
|
|
50 |
for i, ex in enumerate(ds.take(5)):
|
51 |
print(ex["text"])
|
52 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
## Cite
|
55 |
|
|
|
50 |
for i, ex in enumerate(ds.take(5)):
|
51 |
print(ex["text"])
|
52 |
```
|
53 |
+
# Text Normalization (AsoSoft Library)
|
54 |
+
|
55 |
+
This repository documents how Central Kurdish text is normalized with the **AsoSoft Library** before release. The goal is to standardize Unicode, punctuation, numerals, and common web artifacts so downstream tokenizers and language models see clean, consistent text.
|
56 |
+
|
57 |
+
- Library: **AsoSoft Library** (C#/.NET) by Aso Mahmudi
|
58 |
+
- Repo: https://github.com/AsoSoft/AsoSoft-Library
|
59 |
+
- Scope: Kurdish Sorani (ckb) primary, with script-agnostic steps for other Kurdish varieties (kmr, hac)
|
60 |
+
|
61 |
+
---
|
62 |
+
|
63 |
+
## Why normalize
|
64 |
+
|
65 |
+
- Reduce spurious vocabulary caused by look-alike glyphs and legacy encodings.
|
66 |
+
- Ensure consistent numerals and punctuation for stable tokenization.
|
67 |
+
- Replace privacy-sensitive artifacts like URLs and emails with safe placeholders.
|
68 |
+
- Remove invisible noise (tatweel, zero-widths, control chars) that hurts training.
|
69 |
+
|
70 |
+
---
|
71 |
+
|
72 |
+
## What the pipeline does
|
73 |
+
|
74 |
+
### 1) Legacy encodings to Unicode (conditional)
|
75 |
+
Applied only when legacy font artifacts are detected.
|
76 |
+
|
77 |
+
- `AliK2Unicode`
|
78 |
+
- `AliWeb2Unicode`
|
79 |
+
- `Dylan2Unicode`
|
80 |
+
- `Zarnegar2Unicode`
|
81 |
+
|
82 |
+
### 2) HTML and web artifacts
|
83 |
+
- `ReplaceHtmlEntity` converts entities (e.g. `"` → `"`).
|
84 |
+
- `ReplaceUrlEmail` replaces URLs and emails with `[URL]` and `[EMAIL]`.
|
85 |
+
|
86 |
+
### 3) Unicode standardization and Kurdish-specific fixes
|
87 |
+
`Normalize(...)` with deep and additional corrections enabled.
|
88 |
+
|
89 |
+
- Replace Arabic Presentation Forms with standard code points.
|
90 |
+
- Remove Tatweel U+0640 and stray control/zero-width characters.
|
91 |
+
- Normalize dashes and spaces.
|
92 |
+
- Map visually similar Arabic letters to Kurdish standard forms (e.g. ڪ, ے, ٶ → ک, ی, ؤ).
|
93 |
+
- Kurdish-specific standardization of `ە, هـ, ی, ک`.
|
94 |
+
- Correct frequent mis-conversions from non-Unicode fonts.
|
95 |
+
- Optionally convert word-initial `ر` to `ڕ`.
|
96 |
+
|
97 |
+
### 4) Punctuation and whitespace
|
98 |
+
- `NormalizePunctuations(text, separateAllPunctuations=false)` ensures no extra spaces around punctuation.
|
99 |
+
- `TrimLine` trims leading/trailing whitespace including zero-width spaces.
|
100 |
+
|
101 |
+
### 5) Numerals and digit separation
|
102 |
+
- `UnifyNumerals(text, "en")` normalizes all digits to ASCII 0–9 for tokenizer stability.
|
103 |
+
- `SeperateDigits` inserts spaces between digits and adjacent letters (e.g. `12کەس` → `12 کەس`).
|
104 |
+
|
105 |
+
> Note: For kmr/hac lines, we only apply script-agnostic steps (HTML/entity cleanup, URL/email replacement, Unicode cleanup, punctuation, numerals, trimming). We do not transliterate or run G2P on released text.
|
106 |
+
|
107 |
+
---
|
108 |
+
|
109 |
+
## Reproducible configuration
|
110 |
+
|
111 |
+
We run the following configuration in order. The last step that applies is the one whose conditions are met.
|
112 |
+
|
113 |
+
```csharp
|
114 |
+
using AsoSoftLibrary;
|
115 |
+
|
116 |
+
string NormalizeCkbLine(string text)
|
117 |
+
{
|
118 |
+
// 1) Legacy converters (conditional, heuristic triggers)
|
119 |
+
if (LooksLikeAliK(text)) text = AsoSoft.AliK2Unicode(text);
|
120 |
+
if (LooksLikeAliWeb(text)) text = AsoSoft.AliWeb2Unicode(text);
|
121 |
+
if (LooksLikeDylan(text)) text = AsoSoft.Dylan2Unicode(text);
|
122 |
+
if (LooksLikeZarnegar(text)) text = AsoSoft.Zarnegar2Unicode(text);
|
123 |
+
|
124 |
+
// 2) HTML and web artifacts
|
125 |
+
text = AsoSoft.ReplaceHtmlEntity(text);
|
126 |
+
text = AsoSoft.ReplaceUrlEmail(text); // replaces with [URL], [EMAIL]
|
127 |
+
|
128 |
+
// 3) Unicode standardization (+ Kurdish fixes)
|
129 |
+
// changeInitialR=true enables initial ر → ڕ
|
130 |
+
text = AsoSoft.Normalize(
|
131 |
+
text: text,
|
132 |
+
isOnlyKurdish: true,
|
133 |
+
changeInitialR: true,
|
134 |
+
deepUnicodeCorrectios: true,
|
135 |
+
additionalUnicodeCorrections: true,
|
136 |
+
usersReplaceList: null
|
137 |
+
);
|
138 |
+
|
139 |
+
// 4) Punctuation and whitespace
|
140 |
+
text = AsoSoft.NormalizePunctuations(text, separateAllPunctuations: false);
|
141 |
+
text = AsoSoft.TrimLine(text);
|
142 |
+
|
143 |
+
// 5) Numerals and digit separation
|
144 |
+
text = AsoSoft.UnifyNumerals(text, "en");
|
145 |
+
text = AsoSoft.SeperateDigits(text);
|
146 |
+
|
147 |
+
return text;
|
148 |
+
}
|
149 |
+
```
|
150 |
+
|
151 |
+
Heuristic detectors like `LooksLikeAliK` check for characteristic code points and glyph ranges associated with each legacy font family. The converters are applied only when such patterns are present.
|
152 |
+
|
153 |
+
---
|
154 |
+
|
155 |
+
## Before and after examples
|
156 |
+
|
157 |
+
```
|
158 |
+
Input : دەقی«کوردی » و ڕێنووس ،((خاڵبەندی )) چۆنە ؟
|
159 |
+
Output: دەقی «کوردی» و ڕێنووس، «خاڵبەندی» چۆنە?
|
160 |
+
```
|
161 |
+
|
162 |
+
```
|
163 |
+
Input : ژمارەکانی ٤٥٦ و ۴۵۶ و 456
|
164 |
+
Output: ژمارەکانی 456 و 456 و 456
|
165 |
+
```
|
166 |
+
|
167 |
+
```
|
168 |
+
Input : دەقے شیَعري خـــۆش. رهنگهكاني خاك
|
169 |
+
Output: دەقی شێعری خۆش. ڕەنگەکانی خاک
|
170 |
+
```
|
171 |
+
|
172 |
+
```
|
173 |
+
Input : ئێوە "دەق" لە زمانی <کوردی> دەنووسن
|
174 |
+
Output: ئێوە "دەق" بە زمانی <کوردی> دەنووسن
|
175 |
+
```
|
176 |
+
|
177 |
+
```
|
178 |
+
Input : لە ساڵی1950دا1000دۆلاریان بە 5کەس دا
|
179 |
+
Output: لە ساڵی 1950 دا 1000 دۆلاریان بە 5 کەس دا
|
180 |
+
```
|
181 |
+
|
182 |
+
---
|
183 |
+
|
184 |
+
## What we do not do
|
185 |
+
|
186 |
+
- No transliteration or G2P on the released corpus. The text remains in its native script.
|
187 |
+
- No poem meter classification during release processing.
|
188 |
+
- No semantic rewriting beyond canonical character and punctuation normalization.
|
189 |
+
|
190 |
+
---
|
191 |
+
|
192 |
+
## Dialect coverage policy
|
193 |
+
|
194 |
+
- **ckb**: full AsoSoft normalization including Kurdish-specific fixes.
|
195 |
+
- **kmr/hac**: script-agnostic cleanup only. We avoid ckb-specific letter substitutions to preserve dialectal orthography and phonology.
|
196 |
+
|
197 |
+
---
|
198 |
+
|
199 |
+
## Quality checks
|
200 |
+
|
201 |
+
- Character inventory auditing before and after normalization.
|
202 |
+
- Proportion of placeholders `[URL]`, `[EMAIL]` to detect crawler bias.
|
203 |
+
- Count of removed control and zero-width characters.
|
204 |
+
- Round-trip sampling with spot manual verification on ambiguous lines.
|
205 |
+
- Determinism check: same input produces same output across runs.
|
206 |
+
|
207 |
+
---
|
208 |
+
|
209 |
+
## Reproducing locally
|
210 |
+
|
211 |
+
1. Install .NET 6 or newer.
|
212 |
+
2. Add AsoSoft Library via NuGet in your C# project.
|
213 |
+
3. Pipe your text through a console app using the configuration above.
|
214 |
+
|
215 |
+
Example console usage:
|
216 |
+
|
217 |
+
```bash
|
218 |
+
dotnet run --project NormalizerApp --input data/raw.txt --output data/normalized.txt
|
219 |
+
```
|
220 |
+
|
221 |
+
Where `NormalizerApp` calls `NormalizeCkbLine` for each line.
|
222 |
+
|
223 |
+
---
|
224 |
+
|
225 |
+
## Parameters you can tune
|
226 |
+
|
227 |
+
- `changeInitialR`: set to `false` if you do not want `ر` to become `ڕ` word-initially.
|
228 |
+
- `UnifyNumerals` target: `"en"` for ASCII 0–9 or `"ar"` for Arabic-Indic digits, depending on your tokenizer.
|
229 |
+
- `separateAllPunctuations`: set to `true` if you prefer all punctuation to be isolated by spaces for whitespace-tokenized pipelines.
|
230 |
+
|
231 |
+
---
|
232 |
|
233 |
## Cite
|
234 |
|