Rodrigo1771 commited on
Commit
724e145
·
verified ·
1 Parent(s): 0183fce

Upload 3 files

Browse files
Files changed (3) hide show
  1. combined-train-distemist-dev-ner.py +114 -0
  2. dev.conll +3 -0
  3. test.conll +3 -0
combined-train-distemist-dev-ner.py ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Loading script for the CombinedTrainDisTEMISTDevNER 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/combined-train-distemist-dev-ner/resolve/main/"
16
+ _TRAINING_FILE = "train.conll"
17
+ _DEV_FILE = "dev.conll"
18
+ _TEST_FILE = "test.conll"
19
+
20
+
21
+ class CombinedTrainDisTEMISTDevNERConfig(datasets.BuilderConfig):
22
+ """BuilderConfig for CombinedTrainDisTEMISTDevNER NER dataset"""
23
+
24
+ def __init__(self, **kwargs):
25
+ """BuilderConfig for CombinedTrainDisTEMISTDevNER NER.
26
+
27
+ Args:
28
+ **kwargs: keyword arguments forwarded to super.
29
+ """
30
+ super(CombinedTrainDisTEMISTDevNERConfig, self).__init__(**kwargs)
31
+
32
+
33
+ class CombinedTrainDisTEMISTDevNER(datasets.GeneratorBasedBuilder):
34
+ """CombinedTrainDisTEMISTDevNER NER dataset."""
35
+
36
+ BUILDER_CONFIGS = [
37
+ CombinedTrainDisTEMISTDevNERConfig(
38
+ name="CombinedTrainDisTEMISTDevNER",
39
+ version=datasets.Version("1.0.0"),
40
+ description="CombinedTrainDisTEMISTDevNER 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-PROCEDIMIENTO",
57
+ "I-PROCEDIMIENTO",
58
+ "B-SINTOMA",
59
+ "I-SINTOMA",
60
+ "B-FARMACO",
61
+ "I-FARMACO"
62
+ ]
63
+ )
64
+ ),
65
+ }
66
+ ),
67
+ supervised_keys=None,
68
+ homepage=_DESCRIPTION,
69
+ citation=_CITATION,
70
+ )
71
+
72
+ def _split_generators(self, dl_manager):
73
+ """Returns SplitGenerators."""
74
+ urls_to_download = {
75
+ "train": f"{_URL}{_TRAINING_FILE}",
76
+ "dev": f"{_URL}{_DEV_FILE}",
77
+ "test": f"{_URL}{_TEST_FILE}",
78
+ }
79
+ downloaded_files = dl_manager.download_and_extract(urls_to_download)
80
+
81
+ return [
82
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
83
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
84
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
85
+ ]
86
+
87
+ def _generate_examples(self, filepath):
88
+ logger.info("⏳ Generating examples from = %s", filepath)
89
+ with open(filepath, encoding="utf-8") as f:
90
+ guid = 0
91
+ tokens = []
92
+ ner_tags = []
93
+ for line in f:
94
+ if line.startswith("-DOCSTART-") or line == "" or line == "\n":
95
+ if tokens:
96
+ yield guid, {
97
+ "id": str(guid),
98
+ "tokens": tokens,
99
+ "ner_tags": ner_tags,
100
+ }
101
+ guid += 1
102
+ tokens = []
103
+ ner_tags = []
104
+ else:
105
+ # CombinedTrainDisTEMISTDevNER tokens are tab separated
106
+ splits = line.split("\t")
107
+ tokens.append(splits[0])
108
+ ner_tags.append(splits[-1].rstrip())
109
+ # last example
110
+ yield guid, {
111
+ "id": str(guid),
112
+ "tokens": tokens,
113
+ "ner_tags": ner_tags,
114
+ }
dev.conll ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:10db94e3d2dcb1221dbb108a3a75d860a47b45cc1a58eabec45f89031fab37ab
3
+ size 6962059
test.conll ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:03d8ffc952d4699f82662572baddc18e2e3beda7646ad10f2e01af1c861ffe43
3
+ size 12313810