phoneee/thai-legal-corpus
Thai Legal Corpus v1 Cleaned and deduplicated Thai legal text corpus for Continual Pre-Training (CPT), with structured citation metadata for legal analysis. Dataset Description Metric Value Total records 176,543 Total size 6.03 GB Avg doc length 11,952 chars Sources 3 Year range 1874-2026 Splits train 158,887 / val 8,826 / test 8,830 Sources Source Records krisdika 6,743 supreme_court 127,012 thailaw 42,788… See the full description on the dataset page: https://huggingface.co/datasets/phoneee/thai-legal-corpus.
Thai Legal Corpus v1
Cleaned and deduplicated Thai legal text corpus for Continual Pre-Training (CPT), with structured citation metadata for legal analysis.
Dataset Description
Sources
Repository Structure
data/
train.jsonl, val.jsonl, test.jsonl -- Cleaned text (for CPT)
metadata/
deka_citations.jsonl -- Citation metadata (join by doc_id)
law_section_index.json -- Law-section-case mapping
corpus_stats.jsonData Schema
Training Data (data/*.jsonl)
Citation Metadata (metadata/deka_citations.jsonl)
Structured fields for Supreme Court rulings. Join with training data on doc_id.
Law-Section-Case Index (metadata/law_section_index.json)
Structured mapping from Thai laws to sections to Supreme Court case counts.
Top laws: ป.พ.พ. (275,772 cases), ป.อ. (102,245), ป.วิ.อ. (99,840), ป.วิ.พ. (70,590)
Original Law Full Text Sources
Sources
- krisdika (Office of the Council of State) -- Structured laws from `open-law-data-thailand/ocs-krisdika`
- thailaw (PyThaiNLP) -- Full-text Thai laws from `pythainlp/thailaw-v1.0`
- supreme_court -- Supreme Court rulings from deka.supremecourt.or.th
Cleaning Pipeline
Integrated with OpenThaiGPT/data-processing patterns:
- Unicode NFC normalization + cc_net punctuation normalization + invisible/non-printing char removal
- Content cleaning: strip URLs, emails, HTML tags, iframes, markup, IPs, hashtags
- Encoding corruption detection: GHOST (double-encoding), NONECHAR (invalid Thai codepoints), NONETONEMARK (OCR artifacts)
- Quality filtering: Thai ratio >= 30%, text length 100-500K chars, garbled ratio < 10%
- Exact hash deduplication (MD5)
- Stratified 90/5/5 split by source
Intended Use
- Continual Pre-Training (CPT) of Thai language models for legal domain
- Legal citation analysis and knowledge graph construction
- Legal text analysis and information retrieval
Limitations
- Supreme Court rulings may contain archaic Thai legal terminology
- Some older statutory records may have OCR artifacts from source
- Year metadata is best-effort extraction from text
- Citation extraction is regex-based and may miss some references
Citation
@misc{thai-legal-corpus-2026,
title={Thai Legal Corpus v1},
year={2026},
howpublished={HuggingFace},
}