Matías Rojas
commited on
Commit
•
d71eb6c
1
Parent(s):
b5fb0b2
files added
Browse files- .DS_Store +0 -0
- data/.DS_Store +0 -0
- data/Finding_dev.conll +0 -0
- data/Finding_test.conll +0 -0
- data/Finding_train.conll +0 -0
- finding.py +102 -0
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
data/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
data/Finding_dev.conll
ADDED
The diff for this file is too large to render.
See raw diff
|
|
data/Finding_test.conll
ADDED
The diff for this file is too large to render.
See raw diff
|
|
data/Finding_train.conll
ADDED
The diff for this file is too large to render.
See raw diff
|
|
finding.py
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import datasets
|
2 |
+
|
3 |
+
|
4 |
+
logger = datasets.logging.get_logger(__name__)
|
5 |
+
|
6 |
+
|
7 |
+
_CITATION = """\
|
8 |
+
|
9 |
+
"""
|
10 |
+
|
11 |
+
_DESCRIPTION = """\
|
12 |
+
|
13 |
+
|
14 |
+
"""
|
15 |
+
|
16 |
+
_URL = "https://huggingface.co/datasets/mrojas/family/resolve/main/data/"
|
17 |
+
_TRAINING_FILE = "Family_Member_ner_train.conll"
|
18 |
+
_DEV_FILE = "Family_Member_dev.conll"
|
19 |
+
_TEST_FILE = "Family_Member_test.conll"
|
20 |
+
|
21 |
+
|
22 |
+
class FamilyConfig(datasets.BuilderConfig):
|
23 |
+
"""BuilderConfig for Family"""
|
24 |
+
|
25 |
+
def __init__(self, **kwargs):
|
26 |
+
"""BuilderConfig for Family.
|
27 |
+
Args:
|
28 |
+
**kwargs: keyword arguments forwarded to super.
|
29 |
+
"""
|
30 |
+
super(FamilyConfig, self).__init__(**kwargs)
|
31 |
+
|
32 |
+
|
33 |
+
class Family(datasets.GeneratorBasedBuilder):
|
34 |
+
"""Family dataset."""
|
35 |
+
|
36 |
+
BUILDER_CONFIGS = [
|
37 |
+
FamilyConfig(name="family", version=datasets.Version("1.0.0"), description="Family dataset"),
|
38 |
+
]
|
39 |
+
|
40 |
+
def _info(self):
|
41 |
+
return datasets.DatasetInfo(
|
42 |
+
description=_DESCRIPTION,
|
43 |
+
features=datasets.Features(
|
44 |
+
{
|
45 |
+
"tokens": datasets.Sequence(datasets.Value("string")),
|
46 |
+
"ner_tags": datasets.Sequence(
|
47 |
+
datasets.features.ClassLabel(
|
48 |
+
names=[
|
49 |
+
"O",
|
50 |
+
"B-Family_Member",
|
51 |
+
"I-Family_Member",
|
52 |
+
]
|
53 |
+
)
|
54 |
+
),
|
55 |
+
}
|
56 |
+
),
|
57 |
+
supervised_keys=None,
|
58 |
+
homepage="",
|
59 |
+
citation=_CITATION,
|
60 |
+
)
|
61 |
+
|
62 |
+
def _split_generators(self, dl_manager):
|
63 |
+
"""Returns SplitGenerators."""
|
64 |
+
urls_to_download = {
|
65 |
+
"train": f"{_URL}{_TRAINING_FILE}",
|
66 |
+
"dev": f"{_URL}{_DEV_FILE}",
|
67 |
+
"test": f"{_URL}{_TEST_FILE}",
|
68 |
+
}
|
69 |
+
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
70 |
+
|
71 |
+
return [
|
72 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
73 |
+
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
|
74 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
|
75 |
+
]
|
76 |
+
|
77 |
+
def _generate_examples(self, filepath):
|
78 |
+
logger.info("⏳ Generating examples from = %s", filepath)
|
79 |
+
with open(filepath, encoding="utf-8") as f:
|
80 |
+
id_ = 0
|
81 |
+
tokens = []
|
82 |
+
ner_tags = []
|
83 |
+
for line in f:
|
84 |
+
if line == "" or line == "\n":
|
85 |
+
if tokens:
|
86 |
+
yield id_, {
|
87 |
+
"tokens": tokens,
|
88 |
+
"ner_tags": ner_tags,
|
89 |
+
}
|
90 |
+
id_ += 1
|
91 |
+
tokens = []
|
92 |
+
ner_tags = []
|
93 |
+
else:
|
94 |
+
# conll2003 tokens are space separated
|
95 |
+
splits = line.split(" ")
|
96 |
+
tokens.append(splits[0])
|
97 |
+
ner_tags.append(splits[1].rstrip())
|
98 |
+
# last example
|
99 |
+
yield id_, {
|
100 |
+
"tokens": tokens,
|
101 |
+
"ner_tags": ner_tags,
|
102 |
+
}
|