drAbreu commited on
Commit
f570476
1 Parent(s): 438cedb

Added generic roles

Browse files
Files changed (1) hide show
  1. sd-nlp-non-tokenized.py +17 -3
sd-nlp-non-tokenized.py CHANGED
@@ -70,14 +70,15 @@ class SourceDataNLP(datasets.GeneratorBasedBuilder):
70
  VERSION = datasets.Version("1.0.0")
71
 
72
  _URLS = {
73
- "NER": f"{_BASE_URL}sd_panels_filtered.zip",
74
- "PANELIZATION": f"{_BASE_URL}sd_panelization_filtered.zip",
75
  }
76
  BUILDER_CONFIGS = [
77
  datasets.BuilderConfig(name="NER", version=VERSION, description="Dataset for entity recognition"),
78
  datasets.BuilderConfig(name="GENEPROD_ROLES", version=VERSION, description="Dataset for semantic roles."),
79
  datasets.BuilderConfig(name="SMALL_MOL_ROLES", version=VERSION, description="Dataset for semantic roles."),
80
  datasets.BuilderConfig(name="BORING", version=VERSION, description="Dataset for semantic roles."),
 
81
  datasets.BuilderConfig(
82
  name="PANELIZATION",
83
  version=VERSION,
@@ -147,6 +148,16 @@ class SourceDataNLP(datasets.GeneratorBasedBuilder):
147
  "tag_mask": datasets.Sequence(feature=datasets.Value("int8")),
148
  }
149
  )
 
 
 
 
 
 
 
 
 
 
150
 
151
  return datasets.DatasetInfo(
152
  description=self._DESCRIPTION,
@@ -161,7 +172,7 @@ class SourceDataNLP(datasets.GeneratorBasedBuilder):
161
  """Returns SplitGenerators.
162
  Uses local files if a data_dir is specified. Otherwise downloads the files from their official url."""
163
 
164
- if self.config.name in ["NER", "GENEPROD_ROLES", "SMALL_MOL_ROLES", "BORING"]:
165
  url = self._URLS["NER"]
166
  data_dir = dl_manager.download_and_extract(url)
167
  data_dir += "/"
@@ -230,6 +241,9 @@ class SourceDataNLP(datasets.GeneratorBasedBuilder):
230
  elif self.config.name == "BORING":
231
  yield id_, {"words": data["words"],
232
  "labels": data["label_ids"]["boring"]}
 
 
 
233
  elif self.config.name == "PANELIZATION":
234
  labels = data["label_ids"]["panel_start"]
235
  tag_mask = [1 if t == "B-PANEL_START" else 0 for t in labels]
 
70
  VERSION = datasets.Version("1.0.0")
71
 
72
  _URLS = {
73
+ "NER": f"{_BASE_URL}sd_panels_filtered_generic_roles.zip",
74
+ "PANELIZATION": f"{_BASE_URL}sd_panelization_filtered_generic_roles.zip",
75
  }
76
  BUILDER_CONFIGS = [
77
  datasets.BuilderConfig(name="NER", version=VERSION, description="Dataset for entity recognition"),
78
  datasets.BuilderConfig(name="GENEPROD_ROLES", version=VERSION, description="Dataset for semantic roles."),
79
  datasets.BuilderConfig(name="SMALL_MOL_ROLES", version=VERSION, description="Dataset for semantic roles."),
80
  datasets.BuilderConfig(name="BORING", version=VERSION, description="Dataset for semantic roles."),
81
+ datasets.BuilderConfig(name="ROLES", version=VERSION, description="Dataset to train roles. GENEPROD and SMALL_MOL at once."),
82
  datasets.BuilderConfig(
83
  name="PANELIZATION",
84
  version=VERSION,
 
148
  "tag_mask": datasets.Sequence(feature=datasets.Value("int8")),
149
  }
150
  )
151
+ elif self.config.name == "ROLES":
152
+ features = datasets.Features(
153
+ {
154
+ "words": datasets.Sequence(feature=datasets.Value("string")),
155
+ "labels": datasets.Sequence(
156
+ feature=datasets.ClassLabel(num_classes=len(self._PANEL_START_NAMES),
157
+ names=self._PANEL_START_NAMES)
158
+ ),
159
+ }
160
+ )
161
 
162
  return datasets.DatasetInfo(
163
  description=self._DESCRIPTION,
 
172
  """Returns SplitGenerators.
173
  Uses local files if a data_dir is specified. Otherwise downloads the files from their official url."""
174
 
175
+ if self.config.name in ["NER", "GENEPROD_ROLES", "SMALL_MOL_ROLES", "BORING", "ROLES"]:
176
  url = self._URLS["NER"]
177
  data_dir = dl_manager.download_and_extract(url)
178
  data_dir += "/"
 
241
  elif self.config.name == "BORING":
242
  yield id_, {"words": data["words"],
243
  "labels": data["label_ids"]["boring"]}
244
+ elif self.config.name == "ROLES":
245
+ yield id_, {"words": data["text_generic_roles"],
246
+ "labels": data["labels_generic_roles"]}
247
  elif self.config.name == "PANELIZATION":
248
  labels = data["label_ids"]["panel_start"]
249
  tag_mask = [1 if t == "B-PANEL_START" else 0 for t in labels]