khmer-text-corpus / README.md
Panhapich's picture
Upload README.md with huggingface_hub
b7074bc verified
|
Raw
History Blame Contribute Delete
5.5 kB
---
license: other
language:
- km
- en
multilinguality: multilingual
size_categories:
- 1M<n<10M
task_categories:
- text-generation
- fill-mask
task_ids:
- language-modeling
- masked-language-modeling
tags:
- khmer
- cambodia
- code-switching
- sentencepiece
- diffusion-lm
- low-resource
pretty_name: Khmer + English Mixed Text Corpus
configs:
- config_name: raw
default: true
data_files:
- split: train
path: all_text.txt
- config_name: segmented
data_files:
- split: train
path: all_text_segmented.txt
---
# Khmer + English Mixed Text Corpus
A cleaned, deduplicated Khmer text corpus with naturally-occurring **Khmer/English
code-switching** (English tech & finance terms, Latin script, and digits embedded in Khmer
text). It is the training data for the
[`Panhapich/khmer-sp-8k`](https://huggingface.co/Panhapich/khmer-sp-8k) SentencePiece tokenizer and the
text-only warm-start of a shared Khmer diffusion decoder.
## Dataset summary
- **4,893,739 sentences**, one per line, UTF-8, deduplicated and shuffled
(fixed seed 42, reproducible).
- Two parallel versions of the same corpus are provided as separate configs — see
[Dataset structure](#dataset-structure).
- Khmer/English mixing is **entirely organic**: it comes from the real sources below (receipt
line items, tech/finance terms in headlines and raw text). No synthetic code-switching is
injected anywhere in this corpus.
## Dataset structure
### Configs / files
| Config | File | Description |
|---|---|---|
| `raw` (default) | `all_text.txt` | Natural Khmer text, no artificial word-boundary spaces. General-purpose use. |
| `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. |
```python
from datasets import load_dataset
raw = load_dataset("Panhapich/khmer-text-corpus", "raw") # or omit the config name, it's the default
segmented = load_dataset("Panhapich/khmer-text-corpus", "segmented")
```
### Data instances
Each row is a single field, `text`: one normalized sentence (or, in the `segmented` config,
one word-segmented sentence with explicit spaces between Khmer words).
### Data splits
A single `train` split — this is raw pretraining/tokenizer-training text, not a supervised
task with held-out evaluation labels.
## Dataset creation
### Source data
Built from exactly four sources, mixed together, deduplicated, and shuffled. A global cap
(`5,000,000` sentences) bounds the total — small sources and the local file are
taken in full, and the large raw-text source fills the remainder:
| Source | Field | Description | Collected (pre-dedup) | Share |
|---|---|---|---|---|
| `nphearum/khmer-raw-text-3M-v2` | text | Large raw Khmer text (split on the Khmer full stop `។`) | 4,836,355 | 96.7% |
| `Sokheng/khmer-synthetic-ocr-v1-100k` | text | Synthetic OCR receipt/label text (Khmer/English/digit mixed) | 93,293 | 1.9% |
| `khmer_corpus.txt` | line | Pre-chunked ~1000-character Khmer text blocks (local file) | 35,373 | 0.7% |
| `rinabuoy/aupp-assignment-data` | title | Khmer news headlines | 34,991 | 0.7% |
**The Khmer/English mixing is entirely organic** — it comes from the real sources above. No
synthetic code-switching is injected.
### Curation / preprocessing
Every sentence is normalized: coerce to string, strip, replace newlines/tabs with a single
space, collapse repeated whitespace, and drop empty/invalid labels (`???`, `NULL`, `N/A`,
`UNKNOWN`). Khmer word-spacing, punctuation, Khmer + Arabic numerals, and English/Latin tokens
are preserved. Hub-source sentences are kept only if 5-400 characters; the local blocks are
exempt from the length cap. The corpus is deduplicated and shuffled with a fixed seed (42) for
reproducibility.
The `segmented` config additionally runs `khmer-nltk` word segmentation, with English/digit
spans and known loanwords/acronyms (ATM, ABA, PDF, ...) masked out beforehand so the segmenter
doesn't shatter them, and glued English/Latin runs (e.g. `tryAImodel`) further decomposed via
frequency-based word segmentation, guarded by a domain exception list (ACLEDA, Bakong, COVID-19,
5G, ...) so real terms aren't mangled. Full pipeline: `khmer_segmentation.py` in
[`Panhapich/khmer-sp-8k`](https://huggingface.co/Panhapich/khmer-sp-8k).
## Considerations for using the data
- **Known noise**: the local `khmer_corpus.txt` source and the raw-web-scraped Hub source
contain some non-standard spelling, stray symbols, and OCR artifacts. This is real-world
scraped text, not a curated, edited corpus.
- **Not filtered for PII** beyond the basic invalid-label rules above.
- **Plain text only** — no labels, translations, or task annotations.
- **Segmentation is a statistical CRF model**, not a hand-built rule system — it generalizes
well to ordinary Khmer but was not evaluated line-by-line against this specific corpus; treat
the `segmented` config as "reduces cross-word token fusion," not "hand-verified perfect."
## Licensing
This corpus is derived from third-party datasets and inherits their licenses. Confirm the terms
of each source above and set the `license` field accordingly — `other` is a placeholder.