Tim Hagen commited on
Commit ·
2f10485
0
Parent(s):
Initial commit
Browse filesFiles changed (3)
- .gitattributesAdded+59
- README.mdAdded+168
- conversion_script.pyAdded+26
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859*.7z filter=lfs diff=lfs merge=lfs -text*.arrow filter=lfs diff=lfs merge=lfs -text*.bin filter=lfs diff=lfs merge=lfs -text*.bz2 filter=lfs diff=lfs merge=lfs -text*.ckpt filter=lfs diff=lfs merge=lfs -text*.ftz filter=lfs diff=lfs merge=lfs -text*.gz filter=lfs diff=lfs merge=lfs -text*.h5 filter=lfs diff=lfs merge=lfs -text*.joblib filter=lfs diff=lfs merge=lfs -text*.lfs.* filter=lfs diff=lfs merge=lfs -text*.lz4 filter=lfs diff=lfs merge=lfs -text*.mds filter=lfs diff=lfs merge=lfs -text*.mlmodel filter=lfs diff=lfs merge=lfs -text*.model filter=lfs diff=lfs merge=lfs -text*.msgpack filter=lfs diff=lfs merge=lfs -text*.npy filter=lfs diff=lfs merge=lfs -text*.npz filter=lfs diff=lfs merge=lfs -text*.onnx filter=lfs diff=lfs merge=lfs -text*.ot filter=lfs diff=lfs merge=lfs -text*.parquet filter=lfs diff=lfs merge=lfs -text*.pb filter=lfs diff=lfs merge=lfs -text*.pickle filter=lfs diff=lfs merge=lfs -text*.pkl filter=lfs diff=lfs merge=lfs -text*.pt filter=lfs diff=lfs merge=lfs -text*.pth filter=lfs diff=lfs merge=lfs -text*.rar filter=lfs diff=lfs merge=lfs -text*.safetensors filter=lfs diff=lfs merge=lfs -textsaved_model/**/* filter=lfs diff=lfs merge=lfs -text*.tar.* filter=lfs diff=lfs merge=lfs -text*.tar filter=lfs diff=lfs merge=lfs -text*.tflite filter=lfs diff=lfs merge=lfs -text*.tgz filter=lfs diff=lfs merge=lfs -text*.wasm filter=lfs diff=lfs merge=lfs -text*.xz filter=lfs diff=lfs merge=lfs -text*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text# Audio files - uncompressed*.pcm filter=lfs diff=lfs merge=lfs -text*.sam filter=lfs diff=lfs merge=lfs -text*.raw filter=lfs diff=lfs merge=lfs -text# Audio files - compressed*.aac filter=lfs diff=lfs merge=lfs -text*.flac filter=lfs diff=lfs merge=lfs -text*.mp3 filter=lfs diff=lfs merge=lfs -text*.ogg filter=lfs diff=lfs merge=lfs -text*.wav filter=lfs diff=lfs merge=lfs -text# Image files - uncompressed*.bmp filter=lfs diff=lfs merge=lfs -text*.gif filter=lfs diff=lfs merge=lfs -text*.png filter=lfs diff=lfs merge=lfs -text*.tiff filter=lfs diff=lfs merge=lfs -text# Image files - compressed*.jpg filter=lfs diff=lfs merge=lfs -text*.jpeg filter=lfs diff=lfs merge=lfs -text*.webp filter=lfs diff=lfs merge=lfs -text# Video files - compressed*.mp4 filter=lfs diff=lfs merge=lfs -text*.webm filter=lfs diff=lfs merge=lfs -text123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168---license: mittask_categories:- text-classification- token-classificationlanguage:- enmultilinguality:- monolingualsize_categories:- 1K<n<10Ktags:- causalitypretty_name: AltLexconfigs:- config_name: causality detection data_files: - split: train path: causality-detection/train.parquet - split: test path: causality-detection/test.parquet features: - name: index dtype: string - name: text dtype: string - name: label dtype: class_label: names: '0': uncausal '1': causal- config_name: causal candidate extraction data_files: - split: train path: causal-candidate-extraction/train.parquet - split: test path: causal-candidate-extraction/test.parquet features: - name: index dtype: string - name: text dtype: string - name: entity sequence: sequence: int32- config_name: causality identification data_files: - split: train path: causality-identification/train.parquet - split: test path: causality-identification/test.parquet features: - name: index dtype: string - name: text dtype: string - name: relations list: - name: relationship dtype: class_label: names: '0': no-rel '1': causal - name: first dtype: string - name: second dtype: stringtrain-eval-index:- config: causality detection task: text-classification task_id: text_classification splits: train_split: train eval_split: test col_mapping: text: text label: label metrics: - type: accuracy - type: precision - type: recall - type: f1- config: causal candidate extraction task: token-classification task_id: token_classification splits: train_split: train eval_split: test metrics: - type: accuracy - type: precision - type: recall - type: f1- config: causality identification task: text-classification task_id: text_classification splits: train_split: train eval_split: test metrics: - type: accuracy - type: precision - type: recall - type: f1---
> [!NOTE] > This repository integrates the AltLex corpus into hf datasets. It is in conformance with AltLex's MIT license. Please find the original dataset> [here](https://github.com/chridey/altlex). We used the [UniCausal](https://github.com/tanfiona/UniCausal/tree/main/data/grouped/splits) reformatting of the data as the basis> for this repository. Please see the [citations](#citations) at the end of this README.
## Dataset Description
- **Repository:** https://github.com/chridey/altlex- **Paper:** [Identifying Causal Relations Using Parallel Wikipedia Articles](https://doi.org/10.18653/v1/P16-1135)
# Usage## Causality Detection```pyfrom datasets import load_datasetdataset = load_dataset("thagen/AltLex", "causality detection")```
## Causal Candidate Extraction```pyfrom datasets import load_datasetdataset = load_dataset("thagen/AltLex", "causal candidate extraction")```
## Causality Identification```pyfrom datasets import load_datasetdataset = load_dataset("thagen/AltLex", "causality identification")```
# Citations
The AltLex paper by [Hidey and McKeown, 2016](https://doi.org/10.18653/v1/P16-1135):```bib@inproceedings{hidey:2016, title = {Identifying Causal Relations Using Parallel {Wikipedia} Articles}, booktitle = {Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)}, author = {Hidey, Christopher and McKeown, Kathleen}, year = {2016}, pages = {1424--1433}, publisher = {Association for Computational Linguistics}, doi = {10.18653/v1/P16-1135}}```
UniCausal by [Tan et al., 2023](https://link.springer.com/chapter/10.1007/978-3-031-39831-5_23) — who's dataformat we used to make AltLex compatible with hf datasets:```bib@inproceedings{tan:2023, title = {{{UniCausal}}: {{Unified Benchmark}} and {{Repository}} for {{Causal Text Mining}}}, shorttitle = {{{UniCausal}}}, booktitle = {Big {{Data Analytics}} and {{Knowledge Discovery}} - 25th {{International Conference}}, {{DaWaK}} 2023, {{Penang}}, {{Malaysia}}, {{August}} 28-30, 2023, {{Proceedings}}}, author = {Tan, Fiona Anting and Zuo, Xinyu and Ng, See-Kiong}, editor = {Wrembel, Robert and Gamper, Johann and Kotsis, Gabriele and Tjoa, A. Min and Khalil, Ismail}, year = {2023}, series = {Lecture {{Notes}} in {{Computer Science}}}, volume = {14148}, pages = {248--262}, publisher = {Springer}, doi = {10.1007/978-3-031-39831-5_23}}```1234567891011121314151617181920212223242526#!/usr/bin/env python3
"""Run this script as ./conversion_script.py to convert the UniCausal AltLex files to HF-compatible parquet files."""
# 1) Install dependencies:# pip install git+https://github.com/TheMrSheldon/causality-toolkit.git# 2) Download these files:# - https://raw.githubusercontent.com/tanfiona/UniCausal/refs/heads/main/data/grouped/splits/altlex_test.csv# - https://raw.githubusercontent.com/tanfiona/UniCausal/refs/heads/main/data/grouped/splits/altlex_train.csv
from pathlib import Path
from ctk.data.constants import Taskfrom ctk.data.conversion import UniCausal2HF
converter = UniCausal2HF({"train": Path.cwd() / "altlex_train.csv", "test": Path.cwd() / "altlex_test.csv"}, Path.cwd())
converter.convert(Task.CausalityDetection, "train")converter.convert(Task.CausalityDetection, "test")converter.convert(Task.CausalCandidateExtraction, "train")converter.convert(Task.CausalCandidateExtraction, "test")converter.convert(Task.CausalityIdentification, "train")converter.convert(Task.CausalityIdentification, "test").gitattributesAdded+59
README.mdAdded+168
conversion_script.pyAdded+26