Aashraya Sachdeva commited on
Commit
387de82
·
1 Parent(s): 30fb2a7
Files changed (1) hide show
  1. multiconer2.py +9 -6
multiconer2.py CHANGED
@@ -193,13 +193,13 @@ class Multiconer2(datasets.GeneratorBasedBuilder):
193
  "ner_macro_tags": datasets.Sequence(
194
  datasets.features.ClassLabel(
195
  names=['O',
196
- "B-Location", "I-Location"
197
  "B-CreativeWork", "I-CreativeWork",
198
  "B-Group", "I-Group",
199
- "B-Person", "I-Person",
200
  "B-Product", "I-Product",
201
  "B-Medical", "I-Medical",
202
- ]
203
  )
204
  ),
205
  }
@@ -213,8 +213,8 @@ class Multiconer2(datasets.GeneratorBasedBuilder):
213
  """Returns SplitGenerators."""
214
 
215
  downloaded_files = dl_manager.download_and_extract({
216
- "train": f"{self.config.name}-train.conll",
217
- "dev": f"{self.config.name}-dev.conll",
218
  })
219
 
220
  return [
@@ -228,6 +228,7 @@ class Multiconer2(datasets.GeneratorBasedBuilder):
228
  guid = 0
229
  tokens = []
230
  ner_tags = []
 
231
  for line in f:
232
  if line.startswith("#") or line == "" or line == "\n":
233
  if tokens:
@@ -239,16 +240,18 @@ class Multiconer2(datasets.GeneratorBasedBuilder):
239
  guid += 1
240
  tokens = []
241
  ner_tags = []
 
242
  else:
243
  # conll2003 tokens are space separated
244
  splits = line.split(" _ _ ")
245
  tokens.append(splits[0])
246
  ner_tags.append(splits[1].rstrip())
 
247
  # last example
248
  if tokens:
249
  yield guid, {
250
  "id": str(guid),
251
  "tokens": tokens,
252
  "ner_tags": ner_tags,
253
- "ner_macro_tags": [self.micro_to_macro_ner_mapping[ner] for ner in ner_tags]
254
  }
 
193
  "ner_macro_tags": datasets.Sequence(
194
  datasets.features.ClassLabel(
195
  names=['O',
196
+ "B-Location", "I-Location",
197
  "B-CreativeWork", "I-CreativeWork",
198
  "B-Group", "I-Group",
199
+ "B-Person", "I-Person",
200
  "B-Product", "I-Product",
201
  "B-Medical", "I-Medical",
202
+ ]
203
  )
204
  ),
205
  }
 
213
  """Returns SplitGenerators."""
214
 
215
  downloaded_files = dl_manager.download_and_extract({
216
+ "train": f"{self.config.name}-train.conll",
217
+ "dev": f"{self.config.name}-dev.conll",
218
  })
219
 
220
  return [
 
228
  guid = 0
229
  tokens = []
230
  ner_tags = []
231
+ ner_macro_tags = []
232
  for line in f:
233
  if line.startswith("#") or line == "" or line == "\n":
234
  if tokens:
 
240
  guid += 1
241
  tokens = []
242
  ner_tags = []
243
+ ner_macro_tags = []
244
  else:
245
  # conll2003 tokens are space separated
246
  splits = line.split(" _ _ ")
247
  tokens.append(splits[0])
248
  ner_tags.append(splits[1].rstrip())
249
+ ner_macro_tags.append(self.micro_to_macro_ner_mapping[splits[1].rstrip()])
250
  # last example
251
  if tokens:
252
  yield guid, {
253
  "id": str(guid),
254
  "tokens": tokens,
255
  "ner_tags": ner_tags,
256
+ "ner_macro_tags": ner_macro_tags,
257
  }