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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-nc-sa-4.0
|
| 3 |
+
task_categories:
|
| 4 |
+
- text-classification
|
| 5 |
+
- token-classification
|
| 6 |
+
language:
|
| 7 |
+
- en
|
| 8 |
+
multilinguality:
|
| 9 |
+
- monolingual
|
| 10 |
+
size_categories:
|
| 11 |
+
- n<1K
|
| 12 |
+
tags:
|
| 13 |
+
- causality
|
| 14 |
+
pretty_name: BioCause
|
| 15 |
+
configs:
|
| 16 |
+
- config_name: causality detection
|
| 17 |
+
data_files:
|
| 18 |
+
- split: train
|
| 19 |
+
path: causality-detection/train.parquet
|
| 20 |
+
- split: validation
|
| 21 |
+
path: causality-detection/dev.parquet
|
| 22 |
+
- split: test
|
| 23 |
+
path: causality-detection/test.parquet
|
| 24 |
+
features:
|
| 25 |
+
- name: index
|
| 26 |
+
dtype: string
|
| 27 |
+
- name: text
|
| 28 |
+
dtype: string
|
| 29 |
+
- name: label
|
| 30 |
+
dtype:
|
| 31 |
+
class_label:
|
| 32 |
+
names:
|
| 33 |
+
'0': uncausal
|
| 34 |
+
'1': causal
|
| 35 |
+
- config_name: causal candidate extraction
|
| 36 |
+
data_files:
|
| 37 |
+
- split: train
|
| 38 |
+
path: causal-candidate-extraction/train.parquet
|
| 39 |
+
- split: validation
|
| 40 |
+
path: causal-candidate-extraction/dev.parquet
|
| 41 |
+
- split: test
|
| 42 |
+
path: causal-candidate-extraction/test.parquet
|
| 43 |
+
features:
|
| 44 |
+
- name: index
|
| 45 |
+
dtype: string
|
| 46 |
+
- name: text
|
| 47 |
+
dtype: string
|
| 48 |
+
- name: entity
|
| 49 |
+
sequence:
|
| 50 |
+
sequence: int32
|
| 51 |
+
- config_name: causality identification
|
| 52 |
+
data_files:
|
| 53 |
+
- split: train
|
| 54 |
+
path: causality-identification/train.parquet
|
| 55 |
+
- split: validation
|
| 56 |
+
path: causality-identification/dev.parquet
|
| 57 |
+
- split: test
|
| 58 |
+
path: causality-identification/test.parquet
|
| 59 |
+
features:
|
| 60 |
+
- name: index
|
| 61 |
+
dtype: string
|
| 62 |
+
- name: text
|
| 63 |
+
dtype: string
|
| 64 |
+
- name: relations
|
| 65 |
+
list:
|
| 66 |
+
- name: relationship
|
| 67 |
+
dtype:
|
| 68 |
+
class_label:
|
| 69 |
+
names:
|
| 70 |
+
'0': no-rel
|
| 71 |
+
'1': causal
|
| 72 |
+
- name: first
|
| 73 |
+
dtype: string
|
| 74 |
+
- name: second
|
| 75 |
+
dtype: string
|
| 76 |
+
train-eval-index:
|
| 77 |
+
- config: causality detection
|
| 78 |
+
task: text-classification
|
| 79 |
+
task_id: text_classification
|
| 80 |
+
splits:
|
| 81 |
+
train_split: train
|
| 82 |
+
eval_split: test
|
| 83 |
+
col_mapping:
|
| 84 |
+
text: text
|
| 85 |
+
label: label
|
| 86 |
+
metrics:
|
| 87 |
+
- type: accuracy
|
| 88 |
+
- type: precision
|
| 89 |
+
- type: recall
|
| 90 |
+
- type: f1
|
| 91 |
+
- config: causal candidate extraction
|
| 92 |
+
task: token-classification
|
| 93 |
+
task_id: token_classification
|
| 94 |
+
splits:
|
| 95 |
+
train_split: train
|
| 96 |
+
eval_split: test
|
| 97 |
+
metrics:
|
| 98 |
+
- type: accuracy
|
| 99 |
+
- type: precision
|
| 100 |
+
- type: recall
|
| 101 |
+
- type: f1
|
| 102 |
+
- config: causality identification
|
| 103 |
+
task: text-classification
|
| 104 |
+
task_id: text_classification
|
| 105 |
+
splits:
|
| 106 |
+
train_split: train
|
| 107 |
+
eval_split: test
|
| 108 |
+
metrics:
|
| 109 |
+
- type: accuracy
|
| 110 |
+
- type: precision
|
| 111 |
+
- type: recall
|
| 112 |
+
- type: f1
|
| 113 |
+
---
|
| 114 |
+
|
| 115 |
+
> [!NOTE]
|
| 116 |
+
> This repository integrates the BioCause corpus into hf datasets. Please find the original dataset
|
| 117 |
+
> [here](https://github.com/Luisiglm/BioCause). The data is sourced from the
|
| 118 |
+
> [CREST](https://github.com/phosseini/CREST) aggregation. Please see the [citations](#citations) at the end of this README.
|
| 119 |
+
|
| 120 |
+
## Dataset Description
|
| 121 |
+
|
| 122 |
+
- **Homepage:** https://github.com/Luisiglm/BioCause
|
| 123 |
+
- **Paper:** [BioCause: Annotating and Analysing Causality in the Biomedical Domain](https://doi.org/10.1186/1471-2105-14-2)
|
| 124 |
+
|
| 125 |
+
# Usage
|
| 126 |
+
## Causality Detection
|
| 127 |
+
```py
|
| 128 |
+
from datasets import load_dataset
|
| 129 |
+
dataset = load_dataset("thagen/BioCause", "causality detection")
|
| 130 |
+
```
|
| 131 |
+
|
| 132 |
+
## Causal Candidate Extraction
|
| 133 |
+
```py
|
| 134 |
+
from datasets import load_dataset
|
| 135 |
+
dataset = load_dataset("thagen/BioCause", "causal candidate extraction")
|
| 136 |
+
```
|
| 137 |
+
|
| 138 |
+
## Causality Identification
|
| 139 |
+
```py
|
| 140 |
+
from datasets import load_dataset
|
| 141 |
+
dataset = load_dataset("thagen/BioCause", "causality identification")
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
# Citations
|
| 145 |
+
|
| 146 |
+
The BioCause paper by [Mihaila et al., 2013](https://doi.org/10.1186/1471-2105-14-2):
|
| 147 |
+
```bib
|
| 148 |
+
@article{mihaila:2013,
|
| 149 |
+
title = {{{BioCause}}: {{Annotating}} and Analysing Causality in the Biomedical Domain},
|
| 150 |
+
shorttitle = {{{BioCause}}},
|
| 151 |
+
author = {Mihaila, Claudiu and Ohta, Tomoko and Pyysalo, Sampo and Ananiadou, Sophia},
|
| 152 |
+
year = {2013},
|
| 153 |
+
journal = {BMC Bioinform.},
|
| 154 |
+
volume = {14},
|
| 155 |
+
pages = {2},
|
| 156 |
+
doi = {10.1186/1471-2105-14-2}
|
| 157 |
+
}
|
| 158 |
+
```
|
| 159 |
+
|
| 160 |
+
CREST by [Hosseini et al., 2021](https://arxiv.org/abs/2103.13606) — whose aggregation we used to source the BioCause data:
|
| 161 |
+
```bib
|
| 162 |
+
@article{hosseini:2021,
|
| 163 |
+
title = {Predicting {{Directionality}} in {{Causal Relations}} in {{Text}}},
|
| 164 |
+
author = {Hosseini, Pedram and Broniatowski, David A. and Diab, Mona T.},
|
| 165 |
+
year = {2021},
|
| 166 |
+
journal = {CoRR},
|
| 167 |
+
volume = {abs/2103.13606},
|
| 168 |
+
eprint = {2103.13606},
|
| 169 |
+
archiveprefix = {arXiv}
|
| 170 |
+
}
|
| 171 |
+
```
|
conversion_script.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
|
| 3 |
+
"""
|
| 4 |
+
Run this script as ./conversion_script.py to convert the BioCause entries from
|
| 5 |
+
the CREST v2 aggregation file to HF-compatible parquet files.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
# 1) Install dependencies:
|
| 9 |
+
# pip install git+https://github.com/TheMrSheldon/causality-toolkit.git
|
| 10 |
+
# 2) Source file (fetched automatically via pandas):
|
| 11 |
+
# - https://raw.githubusercontent.com/phosseini/CREST/master/data/crest_v2.xlsx
|
| 12 |
+
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
|
| 15 |
+
from ctk.data.constants import Task
|
| 16 |
+
from ctk.data.conversion import CREST2HF, CRESTSource
|
| 17 |
+
|
| 18 |
+
converter = CREST2HF(
|
| 19 |
+
"https://raw.githubusercontent.com/phosseini/CREST/master/data/crest_v2.xlsx",
|
| 20 |
+
Path.cwd(),
|
| 21 |
+
prefix="biocause",
|
| 22 |
+
filters={"source": CRESTSource.BioCause},
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
for split in ["train", "dev", "test"]:
|
| 26 |
+
converter.convert(Task.CausalityDetection, split)
|
| 27 |
+
converter.convert(Task.CausalCandidateExtraction, split)
|
| 28 |
+
converter.convert(Task.CausalityIdentification, split)
|