ramybaly
commited on
Commit
·
774debe
1
Parent(s):
8762e84
fixed bug in dataset script
Browse files- id2fine_tags.json +2 -2
- nerd.py +78 -81
id2fine_tags.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:64604b88e4f94fb8d729e428302915704a04b8317c84802ae188ea41a97faaf6
|
| 3 |
+
size 1748
|
nerd.py
CHANGED
|
@@ -73,79 +73,79 @@ class NERD(datasets.GeneratorBasedBuilder):
|
|
| 73 |
names=['O', 'I-ART', 'I-BUILDING', 'I-EVENT', 'I-LOC', 'I-ORG', 'I-MISC', 'I-PER', 'I-PRODUCT']
|
| 74 |
)
|
| 75 |
),
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
}
|
| 150 |
),
|
| 151 |
supervised_keys=None,
|
|
@@ -156,9 +156,6 @@ class NERD(datasets.GeneratorBasedBuilder):
|
|
| 156 |
def _split_generators(self, dl_manager):
|
| 157 |
"""Returns SplitGenerators."""
|
| 158 |
urls_to_download = {
|
| 159 |
-
# "train": f"{_URL}{_TRAINING_FILE}",
|
| 160 |
-
# "validation": f"{_URL}{_DEV_FILE}",
|
| 161 |
-
# "test": f"{_URL}{_TEST_FILE}",
|
| 162 |
'train': 'train.txt',
|
| 163 |
'validation': 'validation.txt',
|
| 164 |
'test': 'test.txt',
|
|
@@ -180,7 +177,7 @@ class NERD(datasets.GeneratorBasedBuilder):
|
|
| 180 |
guid = 0
|
| 181 |
tokens = []
|
| 182 |
ner_tags = []
|
| 183 |
-
|
| 184 |
|
| 185 |
for line in lines:
|
| 186 |
if line.startswith("-DOCSTART-") or line.strip() == "" or line == "\n":
|
|
@@ -189,22 +186,22 @@ class NERD(datasets.GeneratorBasedBuilder):
|
|
| 189 |
"id": str(guid),
|
| 190 |
"tokens": tokens,
|
| 191 |
"ner_tags": ner_tags,
|
| 192 |
-
|
| 193 |
}
|
| 194 |
guid += 1
|
| 195 |
tokens = []
|
| 196 |
ner_tags = []
|
| 197 |
-
|
| 198 |
else:
|
| 199 |
# nerd tokens are tab- separated
|
| 200 |
splits = line.split('\t')
|
| 201 |
tokens.append(splits[0])
|
| 202 |
ner_tags.append(splits[1])
|
| 203 |
-
|
| 204 |
# last example
|
| 205 |
yield guid, {
|
| 206 |
"id": str(guid),
|
| 207 |
"tokens": tokens,
|
| 208 |
"ner_tags": ner_tags,
|
| 209 |
-
|
| 210 |
}
|
|
|
|
| 73 |
names=['O', 'I-ART', 'I-BUILDING', 'I-EVENT', 'I-LOC', 'I-ORG', 'I-MISC', 'I-PER', 'I-PRODUCT']
|
| 74 |
)
|
| 75 |
),
|
| 76 |
+
"ner_tags_fine": datasets.Sequence(
|
| 77 |
+
datasets.features.ClassLabel(
|
| 78 |
+
names=[
|
| 79 |
+
'O',
|
| 80 |
+
'I-ART-broadcastprogram',
|
| 81 |
+
'I-ART-film',
|
| 82 |
+
'I-ART-music',
|
| 83 |
+
'I-ART-other',
|
| 84 |
+
'I-ART-painting',
|
| 85 |
+
'I-ART-writtenart',
|
| 86 |
+
'I-BUILDING-airport',
|
| 87 |
+
'I-BUILDING-hospital',
|
| 88 |
+
'I-BUILDING-hotel',
|
| 89 |
+
'I-BUILDING-library',
|
| 90 |
+
'I-BUILDING-other',
|
| 91 |
+
'I-BUILDING-restaurant',
|
| 92 |
+
'I-BUILDING-sportsfacility',
|
| 93 |
+
'I-BUILDING-theater',
|
| 94 |
+
'I-EVENT-attack/battle/war/militaryconflict',
|
| 95 |
+
'I-EVENT-disaster',
|
| 96 |
+
'I-EVENT-election',
|
| 97 |
+
'I-EVENT-other',
|
| 98 |
+
'I-EVENT-protest',
|
| 99 |
+
'I-EVENT-sportsevent',
|
| 100 |
+
'I-LOC-GPE',
|
| 101 |
+
'I-LOC-bodiesofwater',
|
| 102 |
+
'I-LOC-island',
|
| 103 |
+
'I-LOC-mountain',
|
| 104 |
+
'I-LOC-other',
|
| 105 |
+
'I-LOC-park',
|
| 106 |
+
'I-LOC-road/railway/highway/transit',
|
| 107 |
+
'I-ORG-company',
|
| 108 |
+
'I-ORG-education',
|
| 109 |
+
'I-ORG-government/governmentagency',
|
| 110 |
+
'I-ORG-media/newspaper',
|
| 111 |
+
'I-ORG-other',
|
| 112 |
+
'I-ORG-politicalparty',
|
| 113 |
+
'I-ORG-religion',
|
| 114 |
+
'I-ORG-showorganization',
|
| 115 |
+
'I-ORG-sportsleague',
|
| 116 |
+
'I-ORG-sportsteam',
|
| 117 |
+
'I-MISC-astronomything',
|
| 118 |
+
'I-MISC-award',
|
| 119 |
+
'I-MISC-biologything',
|
| 120 |
+
'I-MISC-chemicalthing',
|
| 121 |
+
'I-MISC-currency',
|
| 122 |
+
'I-MISC-disease',
|
| 123 |
+
'I-MISC-educationaldegree',
|
| 124 |
+
'I-MISC-god',
|
| 125 |
+
'I-MISC-language',
|
| 126 |
+
'I-MISC-law',
|
| 127 |
+
'I-MISC-livingthing',
|
| 128 |
+
'I-MISC-medical',
|
| 129 |
+
'I-PER-actor',
|
| 130 |
+
'I-PER-artist/author',
|
| 131 |
+
'I-PER-athlete',
|
| 132 |
+
'I-PER-director',
|
| 133 |
+
'I-PER-other',
|
| 134 |
+
'I-PER-politician',
|
| 135 |
+
'I-PER-scholar',
|
| 136 |
+
'I-PER-soldier',
|
| 137 |
+
'I-PRODUCT-airplane',
|
| 138 |
+
'I-PRODUCT-car',
|
| 139 |
+
'I-PRODUCT-food',
|
| 140 |
+
'I-PRODUCT-game',
|
| 141 |
+
'I-PRODUCT-other',
|
| 142 |
+
'I-PRODUCT-ship',
|
| 143 |
+
'I-PRODUCT-software',
|
| 144 |
+
'I-PRODUCT-train',
|
| 145 |
+
'I-PRODUCT-weapon'
|
| 146 |
+
]
|
| 147 |
+
)
|
| 148 |
+
),
|
| 149 |
}
|
| 150 |
),
|
| 151 |
supervised_keys=None,
|
|
|
|
| 156 |
def _split_generators(self, dl_manager):
|
| 157 |
"""Returns SplitGenerators."""
|
| 158 |
urls_to_download = {
|
|
|
|
|
|
|
|
|
|
| 159 |
'train': 'train.txt',
|
| 160 |
'validation': 'validation.txt',
|
| 161 |
'test': 'test.txt',
|
|
|
|
| 177 |
guid = 0
|
| 178 |
tokens = []
|
| 179 |
ner_tags = []
|
| 180 |
+
ner_tags_fine = []
|
| 181 |
|
| 182 |
for line in lines:
|
| 183 |
if line.startswith("-DOCSTART-") or line.strip() == "" or line == "\n":
|
|
|
|
| 186 |
"id": str(guid),
|
| 187 |
"tokens": tokens,
|
| 188 |
"ner_tags": ner_tags,
|
| 189 |
+
"ner_tags_fine": ner_tags_fine,
|
| 190 |
}
|
| 191 |
guid += 1
|
| 192 |
tokens = []
|
| 193 |
ner_tags = []
|
| 194 |
+
ner_tags_fine = []
|
| 195 |
else:
|
| 196 |
# nerd tokens are tab- separated
|
| 197 |
splits = line.split('\t')
|
| 198 |
tokens.append(splits[0])
|
| 199 |
ner_tags.append(splits[1])
|
| 200 |
+
ner_tags_fine.append(splits[2].rstrip())
|
| 201 |
# last example
|
| 202 |
yield guid, {
|
| 203 |
"id": str(guid),
|
| 204 |
"tokens": tokens,
|
| 205 |
"ner_tags": ner_tags,
|
| 206 |
+
"ner_tags_fine": ner_tags_fine,
|
| 207 |
}
|