Rodrigo1771 commited on
Commit
7c14185
·
verified ·
1 Parent(s): c144ad5

Upload 3 files

Browse files
Files changed (3) hide show
  1. dev.conll +3 -0
  2. symptemist-ner.py +110 -0
  3. test.conll +3 -0
dev.conll ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0028806f6e9454085a1df68fb63676799def3284afb0655f111d18e1aa2744f0
3
+ size 2928424
symptemist-ner.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Loading script for the SympTEMIST NER dataset.
2
+ import datasets
3
+
4
+
5
+ logger = datasets.logging.get_logger(__name__)
6
+
7
+
8
+ _CITATION = """\
9
+ @inproceedings{lima2023overview,
10
+ title={Overview of SympTEMIST at BioCreative VIII: corpus, guidelines and evaluation of systems for the detection and normalization of symptoms, signs and findings from text},
11
+ author={Lima-L{\'o}pez, Salvador and Farr{\'e}-Maduell, Eul{\`a}lia and Gasco-S{\'a}nchez, Luis and Rodr{\'\i}guez-Miret, Jan and Krallinger, Martin}
12
+ }"""
13
+
14
+ _DESCRIPTION = """\
15
+ https://temu.bsc.es/symptemist/
16
+ """
17
+
18
+ _URL = "https://huggingface.co/datasets/Rodrigo1771/symptemist-ner/resolve/main/"
19
+ _TRAINING_FILE = "train.conll"
20
+ _DEV_FILE = "dev.conll"
21
+ _TEST_FILE = "test.conll"
22
+
23
+ class SympTEMISTNERConfig(datasets.BuilderConfig):
24
+ """BuilderConfig for SympTEMIST NER dataset"""
25
+
26
+ def __init__(self, **kwargs):
27
+ """BuilderConfig for SympTEMIST NER.
28
+
29
+ Args:
30
+ **kwargs: keyword arguments forwarded to super.
31
+ """
32
+ super(SympTEMISTNERConfig, self).__init__(**kwargs)
33
+
34
+
35
+ class SympTEMISTNER(datasets.GeneratorBasedBuilder):
36
+ """SympTEMIST NER dataset."""
37
+
38
+ BUILDER_CONFIGS = [
39
+ SympTEMISTNERConfig(
40
+ name="SympTEMIST NER",
41
+ version=datasets.Version("1.0.0"),
42
+ description="SympTEMIST NER dataset"),
43
+ ]
44
+
45
+ def _info(self):
46
+ return datasets.DatasetInfo(
47
+ description=_DESCRIPTION,
48
+ features=datasets.Features(
49
+ {
50
+ "id": datasets.Value("string"),
51
+ "tokens": datasets.Sequence(datasets.Value("string")),
52
+ "ner_tags": datasets.Sequence(
53
+ datasets.features.ClassLabel(
54
+ names=[
55
+ "O",
56
+ "B-SINTOMA",
57
+ "I-SINTOMA",
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
+ # SympTEMIST 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
+ }
test.conll ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:86282c45fc0ef469c931d618a54e275371d3e61487b4a8b09992420f6f216171
3
+ size 4780073