Upload e3c.py
Browse files
e3c.py
CHANGED
@@ -30,10 +30,10 @@ _URL = "https://github.com/hltfbk/E3C-Corpus/archive/refs/tags/v2.0.0.zip"
|
|
30 |
|
31 |
|
32 |
class E3CConfig(datasets.BuilderConfig):
|
33 |
-
"""BuilderConfig for
|
34 |
|
35 |
def __init__(self, **kwargs):
|
36 |
-
"""BuilderConfig for
|
37 |
Args:
|
38 |
**kwargs: keyword arguments forwarded to super.
|
39 |
"""
|
@@ -46,7 +46,7 @@ class E3C(datasets.GeneratorBasedBuilder):
|
|
46 |
E3CConfig(
|
47 |
name="e3c",
|
48 |
version=VERSION,
|
49 |
-
description="this is
|
50 |
),
|
51 |
]
|
52 |
|
@@ -54,7 +54,9 @@ class E3C(datasets.GeneratorBasedBuilder):
|
|
54 |
"""This method specifies the DatasetInfo which contains information and typings."""
|
55 |
features = datasets.Features(
|
56 |
{
|
|
|
57 |
"tokens": datasets.Sequence(datasets.Value("string")),
|
|
|
58 |
"ner_tags": datasets.Sequence(
|
59 |
datasets.features.ClassLabel(
|
60 |
names=[
|
@@ -263,8 +265,8 @@ class E3C(datasets.GeneratorBasedBuilder):
|
|
263 |
Args:
|
264 |
filepath: The path to the folder containing the files to parse.
|
265 |
Yields:
|
266 |
-
|
267 |
-
|
268 |
"""
|
269 |
guid = 0
|
270 |
for content in self.get_parsed_data(filepath):
|
@@ -275,6 +277,9 @@ class E3C(datasets.GeneratorBasedBuilder):
|
|
275 |
content["TOKENS"],
|
276 |
)
|
277 |
)
|
|
|
|
|
|
|
278 |
labels = ["O"] * len(filtered_tokens)
|
279 |
for entity_type in [
|
280 |
"CLINENTITY",
|
@@ -302,7 +307,9 @@ class E3C(datasets.GeneratorBasedBuilder):
|
|
302 |
else:
|
303 |
labels[idx_token] = f"{entity_type}"
|
304 |
yield guid, {
|
|
|
305 |
"tokens": list(map(lambda tokens: tokens[2], filtered_tokens)),
|
306 |
"ner_tags": labels,
|
|
|
307 |
}
|
308 |
guid += 1
|
|
|
30 |
|
31 |
|
32 |
class E3CConfig(datasets.BuilderConfig):
|
33 |
+
"""BuilderConfig for E3C."""
|
34 |
|
35 |
def __init__(self, **kwargs):
|
36 |
+
"""BuilderConfig for E3C.
|
37 |
Args:
|
38 |
**kwargs: keyword arguments forwarded to super.
|
39 |
"""
|
|
|
46 |
E3CConfig(
|
47 |
name="e3c",
|
48 |
version=VERSION,
|
49 |
+
description="this is an implementation of the E3C dataset",
|
50 |
),
|
51 |
]
|
52 |
|
|
|
54 |
"""This method specifies the DatasetInfo which contains information and typings."""
|
55 |
features = datasets.Features(
|
56 |
{
|
57 |
+
"text": datasets.Value("string"),
|
58 |
"tokens": datasets.Sequence(datasets.Value("string")),
|
59 |
+
"tokens_offsets": datasets.Sequence(datasets.Sequence(datasets.Value("int32"))),
|
60 |
"ner_tags": datasets.Sequence(
|
61 |
datasets.features.ClassLabel(
|
62 |
names=[
|
|
|
265 |
Args:
|
266 |
filepath: The path to the folder containing the files to parse.
|
267 |
Yields:
|
268 |
+
an example containing four fields: the text, the annotations, the tokens offsets and
|
269 |
+
the sentences.
|
270 |
"""
|
271 |
guid = 0
|
272 |
for content in self.get_parsed_data(filepath):
|
|
|
277 |
content["TOKENS"],
|
278 |
)
|
279 |
)
|
280 |
+
tokens_offsets = [
|
281 |
+
[token[0] - sentence[0], token[1] - sentence[0]] for token in filtered_tokens
|
282 |
+
]
|
283 |
labels = ["O"] * len(filtered_tokens)
|
284 |
for entity_type in [
|
285 |
"CLINENTITY",
|
|
|
307 |
else:
|
308 |
labels[idx_token] = f"{entity_type}"
|
309 |
yield guid, {
|
310 |
+
"text": sentence[-1],
|
311 |
"tokens": list(map(lambda tokens: tokens[2], filtered_tokens)),
|
312 |
"ner_tags": labels,
|
313 |
+
"tokens_offsets": tokens_offsets,
|
314 |
}
|
315 |
guid += 1
|