BeardedJohn
commited on
Commit
•
7bfda9f
1
Parent(s):
9de6764
Upload 4 files
Browse files- test.txt +0 -0
- train.txt +0 -0
- ubb-endava-conll-assistant-ner-only-misc-v2.py +130 -0
- validation.txt +0 -0
test.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
train.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
ubb-endava-conll-assistant-ner-only-misc-v2.py
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 HuggingFace Datasets Authors.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
|
16 |
+
# Lint as: python3
|
17 |
+
|
18 |
+
|
19 |
+
import os
|
20 |
+
|
21 |
+
import datasets
|
22 |
+
|
23 |
+
|
24 |
+
logger = datasets.logging.get_logger(__name__)
|
25 |
+
|
26 |
+
|
27 |
+
_CITATION = ""
|
28 |
+
|
29 |
+
_DESCRIPTION = ""
|
30 |
+
|
31 |
+
#_URL = "."
|
32 |
+
_TRAINING_FILE = "train.txt"
|
33 |
+
_DEV_FILE = "validation.txt"
|
34 |
+
_TEST_FILE = "test.txt"
|
35 |
+
|
36 |
+
|
37 |
+
class UBBDemoConfig(datasets.BuilderConfig):
|
38 |
+
"""BuilderConfig for UBBDemo"""
|
39 |
+
|
40 |
+
def __init__(self, **kwargs):
|
41 |
+
"""BuilderConfig for UBBDemo.
|
42 |
+
Args:
|
43 |
+
**kwargs: keyword arguments forwarded to super.
|
44 |
+
"""
|
45 |
+
super(UBBDemoConfig, self).__init__(**kwargs)
|
46 |
+
|
47 |
+
|
48 |
+
class UBBDemo(datasets.GeneratorBasedBuilder):
|
49 |
+
"""UBBDemo dataset."""
|
50 |
+
|
51 |
+
BUILDER_CONFIGS = [
|
52 |
+
UBBDemoConfig(name="UBBDemo", version=datasets.Version("1.0.0"), description="UBBDemo dataset"),
|
53 |
+
]
|
54 |
+
|
55 |
+
def _info(self):
|
56 |
+
return datasets.DatasetInfo(
|
57 |
+
description=_DESCRIPTION,
|
58 |
+
features=datasets.Features(
|
59 |
+
{
|
60 |
+
"id": datasets.Value("string"),
|
61 |
+
"tokens": datasets.Sequence(datasets.Value("string")),
|
62 |
+
"ner_tags": datasets.Sequence(
|
63 |
+
datasets.features.ClassLabel(
|
64 |
+
names=[
|
65 |
+
"O",
|
66 |
+
"B-PER",
|
67 |
+
"I-PER",
|
68 |
+
"B-ORG",
|
69 |
+
"I-ORG",
|
70 |
+
"B-LOC",
|
71 |
+
"I-LOC",
|
72 |
+
"B-MISC",
|
73 |
+
"I-MISC",
|
74 |
+
|
75 |
+
]
|
76 |
+
)
|
77 |
+
),
|
78 |
+
}
|
79 |
+
),
|
80 |
+
supervised_keys=None,
|
81 |
+
homepage="",
|
82 |
+
citation=_CITATION,
|
83 |
+
)
|
84 |
+
|
85 |
+
def _split_generators(self, dl_manager):
|
86 |
+
"""Returns SplitGenerators."""
|
87 |
+
|
88 |
+
path = "./"
|
89 |
+
data_files = {
|
90 |
+
"train": os.path.join(path, _TRAINING_FILE),
|
91 |
+
"validation": os.path.join(path, _DEV_FILE),
|
92 |
+
"test": os.path.join(path, _TEST_FILE),
|
93 |
+
}
|
94 |
+
|
95 |
+
downloaded_file = dl_manager.download_and_extract(data_files)
|
96 |
+
return [
|
97 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_file ["train"]}),
|
98 |
+
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_file ["validation"]}),
|
99 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_file ["test"]}),
|
100 |
+
]
|
101 |
+
|
102 |
+
def _generate_examples(self, filepath):
|
103 |
+
print("I am here" + filepath)
|
104 |
+
logger.info("⏳ Generating examples from = %s", filepath)
|
105 |
+
with open(filepath, encoding="utf-8") as f:
|
106 |
+
guid = 0
|
107 |
+
tokens = []
|
108 |
+
ner_tags = []
|
109 |
+
for line in f:
|
110 |
+
if line.startswith("-DOCSTART-") or line == "" or line == "\n":
|
111 |
+
if tokens:
|
112 |
+
yield guid, {
|
113 |
+
"id": str(guid),
|
114 |
+
"tokens": tokens,
|
115 |
+
"ner_tags": ner_tags,
|
116 |
+
}
|
117 |
+
guid += 1
|
118 |
+
tokens = []
|
119 |
+
ner_tags = []
|
120 |
+
else:
|
121 |
+
# UBBDemo tokens are space separated
|
122 |
+
splits = line.split(" ")
|
123 |
+
tokens.append(splits[0])
|
124 |
+
ner_tags.append(splits[3].rstrip())
|
125 |
+
# last example
|
126 |
+
yield guid, {
|
127 |
+
"id": str(guid),
|
128 |
+
"tokens": tokens,
|
129 |
+
"ner_tags": ner_tags,
|
130 |
+
}
|
validation.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|