Datasets:
Tasks:
Token Classification
Modalities:
Text
Formats:
parquet
Sub-tasks:
named-entity-recognition
Languages:
English
Size:
100K - 1M
Tags:
structure-prediction
License:
Convert dataset to Parquet (#8)
Browse files- Convert dataset to Parquet (79d238bee9110b3d998aa345c2a8934ff1c16837)
- Add 'intra' config data files (59a8b3ce51717ba9c7b3248dc7558518e8733f46)
- Add 'supervised' config data files (32e80064ebb89f8890f752240176e6322a19b6c8)
- Delete loading script (95340b190c5a86dfdbb93d22b016cee9b0f93295)
- Delete data file (ee3a4922bf315a7db52cfaf9fe524e7610b38730)
- Delete data file (4645f0acbc22f7b062ea1f36f41b8040ec3209b3)
- Delete data file (547c080e07ad8821982b2e229cabeb6813d46909)
Co-authored-by: Gianmarco <[email protected]>
- .gitattributes +9 -0
- README.md +332 -0
- few-nerd.py +0 -319
- data/inter.zip → inter/test-00000-of-00001.parquet +2 -2
- data/intra.zip → inter/train-00000-of-00001.parquet +2 -2
- data/supervised.zip → inter/validation-00000-of-00001.parquet +2 -2
- intra/test-00000-of-00001.parquet +3 -0
- intra/train-00000-of-00001.parquet +3 -0
- intra/validation-00000-of-00001.parquet +3 -0
- supervised/test-00000-of-00001.parquet +3 -0
- supervised/train-00000-of-00001.parquet +3 -0
- supervised/validation-00000-of-00001.parquet +3 -0
.gitattributes
CHANGED
|
@@ -17,3 +17,12 @@
|
|
| 17 |
data/inter.zip filter=lfs diff=lfs merge=lfs -text
|
| 18 |
data/intra.zip filter=lfs diff=lfs merge=lfs -text
|
| 19 |
data/supervised.zip filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
data/inter.zip filter=lfs diff=lfs merge=lfs -text
|
| 18 |
data/intra.zip filter=lfs diff=lfs merge=lfs -text
|
| 19 |
data/supervised.zip filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
inter/train-00000-of-00001.parquet filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
inter/validation-00000-of-00001.parquet filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
inter/test-00000-of-00001.parquet filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
intra/train-00000-of-00001.parquet filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
intra/validation-00000-of-00001.parquet filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
intra/test-00000-of-00001.parquet filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
supervised/train-00000-of-00001.parquet filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
supervised/validation-00000-of-00001.parquet filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
supervised/test-00000-of-00001.parquet filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -21,6 +21,338 @@ paperswithcode_id: few-nerd
|
|
| 21 |
pretty_name: Few-NERD
|
| 22 |
tags:
|
| 23 |
- structure-prediction
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
---
|
| 25 |
|
| 26 |
# Dataset Card for "Few-NERD"
|
|
|
|
| 21 |
pretty_name: Few-NERD
|
| 22 |
tags:
|
| 23 |
- structure-prediction
|
| 24 |
+
dataset_info:
|
| 25 |
+
- config_name: inter
|
| 26 |
+
features:
|
| 27 |
+
- name: id
|
| 28 |
+
dtype: string
|
| 29 |
+
- name: tokens
|
| 30 |
+
sequence: string
|
| 31 |
+
- name: ner_tags
|
| 32 |
+
sequence:
|
| 33 |
+
class_label:
|
| 34 |
+
names:
|
| 35 |
+
'0': O
|
| 36 |
+
'1': art
|
| 37 |
+
'2': building
|
| 38 |
+
'3': event
|
| 39 |
+
'4': location
|
| 40 |
+
'5': organization
|
| 41 |
+
'6': other
|
| 42 |
+
'7': person
|
| 43 |
+
'8': product
|
| 44 |
+
- name: fine_ner_tags
|
| 45 |
+
sequence:
|
| 46 |
+
class_label:
|
| 47 |
+
names:
|
| 48 |
+
'0': O
|
| 49 |
+
'1': art-broadcastprogram
|
| 50 |
+
'2': art-film
|
| 51 |
+
'3': art-music
|
| 52 |
+
'4': art-other
|
| 53 |
+
'5': art-painting
|
| 54 |
+
'6': art-writtenart
|
| 55 |
+
'7': building-airport
|
| 56 |
+
'8': building-hospital
|
| 57 |
+
'9': building-hotel
|
| 58 |
+
'10': building-library
|
| 59 |
+
'11': building-other
|
| 60 |
+
'12': building-restaurant
|
| 61 |
+
'13': building-sportsfacility
|
| 62 |
+
'14': building-theater
|
| 63 |
+
'15': event-attack/battle/war/militaryconflict
|
| 64 |
+
'16': event-disaster
|
| 65 |
+
'17': event-election
|
| 66 |
+
'18': event-other
|
| 67 |
+
'19': event-protest
|
| 68 |
+
'20': event-sportsevent
|
| 69 |
+
'21': location-GPE
|
| 70 |
+
'22': location-bodiesofwater
|
| 71 |
+
'23': location-island
|
| 72 |
+
'24': location-mountain
|
| 73 |
+
'25': location-other
|
| 74 |
+
'26': location-park
|
| 75 |
+
'27': location-road/railway/highway/transit
|
| 76 |
+
'28': organization-company
|
| 77 |
+
'29': organization-education
|
| 78 |
+
'30': organization-government/governmentagency
|
| 79 |
+
'31': organization-media/newspaper
|
| 80 |
+
'32': organization-other
|
| 81 |
+
'33': organization-politicalparty
|
| 82 |
+
'34': organization-religion
|
| 83 |
+
'35': organization-showorganization
|
| 84 |
+
'36': organization-sportsleague
|
| 85 |
+
'37': organization-sportsteam
|
| 86 |
+
'38': other-astronomything
|
| 87 |
+
'39': other-award
|
| 88 |
+
'40': other-biologything
|
| 89 |
+
'41': other-chemicalthing
|
| 90 |
+
'42': other-currency
|
| 91 |
+
'43': other-disease
|
| 92 |
+
'44': other-educationaldegree
|
| 93 |
+
'45': other-god
|
| 94 |
+
'46': other-language
|
| 95 |
+
'47': other-law
|
| 96 |
+
'48': other-livingthing
|
| 97 |
+
'49': other-medical
|
| 98 |
+
'50': person-actor
|
| 99 |
+
'51': person-artist/author
|
| 100 |
+
'52': person-athlete
|
| 101 |
+
'53': person-director
|
| 102 |
+
'54': person-other
|
| 103 |
+
'55': person-politician
|
| 104 |
+
'56': person-scholar
|
| 105 |
+
'57': person-soldier
|
| 106 |
+
'58': product-airplane
|
| 107 |
+
'59': product-car
|
| 108 |
+
'60': product-food
|
| 109 |
+
'61': product-game
|
| 110 |
+
'62': product-other
|
| 111 |
+
'63': product-ship
|
| 112 |
+
'64': product-software
|
| 113 |
+
'65': product-train
|
| 114 |
+
'66': product-weapon
|
| 115 |
+
splits:
|
| 116 |
+
- name: train
|
| 117 |
+
num_bytes: 87456461
|
| 118 |
+
num_examples: 130112
|
| 119 |
+
- name: validation
|
| 120 |
+
num_bytes: 10813084
|
| 121 |
+
num_examples: 18817
|
| 122 |
+
- name: test
|
| 123 |
+
num_bytes: 7920453
|
| 124 |
+
num_examples: 14007
|
| 125 |
+
download_size: 19914244
|
| 126 |
+
dataset_size: 106189998
|
| 127 |
+
- config_name: intra
|
| 128 |
+
features:
|
| 129 |
+
- name: id
|
| 130 |
+
dtype: string
|
| 131 |
+
- name: tokens
|
| 132 |
+
sequence: string
|
| 133 |
+
- name: ner_tags
|
| 134 |
+
sequence:
|
| 135 |
+
class_label:
|
| 136 |
+
names:
|
| 137 |
+
'0': O
|
| 138 |
+
'1': art
|
| 139 |
+
'2': building
|
| 140 |
+
'3': event
|
| 141 |
+
'4': location
|
| 142 |
+
'5': organization
|
| 143 |
+
'6': other
|
| 144 |
+
'7': person
|
| 145 |
+
'8': product
|
| 146 |
+
- name: fine_ner_tags
|
| 147 |
+
sequence:
|
| 148 |
+
class_label:
|
| 149 |
+
names:
|
| 150 |
+
'0': O
|
| 151 |
+
'1': art-broadcastprogram
|
| 152 |
+
'2': art-film
|
| 153 |
+
'3': art-music
|
| 154 |
+
'4': art-other
|
| 155 |
+
'5': art-painting
|
| 156 |
+
'6': art-writtenart
|
| 157 |
+
'7': building-airport
|
| 158 |
+
'8': building-hospital
|
| 159 |
+
'9': building-hotel
|
| 160 |
+
'10': building-library
|
| 161 |
+
'11': building-other
|
| 162 |
+
'12': building-restaurant
|
| 163 |
+
'13': building-sportsfacility
|
| 164 |
+
'14': building-theater
|
| 165 |
+
'15': event-attack/battle/war/militaryconflict
|
| 166 |
+
'16': event-disaster
|
| 167 |
+
'17': event-election
|
| 168 |
+
'18': event-other
|
| 169 |
+
'19': event-protest
|
| 170 |
+
'20': event-sportsevent
|
| 171 |
+
'21': location-GPE
|
| 172 |
+
'22': location-bodiesofwater
|
| 173 |
+
'23': location-island
|
| 174 |
+
'24': location-mountain
|
| 175 |
+
'25': location-other
|
| 176 |
+
'26': location-park
|
| 177 |
+
'27': location-road/railway/highway/transit
|
| 178 |
+
'28': organization-company
|
| 179 |
+
'29': organization-education
|
| 180 |
+
'30': organization-government/governmentagency
|
| 181 |
+
'31': organization-media/newspaper
|
| 182 |
+
'32': organization-other
|
| 183 |
+
'33': organization-politicalparty
|
| 184 |
+
'34': organization-religion
|
| 185 |
+
'35': organization-showorganization
|
| 186 |
+
'36': organization-sportsleague
|
| 187 |
+
'37': organization-sportsteam
|
| 188 |
+
'38': other-astronomything
|
| 189 |
+
'39': other-award
|
| 190 |
+
'40': other-biologything
|
| 191 |
+
'41': other-chemicalthing
|
| 192 |
+
'42': other-currency
|
| 193 |
+
'43': other-disease
|
| 194 |
+
'44': other-educationaldegree
|
| 195 |
+
'45': other-god
|
| 196 |
+
'46': other-language
|
| 197 |
+
'47': other-law
|
| 198 |
+
'48': other-livingthing
|
| 199 |
+
'49': other-medical
|
| 200 |
+
'50': person-actor
|
| 201 |
+
'51': person-artist/author
|
| 202 |
+
'52': person-athlete
|
| 203 |
+
'53': person-director
|
| 204 |
+
'54': person-other
|
| 205 |
+
'55': person-politician
|
| 206 |
+
'56': person-scholar
|
| 207 |
+
'57': person-soldier
|
| 208 |
+
'58': product-airplane
|
| 209 |
+
'59': product-car
|
| 210 |
+
'60': product-food
|
| 211 |
+
'61': product-game
|
| 212 |
+
'62': product-other
|
| 213 |
+
'63': product-ship
|
| 214 |
+
'64': product-software
|
| 215 |
+
'65': product-train
|
| 216 |
+
'66': product-weapon
|
| 217 |
+
splits:
|
| 218 |
+
- name: train
|
| 219 |
+
num_bytes: 67631522
|
| 220 |
+
num_examples: 99519
|
| 221 |
+
- name: validation
|
| 222 |
+
num_bytes: 12759787
|
| 223 |
+
num_examples: 19358
|
| 224 |
+
- name: test
|
| 225 |
+
num_bytes: 25768577
|
| 226 |
+
num_examples: 44059
|
| 227 |
+
download_size: 19616006
|
| 228 |
+
dataset_size: 106159886
|
| 229 |
+
- config_name: supervised
|
| 230 |
+
features:
|
| 231 |
+
- name: id
|
| 232 |
+
dtype: string
|
| 233 |
+
- name: tokens
|
| 234 |
+
sequence: string
|
| 235 |
+
- name: ner_tags
|
| 236 |
+
sequence:
|
| 237 |
+
class_label:
|
| 238 |
+
names:
|
| 239 |
+
'0': O
|
| 240 |
+
'1': art
|
| 241 |
+
'2': building
|
| 242 |
+
'3': event
|
| 243 |
+
'4': location
|
| 244 |
+
'5': organization
|
| 245 |
+
'6': other
|
| 246 |
+
'7': person
|
| 247 |
+
'8': product
|
| 248 |
+
- name: fine_ner_tags
|
| 249 |
+
sequence:
|
| 250 |
+
class_label:
|
| 251 |
+
names:
|
| 252 |
+
'0': O
|
| 253 |
+
'1': art-broadcastprogram
|
| 254 |
+
'2': art-film
|
| 255 |
+
'3': art-music
|
| 256 |
+
'4': art-other
|
| 257 |
+
'5': art-painting
|
| 258 |
+
'6': art-writtenart
|
| 259 |
+
'7': building-airport
|
| 260 |
+
'8': building-hospital
|
| 261 |
+
'9': building-hotel
|
| 262 |
+
'10': building-library
|
| 263 |
+
'11': building-other
|
| 264 |
+
'12': building-restaurant
|
| 265 |
+
'13': building-sportsfacility
|
| 266 |
+
'14': building-theater
|
| 267 |
+
'15': event-attack/battle/war/militaryconflict
|
| 268 |
+
'16': event-disaster
|
| 269 |
+
'17': event-election
|
| 270 |
+
'18': event-other
|
| 271 |
+
'19': event-protest
|
| 272 |
+
'20': event-sportsevent
|
| 273 |
+
'21': location-GPE
|
| 274 |
+
'22': location-bodiesofwater
|
| 275 |
+
'23': location-island
|
| 276 |
+
'24': location-mountain
|
| 277 |
+
'25': location-other
|
| 278 |
+
'26': location-park
|
| 279 |
+
'27': location-road/railway/highway/transit
|
| 280 |
+
'28': organization-company
|
| 281 |
+
'29': organization-education
|
| 282 |
+
'30': organization-government/governmentagency
|
| 283 |
+
'31': organization-media/newspaper
|
| 284 |
+
'32': organization-other
|
| 285 |
+
'33': organization-politicalparty
|
| 286 |
+
'34': organization-religion
|
| 287 |
+
'35': organization-showorganization
|
| 288 |
+
'36': organization-sportsleague
|
| 289 |
+
'37': organization-sportsteam
|
| 290 |
+
'38': other-astronomything
|
| 291 |
+
'39': other-award
|
| 292 |
+
'40': other-biologything
|
| 293 |
+
'41': other-chemicalthing
|
| 294 |
+
'42': other-currency
|
| 295 |
+
'43': other-disease
|
| 296 |
+
'44': other-educationaldegree
|
| 297 |
+
'45': other-god
|
| 298 |
+
'46': other-language
|
| 299 |
+
'47': other-law
|
| 300 |
+
'48': other-livingthing
|
| 301 |
+
'49': other-medical
|
| 302 |
+
'50': person-actor
|
| 303 |
+
'51': person-artist/author
|
| 304 |
+
'52': person-athlete
|
| 305 |
+
'53': person-director
|
| 306 |
+
'54': person-other
|
| 307 |
+
'55': person-politician
|
| 308 |
+
'56': person-scholar
|
| 309 |
+
'57': person-soldier
|
| 310 |
+
'58': product-airplane
|
| 311 |
+
'59': product-car
|
| 312 |
+
'60': product-food
|
| 313 |
+
'61': product-game
|
| 314 |
+
'62': product-other
|
| 315 |
+
'63': product-ship
|
| 316 |
+
'64': product-software
|
| 317 |
+
'65': product-train
|
| 318 |
+
'66': product-weapon
|
| 319 |
+
splits:
|
| 320 |
+
- name: train
|
| 321 |
+
num_bytes: 81848645
|
| 322 |
+
num_examples: 131767
|
| 323 |
+
- name: validation
|
| 324 |
+
num_bytes: 11731110
|
| 325 |
+
num_examples: 18824
|
| 326 |
+
- name: test
|
| 327 |
+
num_bytes: 23345314
|
| 328 |
+
num_examples: 37648
|
| 329 |
+
download_size: 24121858
|
| 330 |
+
dataset_size: 116925069
|
| 331 |
+
configs:
|
| 332 |
+
- config_name: inter
|
| 333 |
+
data_files:
|
| 334 |
+
- split: train
|
| 335 |
+
path: inter/train-*
|
| 336 |
+
- split: validation
|
| 337 |
+
path: inter/validation-*
|
| 338 |
+
- split: test
|
| 339 |
+
path: inter/test-*
|
| 340 |
+
- config_name: intra
|
| 341 |
+
data_files:
|
| 342 |
+
- split: train
|
| 343 |
+
path: intra/train-*
|
| 344 |
+
- split: validation
|
| 345 |
+
path: intra/validation-*
|
| 346 |
+
- split: test
|
| 347 |
+
path: intra/test-*
|
| 348 |
+
- config_name: supervised
|
| 349 |
+
data_files:
|
| 350 |
+
- split: train
|
| 351 |
+
path: supervised/train-*
|
| 352 |
+
- split: validation
|
| 353 |
+
path: supervised/validation-*
|
| 354 |
+
- split: test
|
| 355 |
+
path: supervised/test-*
|
| 356 |
---
|
| 357 |
|
| 358 |
# Dataset Card for "Few-NERD"
|
few-nerd.py
DELETED
|
@@ -1,319 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import json
|
| 3 |
-
import datasets
|
| 4 |
-
from tqdm.autonotebook import tqdm
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
_CITATION = """
|
| 8 |
-
@inproceedings{ding2021few,
|
| 9 |
-
title={Few-NERD: A Few-Shot Named Entity Recognition Dataset},
|
| 10 |
-
author={Ding, Ning and Xu, Guangwei and Chen, Yulin, and Wang, Xiaobin and Han, Xu and Xie,
|
| 11 |
-
Pengjun and Zheng, Hai-Tao and Liu, Zhiyuan},
|
| 12 |
-
booktitle={ACL-IJCNLP},
|
| 13 |
-
year={2021}
|
| 14 |
-
}
|
| 15 |
-
"""
|
| 16 |
-
|
| 17 |
-
_DESCRIPTION = """
|
| 18 |
-
Few-NERD is a large-scale, fine-grained manually annotated named entity recognition dataset,
|
| 19 |
-
which contains 8 coarse-grained types, 66 fine-grained types, 188,200 sentences, 491,711 entities
|
| 20 |
-
and 4,601,223 tokens. Three benchmark tasks are built, one is supervised: Few-NERD (SUP) and the
|
| 21 |
-
other two are few-shot: Few-NERD (INTRA) and Few-NERD (INTER).
|
| 22 |
-
"""
|
| 23 |
-
|
| 24 |
-
_LICENSE = "CC BY-SA 4.0"
|
| 25 |
-
|
| 26 |
-
# the original data files (zip of .txt) can be downloaded from tsinghua cloud, but we chose to host them on huggingface.co
|
| 27 |
-
# for better reliability and download speed
|
| 28 |
-
_URL = "https://huggingface.co/datasets/DFKI-SLT/few-nerd/resolve/main/data"
|
| 29 |
-
_URLs = {
|
| 30 |
-
"supervised": f"{_URL}/supervised.zip",
|
| 31 |
-
"intra": f"{_URL}/intra.zip",
|
| 32 |
-
"inter": f"{_URL}/inter.zip"
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
# the label ids, for coarse(NER_TAGS_DICT) and fine(FINE_NER_TAGS_DICT)
|
| 36 |
-
NER_TAGS_DICT = {
|
| 37 |
-
"O": 0,
|
| 38 |
-
"art": 1,
|
| 39 |
-
"building": 2,
|
| 40 |
-
"event": 3,
|
| 41 |
-
"location": 4,
|
| 42 |
-
"organization": 5,
|
| 43 |
-
"other": 6,
|
| 44 |
-
"person": 7,
|
| 45 |
-
"product": 8,
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
FINE_NER_TAGS_DICT = {
|
| 49 |
-
"O": 0,
|
| 50 |
-
"art-broadcastprogram": 1,
|
| 51 |
-
"art-film": 2,
|
| 52 |
-
"art-music": 3,
|
| 53 |
-
"art-other": 4,
|
| 54 |
-
"art-painting": 5,
|
| 55 |
-
"art-writtenart": 6,
|
| 56 |
-
"building-airport": 7,
|
| 57 |
-
"building-hospital": 8,
|
| 58 |
-
"building-hotel": 9,
|
| 59 |
-
"building-library": 10,
|
| 60 |
-
"building-other": 11,
|
| 61 |
-
"building-restaurant": 12,
|
| 62 |
-
"building-sportsfacility": 13,
|
| 63 |
-
"building-theater": 14,
|
| 64 |
-
"event-attack/battle/war/militaryconflict": 15,
|
| 65 |
-
"event-disaster": 16,
|
| 66 |
-
"event-election": 17,
|
| 67 |
-
"event-other": 18,
|
| 68 |
-
"event-protest": 19,
|
| 69 |
-
"event-sportsevent": 20,
|
| 70 |
-
"location-GPE": 21,
|
| 71 |
-
"location-bodiesofwater": 22,
|
| 72 |
-
"location-island": 23,
|
| 73 |
-
"location-mountain": 24,
|
| 74 |
-
"location-other": 25,
|
| 75 |
-
"location-park": 26,
|
| 76 |
-
"location-road/railway/highway/transit": 27,
|
| 77 |
-
"organization-company": 28,
|
| 78 |
-
"organization-education": 29,
|
| 79 |
-
"organization-government/governmentagency": 30,
|
| 80 |
-
"organization-media/newspaper": 31,
|
| 81 |
-
"organization-other": 32,
|
| 82 |
-
"organization-politicalparty": 33,
|
| 83 |
-
"organization-religion": 34,
|
| 84 |
-
"organization-showorganization": 35,
|
| 85 |
-
"organization-sportsleague": 36,
|
| 86 |
-
"organization-sportsteam": 37,
|
| 87 |
-
"other-astronomything": 38,
|
| 88 |
-
"other-award": 39,
|
| 89 |
-
"other-biologything": 40,
|
| 90 |
-
"other-chemicalthing": 41,
|
| 91 |
-
"other-currency": 42,
|
| 92 |
-
"other-disease": 43,
|
| 93 |
-
"other-educationaldegree": 44,
|
| 94 |
-
"other-god": 45,
|
| 95 |
-
"other-language": 46,
|
| 96 |
-
"other-law": 47,
|
| 97 |
-
"other-livingthing": 48,
|
| 98 |
-
"other-medical": 49,
|
| 99 |
-
"person-actor": 50,
|
| 100 |
-
"person-artist/author": 51,
|
| 101 |
-
"person-athlete": 52,
|
| 102 |
-
"person-director": 53,
|
| 103 |
-
"person-other": 54,
|
| 104 |
-
"person-politician": 55,
|
| 105 |
-
"person-scholar": 56,
|
| 106 |
-
"person-soldier": 57,
|
| 107 |
-
"product-airplane": 58,
|
| 108 |
-
"product-car": 59,
|
| 109 |
-
"product-food": 60,
|
| 110 |
-
"product-game": 61,
|
| 111 |
-
"product-other": 62,
|
| 112 |
-
"product-ship": 63,
|
| 113 |
-
"product-software": 64,
|
| 114 |
-
"product-train": 65,
|
| 115 |
-
"product-weapon": 66,
|
| 116 |
-
}
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
class FewNERDConfig(datasets.BuilderConfig):
|
| 120 |
-
"""BuilderConfig for FewNERD"""
|
| 121 |
-
|
| 122 |
-
def __init__(self, **kwargs):
|
| 123 |
-
"""BuilderConfig for FewNERD.
|
| 124 |
-
|
| 125 |
-
Args:
|
| 126 |
-
**kwargs: keyword arguments forwarded to super.
|
| 127 |
-
"""
|
| 128 |
-
super(FewNERDConfig, self).__init__(**kwargs)
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
class FewNERD(datasets.GeneratorBasedBuilder):
|
| 132 |
-
BUILDER_CONFIGS = [
|
| 133 |
-
FewNERDConfig(name="supervised", description="Fully supervised setting."),
|
| 134 |
-
FewNERDConfig(
|
| 135 |
-
name="inter",
|
| 136 |
-
description="Few-shot setting. Each file contains all 8 coarse "
|
| 137 |
-
"types but different fine-grained types.",
|
| 138 |
-
),
|
| 139 |
-
FewNERDConfig(
|
| 140 |
-
name="intra", description="Few-shot setting. Randomly split by coarse type."
|
| 141 |
-
),
|
| 142 |
-
]
|
| 143 |
-
|
| 144 |
-
def _info(self):
|
| 145 |
-
return datasets.DatasetInfo(
|
| 146 |
-
description=_DESCRIPTION,
|
| 147 |
-
features=datasets.Features(
|
| 148 |
-
{
|
| 149 |
-
"id": datasets.Value("string"),
|
| 150 |
-
"tokens": datasets.features.Sequence(datasets.Value("string")),
|
| 151 |
-
"ner_tags": datasets.features.Sequence(
|
| 152 |
-
datasets.features.ClassLabel(
|
| 153 |
-
names=[
|
| 154 |
-
"O",
|
| 155 |
-
"art",
|
| 156 |
-
"building",
|
| 157 |
-
"event",
|
| 158 |
-
"location",
|
| 159 |
-
"organization",
|
| 160 |
-
"other",
|
| 161 |
-
"person",
|
| 162 |
-
"product",
|
| 163 |
-
]
|
| 164 |
-
)
|
| 165 |
-
),
|
| 166 |
-
"fine_ner_tags": datasets.Sequence(
|
| 167 |
-
datasets.features.ClassLabel(
|
| 168 |
-
names=[
|
| 169 |
-
"O",
|
| 170 |
-
"art-broadcastprogram",
|
| 171 |
-
"art-film",
|
| 172 |
-
"art-music",
|
| 173 |
-
"art-other",
|
| 174 |
-
"art-painting",
|
| 175 |
-
"art-writtenart",
|
| 176 |
-
"building-airport",
|
| 177 |
-
"building-hospital",
|
| 178 |
-
"building-hotel",
|
| 179 |
-
"building-library",
|
| 180 |
-
"building-other",
|
| 181 |
-
"building-restaurant",
|
| 182 |
-
"building-sportsfacility",
|
| 183 |
-
"building-theater",
|
| 184 |
-
"event-attack/battle/war/militaryconflict",
|
| 185 |
-
"event-disaster",
|
| 186 |
-
"event-election",
|
| 187 |
-
"event-other",
|
| 188 |
-
"event-protest",
|
| 189 |
-
"event-sportsevent",
|
| 190 |
-
"location-GPE",
|
| 191 |
-
"location-bodiesofwater",
|
| 192 |
-
"location-island",
|
| 193 |
-
"location-mountain",
|
| 194 |
-
"location-other",
|
| 195 |
-
"location-park",
|
| 196 |
-
"location-road/railway/highway/transit",
|
| 197 |
-
"organization-company",
|
| 198 |
-
"organization-education",
|
| 199 |
-
"organization-government/governmentagency",
|
| 200 |
-
"organization-media/newspaper",
|
| 201 |
-
"organization-other",
|
| 202 |
-
"organization-politicalparty",
|
| 203 |
-
"organization-religion",
|
| 204 |
-
"organization-showorganization",
|
| 205 |
-
"organization-sportsleague",
|
| 206 |
-
"organization-sportsteam",
|
| 207 |
-
"other-astronomything",
|
| 208 |
-
"other-award",
|
| 209 |
-
"other-biologything",
|
| 210 |
-
"other-chemicalthing",
|
| 211 |
-
"other-currency",
|
| 212 |
-
"other-disease",
|
| 213 |
-
"other-educationaldegree",
|
| 214 |
-
"other-god",
|
| 215 |
-
"other-language",
|
| 216 |
-
"other-law",
|
| 217 |
-
"other-livingthing",
|
| 218 |
-
"other-medical",
|
| 219 |
-
"person-actor",
|
| 220 |
-
"person-artist/author",
|
| 221 |
-
"person-athlete",
|
| 222 |
-
"person-director",
|
| 223 |
-
"person-other",
|
| 224 |
-
"person-politician",
|
| 225 |
-
"person-scholar",
|
| 226 |
-
"person-soldier",
|
| 227 |
-
"product-airplane",
|
| 228 |
-
"product-car",
|
| 229 |
-
"product-food",
|
| 230 |
-
"product-game",
|
| 231 |
-
"product-other",
|
| 232 |
-
"product-ship",
|
| 233 |
-
"product-software",
|
| 234 |
-
"product-train",
|
| 235 |
-
"product-weapon",
|
| 236 |
-
]
|
| 237 |
-
)
|
| 238 |
-
),
|
| 239 |
-
}
|
| 240 |
-
),
|
| 241 |
-
supervised_keys=None,
|
| 242 |
-
homepage="https://ningding97.github.io/fewnerd/",
|
| 243 |
-
citation=_CITATION,
|
| 244 |
-
)
|
| 245 |
-
|
| 246 |
-
def _split_generators(self, dl_manager):
|
| 247 |
-
"""Returns SplitGenerators."""
|
| 248 |
-
url_to_download = dl_manager.download_and_extract(_URLs[self.config.name])
|
| 249 |
-
return [
|
| 250 |
-
datasets.SplitGenerator(
|
| 251 |
-
name=datasets.Split.TRAIN,
|
| 252 |
-
gen_kwargs={
|
| 253 |
-
"filepath": os.path.join(
|
| 254 |
-
url_to_download,
|
| 255 |
-
self.config.name,
|
| 256 |
-
"train.txt",
|
| 257 |
-
)
|
| 258 |
-
},
|
| 259 |
-
),
|
| 260 |
-
datasets.SplitGenerator(
|
| 261 |
-
name=datasets.Split.VALIDATION,
|
| 262 |
-
gen_kwargs={
|
| 263 |
-
"filepath": os.path.join(
|
| 264 |
-
url_to_download, self.config.name, "dev.txt"
|
| 265 |
-
)
|
| 266 |
-
},
|
| 267 |
-
),
|
| 268 |
-
datasets.SplitGenerator(
|
| 269 |
-
name=datasets.Split.TEST,
|
| 270 |
-
gen_kwargs={
|
| 271 |
-
"filepath": os.path.join(
|
| 272 |
-
url_to_download, self.config.name, "test.txt"
|
| 273 |
-
)
|
| 274 |
-
},
|
| 275 |
-
),
|
| 276 |
-
]
|
| 277 |
-
|
| 278 |
-
def _generate_examples(self, filepath=None):
|
| 279 |
-
# check file type
|
| 280 |
-
assert filepath[-4:] == ".txt"
|
| 281 |
-
|
| 282 |
-
num_lines = sum(1 for _ in open(filepath, encoding="utf-8"))
|
| 283 |
-
id = 0
|
| 284 |
-
|
| 285 |
-
with open(filepath, "r", encoding="utf-8") as f:
|
| 286 |
-
tokens, ner_tags, fine_ner_tags = [], [], []
|
| 287 |
-
for line in tqdm(f, total=num_lines):
|
| 288 |
-
line = line.strip().split()
|
| 289 |
-
|
| 290 |
-
if line:
|
| 291 |
-
assert len(line) == 2
|
| 292 |
-
token, fine_ner_tag = line
|
| 293 |
-
ner_tag = fine_ner_tag.split("-")[0]
|
| 294 |
-
|
| 295 |
-
tokens.append(token)
|
| 296 |
-
ner_tags.append(NER_TAGS_DICT[ner_tag])
|
| 297 |
-
fine_ner_tags.append(FINE_NER_TAGS_DICT[fine_ner_tag])
|
| 298 |
-
|
| 299 |
-
elif tokens:
|
| 300 |
-
# organize a record to be written into json
|
| 301 |
-
record = {
|
| 302 |
-
"tokens": tokens,
|
| 303 |
-
"id": str(id),
|
| 304 |
-
"ner_tags": ner_tags,
|
| 305 |
-
"fine_ner_tags": fine_ner_tags,
|
| 306 |
-
}
|
| 307 |
-
tokens, ner_tags, fine_ner_tags = [], [], []
|
| 308 |
-
id += 1
|
| 309 |
-
yield record["id"], record
|
| 310 |
-
|
| 311 |
-
# take the last sentence
|
| 312 |
-
if tokens:
|
| 313 |
-
record = {
|
| 314 |
-
"tokens": tokens,
|
| 315 |
-
"id": str(id),
|
| 316 |
-
"ner_tags": ner_tags,
|
| 317 |
-
"fine_ner_tags": fine_ner_tags,
|
| 318 |
-
}
|
| 319 |
-
yield record["id"], record
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data/inter.zip → inter/test-00000-of-00001.parquet
RENAMED
|
@@ -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:73de033f4bae11fb58f3c1ce43e114b194463ee359e5c8e2f0e5edc1920e683b
|
| 3 |
+
size 1551840
|
data/intra.zip → inter/train-00000-of-00001.parquet
RENAMED
|
@@ -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:65fea9cbdcb34728ddd22761cdaf0859e50dd14ae5dc0c77fb306f4330934802
|
| 3 |
+
size 16227216
|
data/supervised.zip → inter/validation-00000-of-00001.parquet
RENAMED
|
@@ -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:7ff182cd0ecc939c65dcff22e63fc336c5c8c2309e6e5384eaaddb4ab8629c9a
|
| 3 |
+
size 2135188
|
intra/test-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:35492f80b3fc07b220e6853dcb3eaec73bf70138ef10291b3caf55dc174e9217
|
| 3 |
+
size 4742040
|
intra/train-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d427e6dbbbafa3e3ce99640351075fe2f9e2daab84a602bce47b7e0c60cf9afc
|
| 3 |
+
size 12681898
|
intra/validation-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:febf702f905680d585aadfa04c4c05226117af9982895820be3028f09cef116f
|
| 3 |
+
size 2192068
|
supervised/test-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b7ad746fcbeb68fcc235ba7142d7c3723ea2dc39930089e947284defecf300c6
|
| 3 |
+
size 4823735
|
supervised/train-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6ccb192b1accd3d1754db2244d18ddf64040357fb5b9076a338ec421a72d7d61
|
| 3 |
+
size 16873779
|
supervised/validation-00000-of-00001.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d502de918f2a6510179e64bc8b7cfff4e28999188e308f8b0fe75bd71844da66
|
| 3 |
+
size 2424344
|