Update pico-breast-cancer.py
Browse files- pico-breast-cancer.py +78 -70
pico-breast-cancer.py
CHANGED
@@ -2,6 +2,9 @@ import os
|
|
2 |
import datasets
|
3 |
|
4 |
|
|
|
|
|
|
|
5 |
_CITATION = """\
|
6 |
@InProceedings{mutinda2022pico,
|
7 |
title = {PICO Corpus: A Publicly Available Corpus to Support Automatic Data Extraction from Biomedical Literature},
|
@@ -22,63 +25,10 @@ converted to CoNLL-2003.
|
|
22 |
|
23 |
_HOMEPAGE = "https://github.com/Martin-Masson/pico-corpus"
|
24 |
|
25 |
-
_URL = "https://
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
"B-total-participants",
|
30 |
-
"I-total-participants",
|
31 |
-
"B-intervention-participants",
|
32 |
-
"I-intervention-participants",
|
33 |
-
"B-control-participants",
|
34 |
-
"I-control-participants",
|
35 |
-
"B-age",
|
36 |
-
"I-age",
|
37 |
-
"B-eligibility",
|
38 |
-
"I-eligibility",
|
39 |
-
"B-ethinicity",
|
40 |
-
"I-ethinicity",
|
41 |
-
"B-condition",
|
42 |
-
"I-condition",
|
43 |
-
"B-location",
|
44 |
-
"I-location",
|
45 |
-
"B-intervention",
|
46 |
-
"I-intervention",
|
47 |
-
"B-control",
|
48 |
-
"I-control",
|
49 |
-
"B-outcome",
|
50 |
-
"I-outcome",
|
51 |
-
"B-outcome-measure",
|
52 |
-
"I-outcome-measure",
|
53 |
-
"B-iv-bin-abs",
|
54 |
-
"I-iv-bin-abs",
|
55 |
-
"B-cv-bin-abs",
|
56 |
-
"I-cv-bin-abs",
|
57 |
-
"B-iv-bin-percent",
|
58 |
-
"I-iv-bin-percent",
|
59 |
-
"B-cv-bin-percent",
|
60 |
-
"I-cv-bin-percent",
|
61 |
-
"B-iv-cont-mean",
|
62 |
-
"I-iv-cont-mean",
|
63 |
-
"B-cv-cont-mean",
|
64 |
-
"I-cv-cont-mean",
|
65 |
-
"B-iv-cont-median",
|
66 |
-
"I-iv-cont-median",
|
67 |
-
"B-cv-cont-median",
|
68 |
-
"I-cv-cont-median",
|
69 |
-
"B-iv-cont-sd",
|
70 |
-
"I-iv-cont-sd",
|
71 |
-
"B-cv-cont-sd",
|
72 |
-
"I-cv-cont-sd",
|
73 |
-
"B-iv-cont-q1",
|
74 |
-
"I-iv-cont-q1",
|
75 |
-
"B-cv-cont-q1",
|
76 |
-
"I-cv-cont-q1",
|
77 |
-
"B-iv-cont-q3",
|
78 |
-
"I-iv-cont-q3",
|
79 |
-
"B-cv-cont-q3",
|
80 |
-
"I-cv-cont-q3",
|
81 |
-
]
|
82 |
|
83 |
|
84 |
class PicoBreastCancer(datasets.GeneratorBasedBuilder):
|
@@ -93,7 +43,65 @@ class PicoBreastCancer(datasets.GeneratorBasedBuilder):
|
|
93 |
{
|
94 |
"id": datasets.Value("string"),
|
95 |
"tokens": datasets.Sequence(datasets.Value("string")),
|
96 |
-
"ner_tags": datasets.Sequence(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
}
|
98 |
),
|
99 |
supervised_keys=None,
|
@@ -102,25 +110,25 @@ class PicoBreastCancer(datasets.GeneratorBasedBuilder):
|
|
102 |
)
|
103 |
|
104 |
def _split_generators(self, dl_manager):
|
105 |
-
|
106 |
-
|
107 |
-
"
|
108 |
-
"
|
109 |
-
"test": os.path.join(data_dir, "test.txt"),
|
110 |
}
|
|
|
111 |
|
112 |
return [
|
113 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath":
|
114 |
-
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath":
|
115 |
-
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath":
|
116 |
]
|
117 |
|
118 |
def _generate_examples(self, filepath):
|
119 |
-
|
120 |
-
tokens = []
|
121 |
-
ner_tags = []
|
122 |
-
|
123 |
with open(filepath, encoding="utf-8") as f:
|
|
|
|
|
|
|
124 |
for line in f:
|
125 |
if line.startswith("-DOCSTART-") or line == "" or line == "\n":
|
126 |
if tokens:
|
|
|
2 |
import datasets
|
3 |
|
4 |
|
5 |
+
logger = datasets.logging.get_logger(__name__)
|
6 |
+
|
7 |
+
|
8 |
_CITATION = """\
|
9 |
@InProceedings{mutinda2022pico,
|
10 |
title = {PICO Corpus: A Publicly Available Corpus to Support Automatic Data Extraction from Biomedical Literature},
|
|
|
25 |
|
26 |
_HOMEPAGE = "https://github.com/Martin-Masson/pico-corpus"
|
27 |
|
28 |
+
_URL = "https://raw.githubusercontent.com/Martin-Masson/pico-breast-cancer/main/pico_conll/"
|
29 |
+
_TRAINING_FILE = "train.txt"
|
30 |
+
_DEV_FILE = "dev.txt"
|
31 |
+
_TEST_FILE = "test.txt"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
|
34 |
class PicoBreastCancer(datasets.GeneratorBasedBuilder):
|
|
|
43 |
{
|
44 |
"id": datasets.Value("string"),
|
45 |
"tokens": datasets.Sequence(datasets.Value("string")),
|
46 |
+
"ner_tags": datasets.Sequence(
|
47 |
+
datasets.features.ClassLabel(
|
48 |
+
names= [
|
49 |
+
"O",
|
50 |
+
"B-total-participants",
|
51 |
+
"I-total-participants",
|
52 |
+
"B-intervention-participants",
|
53 |
+
"I-intervention-participants",
|
54 |
+
"B-control-participants",
|
55 |
+
"I-control-participants",
|
56 |
+
"B-age",
|
57 |
+
"I-age",
|
58 |
+
"B-eligibility",
|
59 |
+
"I-eligibility",
|
60 |
+
"B-ethinicity",
|
61 |
+
"I-ethinicity",
|
62 |
+
"B-condition",
|
63 |
+
"I-condition",
|
64 |
+
"B-location",
|
65 |
+
"I-location",
|
66 |
+
"B-intervention",
|
67 |
+
"I-intervention",
|
68 |
+
"B-control",
|
69 |
+
"I-control",
|
70 |
+
"B-outcome",
|
71 |
+
"I-outcome",
|
72 |
+
"B-outcome-measure",
|
73 |
+
"I-outcome-measure",
|
74 |
+
"B-iv-bin-abs",
|
75 |
+
"I-iv-bin-abs",
|
76 |
+
"B-cv-bin-abs",
|
77 |
+
"I-cv-bin-abs",
|
78 |
+
"B-iv-bin-percent",
|
79 |
+
"I-iv-bin-percent",
|
80 |
+
"B-cv-bin-percent",
|
81 |
+
"I-cv-bin-percent",
|
82 |
+
"B-iv-cont-mean",
|
83 |
+
"I-iv-cont-mean",
|
84 |
+
"B-cv-cont-mean",
|
85 |
+
"I-cv-cont-mean",
|
86 |
+
"B-iv-cont-median",
|
87 |
+
"I-iv-cont-median",
|
88 |
+
"B-cv-cont-median",
|
89 |
+
"I-cv-cont-median",
|
90 |
+
"B-iv-cont-sd",
|
91 |
+
"I-iv-cont-sd",
|
92 |
+
"B-cv-cont-sd",
|
93 |
+
"I-cv-cont-sd",
|
94 |
+
"B-iv-cont-q1",
|
95 |
+
"I-iv-cont-q1",
|
96 |
+
"B-cv-cont-q1",
|
97 |
+
"I-cv-cont-q1",
|
98 |
+
"B-iv-cont-q3",
|
99 |
+
"I-iv-cont-q3",
|
100 |
+
"B-cv-cont-q3",
|
101 |
+
"I-cv-cont-q3",
|
102 |
+
]
|
103 |
+
)
|
104 |
+
),
|
105 |
}
|
106 |
),
|
107 |
supervised_keys=None,
|
|
|
110 |
)
|
111 |
|
112 |
def _split_generators(self, dl_manager):
|
113 |
+
urls_to_download = {
|
114 |
+
"train": f"{_URL}{_TRAINING_FILE}",
|
115 |
+
"dev": f"{_URL}{_DEV_FILE}",
|
116 |
+
"test": f"{_URL}{_TEST_FILE}",
|
|
|
117 |
}
|
118 |
+
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
119 |
|
120 |
return [
|
121 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
122 |
+
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
|
123 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
|
124 |
]
|
125 |
|
126 |
def _generate_examples(self, filepath):
|
127 |
+
logger.info("⏳ Generating examples from = %s", filepath)
|
|
|
|
|
|
|
128 |
with open(filepath, encoding="utf-8") as f:
|
129 |
+
idx = 0
|
130 |
+
tokens = []
|
131 |
+
ner_tags = []
|
132 |
for line in f:
|
133 |
if line.startswith("-DOCSTART-") or line == "" or line == "\n":
|
134 |
if tokens:
|