Stardrums commited on
Commit
5753b4a
·
1 Parent(s): 411e4c8

First version of the pico-breast-cancer dataset.

Browse files
Files changed (1) hide show
  1. pico-breast-cancer.py +110 -0
pico-breast-cancer.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+
3
+
4
+ _CITATION = """\
5
+ @InProceedings{mutinda2022pico,
6
+ title = {PICO Corpus: A Publicly Available Corpus to Support Automatic Data Extraction from Biomedical Literature},
7
+ author = {Mutinda, Faith and Liew, Kongmeng and Yada, Shuntaro and Wakamiya, Shoko and Aramaki, Eiji},
8
+ booktitle = {Proceedings of the first Workshop on Information Extraction from Scientific Publications},
9
+ pages = {26--31},
10
+ year = {2022}
11
+ }
12
+ """
13
+
14
+ _DESCRIPTION = """\
15
+ The corpus consists of about 1,011 PubMed abstracts which are RCTs related
16
+ to breast cancer. For each abstract, text snippets that identify the
17
+ Participants, Intervention, Control, and Outcome (PICO elements) are annotated.
18
+ The abstracts were annotated using BRAT (https://brat.nlplab.org/) and later
19
+ converted to CoNLL-2003.
20
+ """
21
+
22
+ _HOMEPAGE = "https://github.com/Martin-Masson/pico-corpus"
23
+
24
+ _URL = "https://raw.githubusercontent.com/Martin-Masson/pico-breast-cancer/main/pico_conll.txt"
25
+
26
+ _TAGS = [
27
+ "O",
28
+ "total-participants",
29
+ "intervention-participants",
30
+ "control-participants",
31
+ "age",
32
+ "eligibility",
33
+ "ethinicity",
34
+ "condition",
35
+ "location",
36
+ "intervention",
37
+ "control",
38
+ "outcome",
39
+ "outcome-Measure",
40
+ "iv-bin-abs",
41
+ "cv-bin-abs",
42
+ "iv-bin-percent",
43
+ "cv-bin-percent",
44
+ "iv-cont-mean",
45
+ "cv-cont-mean",
46
+ "iv-cont-median",
47
+ "cv-cont-median",
48
+ "iv-cont-sd",
49
+ "cv-cont-sd",
50
+ "iv-cont-q1",
51
+ "cv-cont-q1",
52
+ "iv-cont-q3",
53
+ "cv-cont-q3",
54
+ ]
55
+
56
+
57
+ class PicoBreastCancer(datasets.GeneratorBasedBuilder):
58
+ """A corpus of about 1,011 PubMed abstracts from RCTs related to breast cancer."""
59
+
60
+ VERSION = datasets.Version("1.0.0")
61
+
62
+ def _info(self):
63
+ return datasets.DatasetInfo(
64
+ description=_DESCRIPTION,
65
+ features=datasets.Features(
66
+ {
67
+ "id": datasets.Value("string"),
68
+ "tokens": datasets.Sequence(datasets.Value("string")),
69
+ "ner_tags": datasets.Sequence(datasets.ClassLabel(names=_TAGS)),
70
+ }
71
+ ),
72
+ supervised_keys=None,
73
+ homepage=_HOMEPAGE,
74
+ citation=_CITATION,
75
+ )
76
+
77
+ def _split_generators(self, dl_manager):
78
+ data_file = dl_manager.download_and_extract(_URL)
79
+
80
+ return [
81
+ datasets.SplitGenerator(
82
+ name=datasets.Split.ALL,
83
+ gen_kwargs={
84
+ "filepath": data_file,
85
+ },
86
+ )
87
+ ]
88
+
89
+ def _generate_examples(self, filepath):
90
+ idx = 0
91
+ tokens = []
92
+ ner_tags = []
93
+ labels = {tag: i for i, tag in enumerate(_TAGS)}
94
+
95
+ with open(filepath) as f:
96
+ lines = f.read().splitlines()
97
+ for line in lines:
98
+ if not line:
99
+ yield id, {
100
+ "id": str(idx),
101
+ "tokens": tokens,
102
+ "ner_tags": ner_tags
103
+ }
104
+ idx += 1
105
+ tokens.clear()
106
+ ner_tags.clear()
107
+ else:
108
+ token_tag = line.split()
109
+ tokens.append(token_tag[0])
110
+ ner_tags.append(labels[token_tag[1]])