ramybaly
commited on
Commit
·
14a5ad4
1
Parent(s):
0f10ef1
updated field names from 'ner_tags' to 'tags'
Browse files
nerd.py
CHANGED
|
@@ -68,12 +68,12 @@ class NERD(datasets.GeneratorBasedBuilder):
|
|
| 68 |
{
|
| 69 |
"id": datasets.Value("string"),
|
| 70 |
"tokens": datasets.Sequence(datasets.Value("string")),
|
| 71 |
-
"
|
| 72 |
datasets.features.ClassLabel(
|
| 73 |
names=['O', 'I-ART', 'I-BUILDING', 'I-EVENT', 'I-LOC', 'I-ORG', 'I-MISC', 'I-PER', 'I-PRODUCT']
|
| 74 |
)
|
| 75 |
),
|
| 76 |
-
"
|
| 77 |
datasets.features.ClassLabel(
|
| 78 |
names=[
|
| 79 |
'O',
|
|
@@ -176,32 +176,32 @@ class NERD(datasets.GeneratorBasedBuilder):
|
|
| 176 |
|
| 177 |
guid = 0
|
| 178 |
tokens = []
|
| 179 |
-
|
| 180 |
-
|
| 181 |
|
| 182 |
for line in lines:
|
| 183 |
if line.startswith("-DOCSTART_") or line.strip() == "" or line == "\n":
|
| 184 |
if tokens:
|
| 185 |
yield guid, {
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
}
|
| 191 |
guid += 1
|
| 192 |
tokens = []
|
| 193 |
-
|
| 194 |
-
|
| 195 |
else:
|
| 196 |
# nerd tokens are tab- separated
|
| 197 |
splits = line.split('\t')
|
| 198 |
tokens.append(splits[0])
|
| 199 |
-
|
| 200 |
-
|
| 201 |
# last example
|
| 202 |
yield guid, {
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
}
|
|
|
|
| 68 |
{
|
| 69 |
"id": datasets.Value("string"),
|
| 70 |
"tokens": datasets.Sequence(datasets.Value("string")),
|
| 71 |
+
"tags": datasets.Sequence(
|
| 72 |
datasets.features.ClassLabel(
|
| 73 |
names=['O', 'I-ART', 'I-BUILDING', 'I-EVENT', 'I-LOC', 'I-ORG', 'I-MISC', 'I-PER', 'I-PRODUCT']
|
| 74 |
)
|
| 75 |
),
|
| 76 |
+
"tags_fine": datasets.Sequence(
|
| 77 |
datasets.features.ClassLabel(
|
| 78 |
names=[
|
| 79 |
'O',
|
|
|
|
| 176 |
|
| 177 |
guid = 0
|
| 178 |
tokens = []
|
| 179 |
+
tags = []
|
| 180 |
+
tags_fine = []
|
| 181 |
|
| 182 |
for line in lines:
|
| 183 |
if line.startswith("-DOCSTART_") or line.strip() == "" or line == "\n":
|
| 184 |
if tokens:
|
| 185 |
yield guid, {
|
| 186 |
+
'id': str(guid),
|
| 187 |
+
'tokens': tokens,
|
| 188 |
+
'tags': tags,
|
| 189 |
+
'tags_fine': tags_fine,
|
| 190 |
}
|
| 191 |
guid += 1
|
| 192 |
tokens = []
|
| 193 |
+
tags = []
|
| 194 |
+
tags_fine = []
|
| 195 |
else:
|
| 196 |
# nerd tokens are tab- separated
|
| 197 |
splits = line.split('\t')
|
| 198 |
tokens.append(splits[0])
|
| 199 |
+
tags.append(splits[1])
|
| 200 |
+
tags_fine.append(splits[2].rstrip())
|
| 201 |
# last example
|
| 202 |
yield guid, {
|
| 203 |
+
'id': str(guid),
|
| 204 |
+
'tokens': tokens,
|
| 205 |
+
'tags': tags,
|
| 206 |
+
'tags_fine': tags_fine,
|
| 207 |
}
|