Commit
•
410a7d9
1
Parent(s):
1ab8f65
added conll files and loading script
Browse files- dev.conll +3 -0
- multi-train-distemist-dev-ner.py +110 -0
- train.conll +3 -0
dev.conll
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:498ef58b80b249be64570e36916403dc44f6af1822b77914d750b054c7d99fcf
|
3 |
+
size 6961926
|
multi-train-distemist-dev-ner.py
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Loading script for the MultiPlusDisTEMIST dataset.
|
2 |
+
import datasets
|
3 |
+
|
4 |
+
|
5 |
+
logger = datasets.logging.get_logger(__name__)
|
6 |
+
|
7 |
+
|
8 |
+
_CITATION = """
|
9 |
+
"""
|
10 |
+
|
11 |
+
|
12 |
+
_DESCRIPTION = """\
|
13 |
+
"""
|
14 |
+
|
15 |
+
_URL = "https://huggingface.co/datasets/Rodrigo1771/multi-plus-distemist/resolve/main/"
|
16 |
+
_TRAINING_FILE = "train.conll"
|
17 |
+
_DEV_FILE = "dev.conll"
|
18 |
+
_TEST_FILE = "test.conll"
|
19 |
+
|
20 |
+
|
21 |
+
class MultiPlusDisTEMISTConfig(datasets.BuilderConfig):
|
22 |
+
"""BuilderConfig for MultiPlusDisTEMIST NER dataset"""
|
23 |
+
|
24 |
+
def __init__(self, **kwargs):
|
25 |
+
"""BuilderConfig for MultiPlusDisTEMIST NER.
|
26 |
+
|
27 |
+
Args:
|
28 |
+
**kwargs: keyword arguments forwarded to super.
|
29 |
+
"""
|
30 |
+
super(MultiPlusDisTEMISTConfig, self).__init__(**kwargs)
|
31 |
+
|
32 |
+
|
33 |
+
class MultiPlusDisTEMIST(datasets.GeneratorBasedBuilder):
|
34 |
+
"""MultiPlusDisTEMIST NER dataset."""
|
35 |
+
|
36 |
+
BUILDER_CONFIGS = [
|
37 |
+
MultiPlusDisTEMISTConfig(
|
38 |
+
name="MultiPlusDisTEMIST",
|
39 |
+
version=datasets.Version("1.0.0"),
|
40 |
+
description="MultiPlusDisTEMIST dataset"),
|
41 |
+
]
|
42 |
+
|
43 |
+
def _info(self):
|
44 |
+
return datasets.DatasetInfo(
|
45 |
+
description=_DESCRIPTION,
|
46 |
+
features=datasets.Features(
|
47 |
+
{
|
48 |
+
"id": datasets.Value("string"),
|
49 |
+
"tokens": datasets.Sequence(datasets.Value("string")),
|
50 |
+
"ner_tags": datasets.Sequence(
|
51 |
+
datasets.features.ClassLabel(
|
52 |
+
names=[
|
53 |
+
"O",
|
54 |
+
"B-ENFERMEDAD",
|
55 |
+
"I-ENFERMEDAD",
|
56 |
+
"B-FARMACO",
|
57 |
+
"I-FARMACO"
|
58 |
+
]
|
59 |
+
)
|
60 |
+
),
|
61 |
+
}
|
62 |
+
),
|
63 |
+
supervised_keys=None,
|
64 |
+
homepage=_DESCRIPTION,
|
65 |
+
citation=_CITATION,
|
66 |
+
)
|
67 |
+
|
68 |
+
def _split_generators(self, dl_manager):
|
69 |
+
"""Returns SplitGenerators."""
|
70 |
+
urls_to_download = {
|
71 |
+
"train": f"{_URL}{_TRAINING_FILE}",
|
72 |
+
"dev": f"{_URL}{_DEV_FILE}",
|
73 |
+
# "test": f"{_URL}{_TEST_FILE}",
|
74 |
+
}
|
75 |
+
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
76 |
+
|
77 |
+
return [
|
78 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
79 |
+
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
|
80 |
+
# datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
|
81 |
+
]
|
82 |
+
|
83 |
+
def _generate_examples(self, filepath):
|
84 |
+
logger.info("⏳ Generating examples from = %s", filepath)
|
85 |
+
with open(filepath, encoding="utf-8") as f:
|
86 |
+
guid = 0
|
87 |
+
tokens = []
|
88 |
+
ner_tags = []
|
89 |
+
for line in f:
|
90 |
+
if line.startswith("-DOCSTART-") or line == "" or line == "\n":
|
91 |
+
if tokens:
|
92 |
+
yield guid, {
|
93 |
+
"id": str(guid),
|
94 |
+
"tokens": tokens,
|
95 |
+
"ner_tags": ner_tags,
|
96 |
+
}
|
97 |
+
guid += 1
|
98 |
+
tokens = []
|
99 |
+
ner_tags = []
|
100 |
+
else:
|
101 |
+
# MultiPlusDisTEMIST tokens are tab separated
|
102 |
+
splits = line.split("\t")
|
103 |
+
tokens.append(splits[0])
|
104 |
+
ner_tags.append(splits[-1].rstrip())
|
105 |
+
# last example
|
106 |
+
yield guid, {
|
107 |
+
"id": str(guid),
|
108 |
+
"tokens": tokens,
|
109 |
+
"ner_tags": ner_tags,
|
110 |
+
}
|
train.conll
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8c0969ac8ddfbd534204bf9f15f8e1a838be19202490183a7f2fe59fedb8b8e9
|
3 |
+
size 28441946
|