File size: 8,508 Bytes
db9e4c0
 
 
30e5f58
 
 
db9e4c0
 
30e5f58
 
 
 
 
 
db9e4c0
 
30e5f58
db9e4c0
30e5f58
 
 
 
db9e4c0
30e5f58
db9e4c0
30e5f58
 
 
 
db9e4c0
30e5f58
db9e4c0
30e5f58
db9e4c0
30e5f58
 
 
 
db9e4c0
30e5f58
db9e4c0
30e5f58
 
 
 
 
 
 
 
 
 
bb3c2af
00ee721
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192045a
 
 
 
 
 
 
 
 
30e5f58
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
---
language:
- ku
- ckb
- kmr
- hac
size_categories:
- 1B<n<10B
license: cc-by-4.0
pretty_name: KurCorpus 2B
tags:
- kurdish
- low-resource
- language-modeling
---

# KurCorpus 2B

![License: CC BY 4.0](https://img.shields.io/badge/License-CC%20BY%204.0-blue)
![Language: Kurdish (ckb/kmr/hac)](https://img.shields.io/badge/Language-Kurdish%20(ckb%2Fkmr%2Fhac)-informational)
![Size: 2B+ tokens](https://img.shields.io/badge/Size-2B%2B%20tokens-brightgreen)
[![DOI](https://img.shields.io/badge/DOI-10.17632%2Ffb5xhhn6m5.1-orange)](https://doi.org/10.17632/fb5xhhn6m5.1)

**KurCorpus 2B** is a multidialectal Kurdish text corpus (>2B tokens) for large-scale language modeling and downstream NLP.

- **Dialects:** Sorani (ckb), Kurmanji/Badini (kmr), Hawrami/Gorani (hac)  
- **License:** CC BY 4.0  
- **Repo:** https://huggingface.co/datasets/abdulhade/Kurdishcorpus  
- **External record:** Mendeley Data DOI `10.17632/fb5xhhn6m5.1`

---

## TL;DR

- Ready for **pretraining** and **finetuning** Kurdish LMs  
- Single field **`text`** (UTF-8), offered as large archives or sharded `.txt(.gz)`  
- Includes **normalization and cleaning** (Unicode, orthography, noise removal with placeholders like `[URL]`, `[EMAIL]`)  
- No official splits; create your own task-specific splits and report dialect coverage

---

## Quickstart

```python
from datasets import load_dataset

# Stream without downloading everything at once (recommended for very large corpora)
ds = load_dataset("abdulhade/Kurdishcorpus", split="train", streaming=True)

for i, ex in enumerate(ds.take(5)):
    print(ex["text"])
```
# Text Normalization (AsoSoft Library)

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.

- Library: **AsoSoft Library** (C#/.NET) by Aso Mahmudi  
- Repo: https://github.com/AsoSoft/AsoSoft-Library  
- Scope: Kurdish Sorani (ckb) primary, with script-agnostic steps for other Kurdish varieties (kmr, hac)

---

## Why normalize

- Reduce spurious vocabulary caused by look-alike glyphs and legacy encodings.
- Ensure consistent numerals and punctuation for stable tokenization.
- Replace privacy-sensitive artifacts like URLs and emails with safe placeholders.
- Remove invisible noise (tatweel, zero-widths, control chars) that hurts training.

---

## What the pipeline does

### 1) Legacy encodings to Unicode (conditional)
Applied only when legacy font artifacts are detected.

- `AliK2Unicode`
- `AliWeb2Unicode`
- `Dylan2Unicode`
- `Zarnegar2Unicode`

### 2) HTML and web artifacts
- `ReplaceHtmlEntity` converts entities (e.g. `&quot;``"`).
- `ReplaceUrlEmail` replaces URLs and emails with `[URL]` and `[EMAIL]`.

### 3) Unicode standardization and Kurdish-specific fixes
`Normalize(...)` with deep and additional corrections enabled.

- Replace Arabic Presentation Forms with standard code points.
- Remove Tatweel U+0640 and stray control/zero-width characters.
- Normalize dashes and spaces.
- Map visually similar Arabic letters to Kurdish standard forms (e.g. ڪ, ے, ٶ → ک, ی, ؤ).
- Kurdish-specific standardization of `ە, هـ, ی, ک`.
- Correct frequent mis-conversions from non-Unicode fonts.
- Optionally convert word-initial `ر` to `ڕ`.

### 4) Punctuation and whitespace
- `NormalizePunctuations(text, separateAllPunctuations=false)` ensures no extra spaces around punctuation.
- `TrimLine` trims leading/trailing whitespace including zero-width spaces.

### 5) Numerals and digit separation
- `UnifyNumerals(text, "en")` normalizes all digits to ASCII 0–9 for tokenizer stability.
- `SeperateDigits` inserts spaces between digits and adjacent letters (e.g. `12کەس``12 کەس`).

> 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.

---

## Reproducible configuration

We run the following configuration in order. The last step that applies is the one whose conditions are met.

```csharp
using AsoSoftLibrary;

string NormalizeCkbLine(string text)
{
    // 1) Legacy converters (conditional, heuristic triggers)
    if (LooksLikeAliK(text))      text = AsoSoft.AliK2Unicode(text);
    if (LooksLikeAliWeb(text))    text = AsoSoft.AliWeb2Unicode(text);
    if (LooksLikeDylan(text))     text = AsoSoft.Dylan2Unicode(text);
    if (LooksLikeZarnegar(text))  text = AsoSoft.Zarnegar2Unicode(text);

    // 2) HTML and web artifacts
    text = AsoSoft.ReplaceHtmlEntity(text);
    text = AsoSoft.ReplaceUrlEmail(text); // replaces with [URL], [EMAIL]

    // 3) Unicode standardization (+ Kurdish fixes)
    // changeInitialR=true enables initial ر → ڕ
    text = AsoSoft.Normalize(
        text: text,
        isOnlyKurdish: true,
        changeInitialR: true,
        deepUnicodeCorrectios: true,
        additionalUnicodeCorrections: true,
        usersReplaceList: null
    );

    // 4) Punctuation and whitespace
    text = AsoSoft.NormalizePunctuations(text, separateAllPunctuations: false);
    text = AsoSoft.TrimLine(text);

    // 5) Numerals and digit separation
    text = AsoSoft.UnifyNumerals(text, "en");
    text = AsoSoft.SeperateDigits(text);

    return text;
}
```

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.

---

## Before and after examples

```
Input : دەقی«کوردی » و ڕێنووس ،((خاڵبەندی )) چۆنە ؟
Output: دەقی «کوردی» و ڕێنووس، «خاڵبەندی» چۆنە?
```

```
Input : ژمارەکانی ٤٥٦ و ۴۵۶ و 456
Output: ژمارەکانی 456 و 456 و 456
```

```
Input : دەقے شیَعري خـــۆش. ره‌نگه‌كاني خاك
Output: دەقی شێعری خۆش. ڕەنگەکانی خاک
```

```
Input : ئێوە &quot;دەق&quot; لە زمانی &lt;کوردی&gt; دەنووسن
Output: ئێوە "دەق" بە زمانی <کوردی> دەنووسن
```

```
Input : لە ساڵی1950دا1000دۆلاریان بە 5کەس دا
Output: لە ساڵی 1950 دا 1000 دۆلاریان بە 5 کەس دا
```

---

## What we do not do

- No transliteration or G2P on the released corpus. The text remains in its native script.
- No poem meter classification during release processing.
- No semantic rewriting beyond canonical character and punctuation normalization.

---

## Dialect coverage policy

- **ckb**: full AsoSoft normalization including Kurdish-specific fixes.
- **kmr/hac**: script-agnostic cleanup only. We avoid ckb-specific letter substitutions to preserve dialectal orthography and phonology.

---

## Quality checks

- Character inventory auditing before and after normalization.
- Proportion of placeholders `[URL]`, `[EMAIL]` to detect crawler bias.
- Count of removed control and zero-width characters.
- Round-trip sampling with spot manual verification on ambiguous lines.
- Determinism check: same input produces same output across runs.

---

## Reproducing locally

1. Install .NET 6 or newer.
2. Add AsoSoft Library via NuGet in your C# project.
3. Pipe your text through a console app using the configuration above.

Example console usage:

```bash
dotnet run --project NormalizerApp --input data/raw.txt --output data/normalized.txt
```

Where `NormalizerApp` calls `NormalizeCkbLine` for each line.

---

## Parameters you can tune

- `changeInitialR`: set to `false` if you do not want `ر` to become `ڕ` word-initially.
- `UnifyNumerals` target: `"en"` for ASCII 0–9 or `"ar"` for Arabic-Indic digits, depending on your tokenizer.
- `separateAllPunctuations`: set to `true` if you prefer all punctuation to be isolated by spaces for whitespace-tokenized pipelines.

---

## Cite

If you use **KurCorpus 2B**, please cite:

[![DOI](https://img.shields.io/badge/DOI-10.17632%2Ffb5xhhn6m5.1-orange)](https://doi.org/10.17632/fb5xhhn6m5.1)

**BibTeX**
```bibtex
@dataset{rawf2025kurcorpus2b,
  title   = {KurCorpus 2B: A Multidialectal 2-Billion-Token Corpus for Kurdish Language Modeling},
  author  = {Rawf, Karwan Mahdi and Abdullah, Abdullah and Hussein, Amanj and Mohammed, Haukar},
  year    = {2025},
  version = {1},
  howpublished = {Mendeley Data},
  doi     = {10.17632/fb5xhhn6m5.1}
}