Tim Hagen commited on
Commit
115d1ae
·
0 Parent(s):

Initial commit

Browse files
Files changed (3) hide show
  1. .gitattributes +59 -0
  2. README.md +135 -0
  3. conversion_script.py +24 -0
.gitattributes ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.lz4 filter=lfs diff=lfs merge=lfs -text
12
+ *.mds filter=lfs diff=lfs merge=lfs -text
13
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
14
+ *.model filter=lfs diff=lfs merge=lfs -text
15
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
16
+ *.npy filter=lfs diff=lfs merge=lfs -text
17
+ *.npz filter=lfs diff=lfs merge=lfs -text
18
+ *.onnx filter=lfs diff=lfs merge=lfs -text
19
+ *.ot filter=lfs diff=lfs merge=lfs -text
20
+ *.parquet filter=lfs diff=lfs merge=lfs -text
21
+ *.pb filter=lfs diff=lfs merge=lfs -text
22
+ *.pickle filter=lfs diff=lfs merge=lfs -text
23
+ *.pkl filter=lfs diff=lfs merge=lfs -text
24
+ *.pt filter=lfs diff=lfs merge=lfs -text
25
+ *.pth filter=lfs diff=lfs merge=lfs -text
26
+ *.rar filter=lfs diff=lfs merge=lfs -text
27
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
28
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
29
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
30
+ *.tar filter=lfs diff=lfs merge=lfs -text
31
+ *.tflite filter=lfs diff=lfs merge=lfs -text
32
+ *.tgz filter=lfs diff=lfs merge=lfs -text
33
+ *.wasm filter=lfs diff=lfs merge=lfs -text
34
+ *.xz filter=lfs diff=lfs merge=lfs -text
35
+ *.zip filter=lfs diff=lfs merge=lfs -text
36
+ *.zst filter=lfs diff=lfs merge=lfs -text
37
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
38
+ # Audio files - uncompressed
39
+ *.pcm filter=lfs diff=lfs merge=lfs -text
40
+ *.sam filter=lfs diff=lfs merge=lfs -text
41
+ *.raw filter=lfs diff=lfs merge=lfs -text
42
+ # Audio files - compressed
43
+ *.aac filter=lfs diff=lfs merge=lfs -text
44
+ *.flac filter=lfs diff=lfs merge=lfs -text
45
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
46
+ *.ogg filter=lfs diff=lfs merge=lfs -text
47
+ *.wav filter=lfs diff=lfs merge=lfs -text
48
+ # Image files - uncompressed
49
+ *.bmp filter=lfs diff=lfs merge=lfs -text
50
+ *.gif filter=lfs diff=lfs merge=lfs -text
51
+ *.png filter=lfs diff=lfs merge=lfs -text
52
+ *.tiff filter=lfs diff=lfs merge=lfs -text
53
+ # Image files - compressed
54
+ *.jpg filter=lfs diff=lfs merge=lfs -text
55
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
56
+ *.webp filter=lfs diff=lfs merge=lfs -text
57
+ # Video files - compressed
58
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
59
+ *.webm filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ task_categories:
4
+ - text-classification
5
+ language:
6
+ - en
7
+ multilinguality:
8
+ - monolingual
9
+ size_categories:
10
+ - 1K<n<10K
11
+ tags:
12
+ - causality
13
+ pretty_name: CausalTimeBank (CTB)
14
+ configs:
15
+ - config_name: causality detection
16
+ data_files:
17
+ - split: train
18
+ path: causality-detection/train.parquet
19
+ - split: test
20
+ path: causality-detection/test.parquet
21
+ features:
22
+ - name: index
23
+ dtype: string
24
+ - name: text
25
+ dtype: string
26
+ - name: label
27
+ dtype:
28
+ class_label:
29
+ names:
30
+ '0': uncausal
31
+ '1': causal
32
+ - config_name: causality identification
33
+ data_files:
34
+ - split: train
35
+ path: causality-identification/train.parquet
36
+ - split: test
37
+ path: causality-identification/test.parquet
38
+ features:
39
+ - name: index
40
+ dtype: string
41
+ - name: text
42
+ dtype: string
43
+ - name: relations
44
+ list:
45
+ - name: relationship
46
+ dtype:
47
+ class_label:
48
+ names:
49
+ '0': no-rel
50
+ '1': causal
51
+ - name: first
52
+ dtype: string
53
+ - name: second
54
+ dtype: string
55
+ train-eval-index:
56
+ - config: causality detection
57
+ task: text-classification
58
+ task_id: text_classification
59
+ splits:
60
+ train_split: train
61
+ eval_split: test
62
+ col_mapping:
63
+ text: text
64
+ label: label
65
+ metrics:
66
+ - type: accuracy
67
+ - type: precision
68
+ - type: recall
69
+ - type: f1
70
+ - config: causality identification
71
+ task: text-classification
72
+ task_id: text_classification
73
+ splits:
74
+ train_split: train
75
+ eval_split: test
76
+ metrics:
77
+ - type: accuracy
78
+ - type: precision
79
+ - type: recall
80
+ - type: f1
81
+ ---
82
+
83
+ > [!NOTE]
84
+ > This repository integrates the CausalTimeBank (CTB) corpus into hf datasets. Please find the original dataset
85
+ > [here](http://hlt-nlp.fbk.eu/technologies/causal-timebank). We used the [UniCausal](https://github.com/tanfiona/UniCausal/tree/main/data/splits) reformatting of the data as the basis
86
+ > for this repository. Please see the [citations](#citations) at the end of this README.
87
+
88
+ ## Dataset Description
89
+
90
+ - **Homepage:** http://hlt-nlp.fbk.eu/technologies/causal-timebank
91
+ - **Paper:** [An Analysis of Causality between Events and its Relation to Temporal Information](https://aclanthology.org/C14-1196)
92
+
93
+ # Usage
94
+ ## Causality Detection
95
+ ```py
96
+ from datasets import load_dataset
97
+ dataset = load_dataset("thagen/CTB", "causality detection")
98
+ ```
99
+
100
+ ## Causality Identification
101
+ ```py
102
+ from datasets import load_dataset
103
+ dataset = load_dataset("thagen/CTB", "causality identification")
104
+ ```
105
+
106
+ # Citations
107
+
108
+ The CausalTimeBank paper by [Mirza and Tonelli, 2014](https://aclanthology.org/C14-1196):
109
+ ```bib
110
+ @inproceedings{mirza:2014,
111
+ title = {An Analysis of Causality between Events and its Relation to Temporal Information},
112
+ booktitle = {Proceedings of {COLING} 2014, the 25th International Conference on Computational Linguistics: Technical Papers},
113
+ author = {Mirza, Paramita and Tonelli, Sara},
114
+ year = {2014},
115
+ pages = {2097--2106},
116
+ publisher = {Dublin City University and Association for Computational Linguistics}
117
+ }
118
+ ```
119
+
120
+ UniCausal by [Tan et al., 2023](https://link.springer.com/chapter/10.1007/978-3-031-39831-5_23) &mdash; who's dataformat we used to make CTB compatible with hf datasets:
121
+ ```bib
122
+ @inproceedings{tan:2023,
123
+ title = {{{UniCausal}}: {{Unified Benchmark}} and {{Repository}} for {{Causal Text Mining}}},
124
+ shorttitle = {{{UniCausal}}},
125
+ booktitle = {Big {{Data Analytics}} and {{Knowledge Discovery}} - 25th {{International Conference}}, {{DaWaK}} 2023, {{Penang}}, {{Malaysia}}, {{August}} 28-30, 2023, {{Proceedings}}},
126
+ author = {Tan, Fiona Anting and Zuo, Xinyu and Ng, See-Kiong},
127
+ editor = {Wrembel, Robert and Gamper, Johann and Kotsis, Gabriele and Tjoa, A. Min and Khalil, Ismail},
128
+ year = {2023},
129
+ series = {Lecture {{Notes}} in {{Computer Science}}},
130
+ volume = {14148},
131
+ pages = {248--262},
132
+ publisher = {Springer},
133
+ doi = {10.1007/978-3-031-39831-5_23}
134
+ }
135
+ ```
conversion_script.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+
3
+ """
4
+ Run this script as ./conversion_script.py to convert the UniCausal CTB files to HF-compatible parquet files.
5
+ """
6
+
7
+ # 1) Install dependencies:
8
+ # pip install git+https://github.com/TheMrSheldon/causality-toolkit.git
9
+ # 2) Download these files:
10
+ # - https://raw.githubusercontent.com/tanfiona/UniCausal/refs/heads/main/data/splits/ctb_test.csv
11
+ # - https://raw.githubusercontent.com/tanfiona/UniCausal/refs/heads/main/data/splits/ctb_train.csv
12
+
13
+ from pathlib import Path
14
+
15
+ from ctk.data.constants import Task
16
+ from ctk.data.conversion import UniCausal2HF
17
+
18
+ converter = UniCausal2HF({"train": Path.cwd() / "ctb_train.csv",
19
+ "test": Path.cwd() / "ctb_test.csv"}, Path.cwd())
20
+
21
+ converter.convert(Task.CausalityDetection, "train")
22
+ converter.convert(Task.CausalityDetection, "test")
23
+ converter.convert(Task.CausalityIdentification, "train")
24
+ converter.convert(Task.CausalityIdentification, "test")