Dr. Jorge Abreu Vicente commited on
Commit
9c9bbcf
1 Parent(s): d1bdffc

Update sd-nlp-non-tokenized.py

Browse files
Files changed (1) hide show
  1. sd-nlp-non-tokenized.py +8 -4
sd-nlp-non-tokenized.py CHANGED
@@ -196,22 +196,25 @@ class SourceDataNLP(datasets.GeneratorBasedBuilder):
196
  yield id_, {
197
  "words": data["words"],
198
  "labels": labels,
 
199
  }
200
  elif self.config.name == "GENEPROD_ROLES":
201
- labels = data["label_ids"]["entity_types"]
202
  geneprod = ["B-GENEPROD", "I-GENEPROD", "B-PROTEIN", "I-PROTEIN", "B-GENE", "I-GENE"]
203
  tag_mask = [1 if t in geneprod else 0 for t in labels]
204
  yield id_, {
205
  "words": data["words"],
206
- "labels": data["label_ids"]["geneprod_roles"],
 
207
  }
208
  elif self.config.name == "SMALL_MOL_ROLES":
209
- labels = data["words"]["entity_types"]
210
  small_mol = ["B-SMALL_MOLECULE", "I-SMALL_MOLECULE"]
211
  tag_mask = [1 if t in small_mol else 0 for t in labels]
212
  yield id_, {
213
  "words": data["words"],
214
- "labels": data["label_ids"]["small_mol_roles"],
 
215
  }
216
  elif self.config.name == "BORING":
217
  yield id_, {"words": data["words"], "labels": data["label_ids"]["boring"]}
@@ -221,4 +224,5 @@ class SourceDataNLP(datasets.GeneratorBasedBuilder):
221
  yield id_, {
222
  "input_ids": data["words"],
223
  "labels": data["label_ids"]["panel_start"],
 
224
  }
 
196
  yield id_, {
197
  "words": data["words"],
198
  "labels": labels,
199
+ "tag_mask": tag_mask
200
  }
201
  elif self.config.name == "GENEPROD_ROLES":
202
+ labels = data["label_ids"]["geneprod_roles"]
203
  geneprod = ["B-GENEPROD", "I-GENEPROD", "B-PROTEIN", "I-PROTEIN", "B-GENE", "I-GENE"]
204
  tag_mask = [1 if t in geneprod else 0 for t in labels]
205
  yield id_, {
206
  "words": data["words"],
207
+ "labels": labels,
208
+ "tag_mask": tag_mask,
209
  }
210
  elif self.config.name == "SMALL_MOL_ROLES":
211
+ labels = data["words"]["small_mol_roles"]
212
  small_mol = ["B-SMALL_MOLECULE", "I-SMALL_MOLECULE"]
213
  tag_mask = [1 if t in small_mol else 0 for t in labels]
214
  yield id_, {
215
  "words": data["words"],
216
+ "labels": labels,
217
+ "tag_mask": tag_mask,
218
  }
219
  elif self.config.name == "BORING":
220
  yield id_, {"words": data["words"], "labels": data["label_ids"]["boring"]}
 
224
  yield id_, {
225
  "input_ids": data["words"],
226
  "labels": data["label_ids"]["panel_start"],
227
+ "tag_mask": tag_mask,
228
  }