Download conversion_script.py from thagen/CausalNewsCorpus: direct link, hf CLI and curl.
- Browser
- Download file 3.33 kB
-
https://huggingface.co/datasets/thagen/CausalNewsCorpus/resolve/main/conversion_script.py
- Command line
-
hf download hf://datasets/thagen/CausalNewsCorpus/conversion_script.py
-
curl -L -o conversion_script.py https://huggingface.co/datasets/thagen/CausalNewsCorpus/resolve/main/conversion_script.py
3.33 kB
| #!/usr/bin/env python3 | |
| """ | |
| Run this script as ./conversion_script.py to convert the Causal News Corpus | |
| (CNC) "V1" (2022) DIRECTLY from its original repository -- ``UniCausal2HF`` | |
| already reads a CSV given any path/URL pandas' own ``read_csv`` accepts, so | |
| no manual download/caching step is needed; point it straight at the raw | |
| GitHub URLs. Previously this dataset had 0 parquet files on disk (the old | |
| script expected a manually-placed ``cnc_train.csv`` that was never | |
| provided) -- this had never once been run. | |
| Citation / original source | |
| --------------------------- | |
| Tan, F. A., Ng, S.-K., & Ong, A. R. (2022). "The Causal News Corpus: | |
| Annotating Causal Relations in Event Sentences from News." LREC 2022. | |
| https://aclanthology.org/2022.lrec-1.246/ | |
| Repo (verified live, public, no login): github.com/tanfiona/CausalNewsCorpus | |
| License: CC0-1.0 (verified via GitHub API) -- public domain, no restrictions. | |
| This is the original 2022 release -- see ../CNCv2/conversion_script.py for | |
| "V2" (published as RECESS), the actively-maintained version the | |
| maintainers themselves now recommend ("For 2023 Shared Task, please use | |
| V2" -- repo README): V1's span annotations (subtask 2, Cause/Effect/Signal) | |
| are much sparser, only 183 causal relations total vs. V2's 2257 (verified: | |
| `train_subtask2_grouped.csv` + `dev_subtask2_grouped.csv` row counts). Kept | |
| as its own separate dataset rather than silently overwritten, so both | |
| remain available for comparison. | |
| Format: the ``_grouped`` CSVs already match causalatee's ``UniCausal2HF`` | |
| grouped format exactly (one row per sentence; ``causal_text_w_pairs`` is a | |
| Python-repr'd list of 0+ independently <ARG0>/<ARG1>/<SIGn>-tagged copies | |
| of that row's ``text``, one per causal relation -- ARG0=cause, ARG1=effect, | |
| confirmed against real "because"/"due to" examples) -- see | |
| causalatee/data/conversion/_unicausal2hf.py for the shared parsing logic | |
| (also used by BECauSEv2, AltLex). | |
| No usable test split: the real held-out test set (``test_subtask2_text.csv``) | |
| has NO gold labels at all and never will -- confirmed directly from | |
| data/V1's upstream README: labels are withheld for a recurring shared | |
| task. Mapped here as: upstream train -> causalatee train, upstream dev -> | |
| causalatee dev.parquet -- written as ``dev.parquet``, NOT ``test.parquet`` | |
| (fixed 2026-07-20; previously written as test.parquet, which claimed a | |
| real held-out test set exists when it's actually the upstream dev split). | |
| `with_validation_split` in the evaluation harness treats a dataset with | |
| dev but no test as: promote this dev to serve as the final eval target, | |
| and carve a FRESH validation split out of train for early stopping | |
| instead, so the promoted dev is never touched during training either way | |
| -- see its docstring. | |
| """ | |
| from pathlib import Path | |
| from causalatee.data.constants import Task | |
| from causalatee.data.conversion import UniCausal2HF | |
| _BASE_URL = "https://raw.githubusercontent.com/tanfiona/CausalNewsCorpus/master/data/V1" | |
| converter = UniCausal2HF( | |
| { | |
| "train": f"{_BASE_URL}/train_subtask2_grouped.csv", | |
| "dev": f"{_BASE_URL}/dev_subtask2_grouped.csv", | |
| }, | |
| Path.cwd(), | |
| ) | |
| for split in ["train", "dev"]: | |
| converter.convert(Task.CausalityDetection, split) | |
| converter.convert(Task.CausalCandidateExtraction, split) | |
| converter.convert(Task.CausalityIdentification, split) | |