Panhapich commited on
Commit
b7074bc
·
verified ·
1 Parent(s): dcf98f3

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +91 -36
README.md CHANGED
@@ -3,70 +3,125 @@ license: other
3
  language:
4
  - km
5
  - en
 
 
 
6
  task_categories:
7
  - text-generation
8
  - fill-mask
 
 
 
9
  tags:
10
  - khmer
11
  - cambodia
12
  - code-switching
13
  - sentencepiece
14
  - diffusion-lm
 
15
  pretty_name: Khmer + English Mixed Text Corpus
 
 
 
 
 
 
 
 
 
 
16
  ---
17
 
18
  # Khmer + English Mixed Text Corpus
19
 
20
- A cleaned, deduplicated Khmer text corpus with naturally-occurring **Khmer/English code-switching**
21
- (English tech & finance terms, Latin script, and digits embedded in Khmer text). It is the training
22
- data for the [`Panhapich/khmer-sp-8k`](https://huggingface.co/Panhapich/khmer-sp-8k) SentencePiece tokenizer
23
- and the text-only warm-start of a shared Khmer diffusion decoder.
 
24
 
25
- ## Contents
26
 
27
- | File | Description |
28
- |---|---|
29
- | `all_text.txt` | The corpus. One normalized sentence per line, UTF-8. |
30
- | `metadata.json` | Corpus statistics and provenance. |
 
 
 
31
 
32
- - **Total sentences:** 4,893,739
33
 
34
- ## Sources
35
 
36
- Built from exactly four sources, mixed together and shuffled. A global cap
37
- (`5,000,000` sentences) bounds the total — small sources and the local file are taken
38
- in full, and the large raw-text source fills the remainder:
39
-
40
- | Source | Field | Contribution |
41
  |---|---|---|
42
- | `Sokheng/khmer-synthetic-ocr-v1-100k` | `text` | Synthetic OCR receipt/label text (Khmer/English/digit mixed) |
43
- | `rinabuoy/aupp-assignment-data` | `title` | Khmer news headlines |
44
- | `nphearum/khmer-raw-text-3M-v2` | `text` | Large raw Khmer text (split on the Khmer full stop `។`) |
45
- | `khmer_corpus.txt` (local) | line | Pre-chunked ~1000-character Khmer text blocks |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
- **The Khmer/English mixing is entirely organic** it comes from the real sources. No synthetic
48
- code-switching is injected.
 
49
 
50
- ## Preprocessing
 
 
 
 
 
51
 
52
- Every sentence is normalized: coerce to string, strip, replace newlines/tabs with a single space,
53
- collapse repeated whitespace, and drop empty/invalid labels (`???`, `NULL`, `N/A`, `UNKNOWN`).
54
- Khmer word-spacing, punctuation, Khmer + Arabic numerals, and English/Latin tokens are preserved.
55
 
56
- Hub-source sentences are kept only if 5-400 characters; the local blocks are exempt from the length
57
- cap. The corpus is deduplicated and shuffled with a fixed seed (42) for reproducibility.
58
 
59
- ## Intended use
 
 
 
 
 
60
 
61
- Subword tokenizer training for Khmer with code-switched English, text-only diffusion/masked-LM
62
- pretraining of a Khmer decoder, and general mixed-script Khmer NLP.
 
 
 
 
63
 
64
- ## Out of scope / limitations
65
 
66
- Plain text only (no labels or translations). Includes synthetic OCR text and raw web-scraped text,
67
- so expect some noise and non-standard spelling. Not filtered for PII beyond the rules above.
 
 
 
 
 
 
68
 
69
  ## Licensing
70
 
71
- This corpus is derived from third-party datasets and inherits their licenses. Confirm the terms of
72
- each source above and set the `license` field accordingly — `other` is a placeholder.
 
3
  language:
4
  - km
5
  - en
6
+ multilinguality: multilingual
7
+ size_categories:
8
+ - 1M<n<10M
9
  task_categories:
10
  - text-generation
11
  - fill-mask
12
+ task_ids:
13
+ - language-modeling
14
+ - masked-language-modeling
15
  tags:
16
  - khmer
17
  - cambodia
18
  - code-switching
19
  - sentencepiece
20
  - diffusion-lm
21
+ - low-resource
22
  pretty_name: Khmer + English Mixed Text Corpus
23
+ configs:
24
+ - config_name: raw
25
+ default: true
26
+ data_files:
27
+ - split: train
28
+ path: all_text.txt
29
+ - config_name: segmented
30
+ data_files:
31
+ - split: train
32
+ path: all_text_segmented.txt
33
  ---
34
 
35
  # Khmer + English Mixed Text Corpus
36
 
37
+ A cleaned, deduplicated Khmer text corpus with naturally-occurring **Khmer/English
38
+ code-switching** (English tech & finance terms, Latin script, and digits embedded in Khmer
39
+ text). It is the training data for the
40
+ [`Panhapich/khmer-sp-8k`](https://huggingface.co/Panhapich/khmer-sp-8k) SentencePiece tokenizer and the
41
+ text-only warm-start of a shared Khmer diffusion decoder.
42
 
43
+ ## Dataset summary
44
 
45
+ - **4,893,739 sentences**, one per line, UTF-8, deduplicated and shuffled
46
+ (fixed seed 42, reproducible).
47
+ - Two parallel versions of the same corpus are provided as separate configs see
48
+ [Dataset structure](#dataset-structure).
49
+ - Khmer/English mixing is **entirely organic**: it comes from the real sources below (receipt
50
+ line items, tech/finance terms in headlines and raw text). No synthetic code-switching is
51
+ injected anywhere in this corpus.
52
 
53
+ ## Dataset structure
54
 
55
+ ### Configs / files
56
 
57
+ | Config | File | Description |
 
 
 
 
58
  |---|---|---|
59
+ | `raw` (default) | `all_text.txt` | Natural Khmer text, no artificial word-boundary spaces. General-purpose use. |
60
+ | `segmented` | `all_text_segmented.txt` | Same 4,893,739 sentences, run through `khmer-nltk` word segmentation + gazetteer/Latin masking (see [`Panhapich/khmer-sp-8k`](https://huggingface.co/Panhapich/khmer-sp-8k)). Ready for SentencePiece-style subword training without re-running segmentation yourself. |
61
+
62
+ ```python
63
+ from datasets import load_dataset
64
+
65
+ raw = load_dataset("Panhapich/khmer-text-corpus", "raw") # or omit the config name, it's the default
66
+ segmented = load_dataset("Panhapich/khmer-text-corpus", "segmented")
67
+ ```
68
+
69
+ ### Data instances
70
+
71
+ Each row is a single field, `text`: one normalized sentence (or, in the `segmented` config,
72
+ one word-segmented sentence with explicit spaces between Khmer words).
73
+
74
+ ### Data splits
75
+
76
+ A single `train` split — this is raw pretraining/tokenizer-training text, not a supervised
77
+ task with held-out evaluation labels.
78
+
79
+ ## Dataset creation
80
+
81
+ ### Source data
82
 
83
+ Built from exactly four sources, mixed together, deduplicated, and shuffled. A global cap
84
+ (`5,000,000` sentences) bounds the total — small sources and the local file are
85
+ taken in full, and the large raw-text source fills the remainder:
86
 
87
+ | Source | Field | Description | Collected (pre-dedup) | Share |
88
+ |---|---|---|---|---|
89
+ | `nphearum/khmer-raw-text-3M-v2` | text | Large raw Khmer text (split on the Khmer full stop `។`) | 4,836,355 | 96.7% |
90
+ | `Sokheng/khmer-synthetic-ocr-v1-100k` | text | Synthetic OCR receipt/label text (Khmer/English/digit mixed) | 93,293 | 1.9% |
91
+ | `khmer_corpus.txt` | line | Pre-chunked ~1000-character Khmer text blocks (local file) | 35,373 | 0.7% |
92
+ | `rinabuoy/aupp-assignment-data` | title | Khmer news headlines | 34,991 | 0.7% |
93
 
94
+ **The Khmer/English mixing is entirely organic** it comes from the real sources above. No
95
+ synthetic code-switching is injected.
 
96
 
97
+ ### Curation / preprocessing
 
98
 
99
+ Every sentence is normalized: coerce to string, strip, replace newlines/tabs with a single
100
+ space, collapse repeated whitespace, and drop empty/invalid labels (`???`, `NULL`, `N/A`,
101
+ `UNKNOWN`). Khmer word-spacing, punctuation, Khmer + Arabic numerals, and English/Latin tokens
102
+ are preserved. Hub-source sentences are kept only if 5-400 characters; the local blocks are
103
+ exempt from the length cap. The corpus is deduplicated and shuffled with a fixed seed (42) for
104
+ reproducibility.
105
 
106
+ The `segmented` config additionally runs `khmer-nltk` word segmentation, with English/digit
107
+ spans and known loanwords/acronyms (ATM, ABA, PDF, ...) masked out beforehand so the segmenter
108
+ doesn't shatter them, and glued English/Latin runs (e.g. `tryAImodel`) further decomposed via
109
+ frequency-based word segmentation, guarded by a domain exception list (ACLEDA, Bakong, COVID-19,
110
+ 5G, ...) so real terms aren't mangled. Full pipeline: `khmer_segmentation.py` in
111
+ [`Panhapich/khmer-sp-8k`](https://huggingface.co/Panhapich/khmer-sp-8k).
112
 
113
+ ## Considerations for using the data
114
 
115
+ - **Known noise**: the local `khmer_corpus.txt` source and the raw-web-scraped Hub source
116
+ contain some non-standard spelling, stray symbols, and OCR artifacts. This is real-world
117
+ scraped text, not a curated, edited corpus.
118
+ - **Not filtered for PII** beyond the basic invalid-label rules above.
119
+ - **Plain text only** — no labels, translations, or task annotations.
120
+ - **Segmentation is a statistical CRF model**, not a hand-built rule system — it generalizes
121
+ well to ordinary Khmer but was not evaluated line-by-line against this specific corpus; treat
122
+ the `segmented` config as "reduces cross-word token fusion," not "hand-verified perfect."
123
 
124
  ## Licensing
125
 
126
+ This corpus is derived from third-party datasets and inherits their licenses. Confirm the terms
127
+ of each source above and set the `license` field accordingly — `other` is a placeholder.