Publish KLAR reproducibility bundle (v1): text-free score bundles + analysis code for the 'Alles klar?' KlarText paper
f45e98c verified Download data_process/deplain_web.py from FraunhoferIAIS/KLAR: direct link, hf CLI and curl.
- Browser
- Download file 2.49 kB
-
https://huggingface.co/datasets/FraunhoferIAIS/KLAR/resolve/main/data_process/deplain_web.py
- Command line
-
hf download hf://datasets/FraunhoferIAIS/KLAR/data_process/deplain_web.py
-
curl -L -o deplain_web.py https://huggingface.co/datasets/FraunhoferIAIS/KLAR/resolve/main/data_process/deplain_web.py
2.49 kB
| """Build an eval dataset from DEplain-web-doc (German plain-language doc pairs). | |
| DEplain-web-doc (Stodden et al., ACL 2023) is openly loadable from HuggingFace with no | |
| auth. Each row has an `original` (complex) and a `simplification` (Einfache/Leichte | |
| Sprache) German document, plus CEFR levels and a `corpus` (subcorpus) tag we keep for | |
| register filtering. | |
| We map to the repo's eval-dataset schema ({title, original, human_translated}) and keep | |
| `corpus`/`complex_level`/`simple_level` as extra metadata. This materializes the human original/simplified pairs only. | |
| Run: | |
| python -m data_process.deplain_web | |
| """ | |
| from __future__ import annotations | |
| import json | |
| from pathlib import Path | |
| HF_DATASET = "DEplain/DEplain-web-doc" | |
| SPLITS = ("train", "validation", "test") | |
| def create_deplain_web_json(splits: tuple[str, ...] = SPLITS) -> int: | |
| """Load DEplain-web-doc (all splits by default) and write the eval dataset. | |
| Returns the number of records written. | |
| """ | |
| from datasets import load_dataset | |
| out_path = Path("data/deplain_web.json") | |
| data: list[dict] = [] | |
| for split in splits: | |
| ds = load_dataset(HF_DATASET, split=split) | |
| for i, row in enumerate(ds): | |
| original = (row.get("original") or "").strip() | |
| simplified = (row.get("simplification") or "").strip() | |
| if not original or not simplified: | |
| continue | |
| corpus = row.get("corpus", "") | |
| data.append( | |
| { | |
| "title": f"{corpus}:{split}:{i}", | |
| "original": original, | |
| "human_translated": simplified, | |
| "corpus": corpus, | |
| "complex_level": row.get("complex_level"), | |
| "simple_level": row.get("simple_level"), | |
| "split": split, | |
| } | |
| ) | |
| if not data: | |
| print("No DEplain-web records assembled - check dataset access.") | |
| return 0 | |
| out_path.parent.mkdir(parents=True, exist_ok=True) | |
| out_path.write_text( | |
| json.dumps(data, ensure_ascii=False, indent=2), encoding="utf-8" | |
| ) | |
| by_corpus: dict[str, int] = {} | |
| for d in data: | |
| by_corpus[d["corpus"]] = by_corpus.get(d["corpus"], 0) + 1 | |
| print(f"Wrote {len(data)} pairs to {out_path}") | |
| print( | |
| "By subcorpus: " + ", ".join(f"{k}={v}" for k, v in sorted(by_corpus.items())) | |
| ) | |
| return len(data) | |
| if __name__ == "__main__": | |
| create_deplain_web_json() | |