Remove extra print (and extra tabs)
Browse files- PxCorpus.py +9 -10
PxCorpus.py
CHANGED
@@ -36,16 +36,17 @@ of 55 participants (38% non-experts, 25% doctors, 36% medical practitioners), ma
|
|
36 |
|
37 |
_URL = "https://zenodo.org/record/6524162/files/pxslu.zip?download=1"
|
38 |
|
|
|
39 |
class PxCorpus(datasets.GeneratorBasedBuilder):
|
40 |
|
41 |
BUILDER_CONFIGS = [
|
42 |
datasets.BuilderConfig(name=f"default", version="1.0.0", description=f"PxCorpus data"),
|
43 |
]
|
44 |
-
|
45 |
DEFAULT_CONFIG_NAME = "default"
|
46 |
|
47 |
def _info(self):
|
48 |
-
|
49 |
features = datasets.Features(
|
50 |
{
|
51 |
"id": datasets.Value("string"),
|
@@ -61,7 +62,7 @@ class PxCorpus(datasets.GeneratorBasedBuilder):
|
|
61 |
),
|
62 |
}
|
63 |
)
|
64 |
-
|
65 |
return datasets.DatasetInfo(
|
66 |
description=_DESCRIPTION,
|
67 |
features=features,
|
@@ -73,8 +74,6 @@ class PxCorpus(datasets.GeneratorBasedBuilder):
|
|
73 |
|
74 |
data_dir = dl_manager.download_and_extract(_URL)
|
75 |
|
76 |
-
print(data_dir)
|
77 |
-
|
78 |
return [
|
79 |
datasets.SplitGenerator(
|
80 |
name=datasets.Split.TRAIN,
|
@@ -125,7 +124,7 @@ class PxCorpus(datasets.GeneratorBasedBuilder):
|
|
125 |
|
126 |
key = 0
|
127 |
all_res = []
|
128 |
-
|
129 |
f_seq_in = open(filepath_1, "r")
|
130 |
seq_in = f_seq_in.read().split("\n")
|
131 |
f_seq_in.close()
|
@@ -155,7 +154,7 @@ class PxCorpus(datasets.GeneratorBasedBuilder):
|
|
155 |
"tokens": tokens,
|
156 |
"ner_tags": ner_tags,
|
157 |
})
|
158 |
-
|
159 |
key += 1
|
160 |
|
161 |
ids = [r["id"] for r in all_res]
|
@@ -164,8 +163,8 @@ class PxCorpus(datasets.GeneratorBasedBuilder):
|
|
164 |
random.shuffle(ids)
|
165 |
random.shuffle(ids)
|
166 |
random.shuffle(ids)
|
167 |
-
|
168 |
-
train, validation, test = np.split(ids, [int(len(ids)*
|
169 |
|
170 |
if split == "train":
|
171 |
allowed_ids = list(train)
|
@@ -173,7 +172,7 @@ class PxCorpus(datasets.GeneratorBasedBuilder):
|
|
173 |
allowed_ids = list(validation)
|
174 |
elif split == "test":
|
175 |
allowed_ids = list(test)
|
176 |
-
|
177 |
for r in all_res:
|
178 |
if r["id"] in allowed_ids:
|
179 |
yield r["id"], r
|
|
|
36 |
|
37 |
_URL = "https://zenodo.org/record/6524162/files/pxslu.zip?download=1"
|
38 |
|
39 |
+
|
40 |
class PxCorpus(datasets.GeneratorBasedBuilder):
|
41 |
|
42 |
BUILDER_CONFIGS = [
|
43 |
datasets.BuilderConfig(name=f"default", version="1.0.0", description=f"PxCorpus data"),
|
44 |
]
|
45 |
+
|
46 |
DEFAULT_CONFIG_NAME = "default"
|
47 |
|
48 |
def _info(self):
|
49 |
+
|
50 |
features = datasets.Features(
|
51 |
{
|
52 |
"id": datasets.Value("string"),
|
|
|
62 |
),
|
63 |
}
|
64 |
)
|
65 |
+
|
66 |
return datasets.DatasetInfo(
|
67 |
description=_DESCRIPTION,
|
68 |
features=features,
|
|
|
74 |
|
75 |
data_dir = dl_manager.download_and_extract(_URL)
|
76 |
|
|
|
|
|
77 |
return [
|
78 |
datasets.SplitGenerator(
|
79 |
name=datasets.Split.TRAIN,
|
|
|
124 |
|
125 |
key = 0
|
126 |
all_res = []
|
127 |
+
|
128 |
f_seq_in = open(filepath_1, "r")
|
129 |
seq_in = f_seq_in.read().split("\n")
|
130 |
f_seq_in.close()
|
|
|
154 |
"tokens": tokens,
|
155 |
"ner_tags": ner_tags,
|
156 |
})
|
157 |
+
|
158 |
key += 1
|
159 |
|
160 |
ids = [r["id"] for r in all_res]
|
|
|
163 |
random.shuffle(ids)
|
164 |
random.shuffle(ids)
|
165 |
random.shuffle(ids)
|
166 |
+
|
167 |
+
train, validation, test = np.split(ids, [int(len(ids) * .7), int(len(ids) * .8)])
|
168 |
|
169 |
if split == "train":
|
170 |
allowed_ids = list(train)
|
|
|
172 |
allowed_ids = list(validation)
|
173 |
elif split == "test":
|
174 |
allowed_ids = list(test)
|
175 |
+
|
176 |
for r in all_res:
|
177 |
if r["id"] in allowed_ids:
|
178 |
yield r["id"], r
|