system HF staff commited on
Commit
85d70f9
1 Parent(s): 2c7f7d6

Update files from the datasets library (from 1.12.0)

Browse files

Release notes: https://github.com/huggingface/datasets/releases/tag/1.12.0

Files changed (1) hide show
  1. wikicorpus.py +4 -4
wikicorpus.py CHANGED
@@ -122,7 +122,7 @@ class Wikicorpus(datasets.GeneratorBasedBuilder):
122
  ]
123
 
124
  def _generate_examples(self, dirpath):
125
- for filepath in sorted(Path(dirpath).iterdir()):
126
  with open(filepath, encoding="latin-1") as f:
127
  example = {}
128
  # raw
@@ -132,7 +132,7 @@ class Wikicorpus(datasets.GeneratorBasedBuilder):
132
  lemmas = []
133
  pos_tags = []
134
  wordnet_senses = []
135
- for id_, row in enumerate(f):
136
  if self.config.form == "raw":
137
  if row.startswith("<doc id"):
138
  metadata_match = METADATA_PATTERN.match(row)
@@ -141,7 +141,7 @@ class Wikicorpus(datasets.GeneratorBasedBuilder):
141
  elif row.startswith("</doc>"):
142
  pass
143
  elif row.startswith("ENDOFARTICLE"):
144
- yield id_, {
145
  "id": example["id"],
146
  "title": example["title"],
147
  "text": "\n".join(text).strip(),
@@ -159,7 +159,7 @@ class Wikicorpus(datasets.GeneratorBasedBuilder):
159
  pass
160
  elif row.startswith("ENDOFARTICLE") or row.startswith("\n"):
161
  if len(words) > 1: # some content besides only (. . Fp 0)
162
- yield id_, {
163
  "id": example["id"],
164
  "title": example["title"],
165
  "sentence": words,
 
122
  ]
123
 
124
  def _generate_examples(self, dirpath):
125
+ for file_idx, filepath in enumerate(sorted(Path(dirpath).iterdir())):
126
  with open(filepath, encoding="latin-1") as f:
127
  example = {}
128
  # raw
 
132
  lemmas = []
133
  pos_tags = []
134
  wordnet_senses = []
135
+ for row_idx, row in enumerate(f):
136
  if self.config.form == "raw":
137
  if row.startswith("<doc id"):
138
  metadata_match = METADATA_PATTERN.match(row)
 
141
  elif row.startswith("</doc>"):
142
  pass
143
  elif row.startswith("ENDOFARTICLE"):
144
+ yield f"{file_idx}_{row_idx}", {
145
  "id": example["id"],
146
  "title": example["title"],
147
  "text": "\n".join(text).strip(),
 
159
  pass
160
  elif row.startswith("ENDOFARTICLE") or row.startswith("\n"):
161
  if len(words) > 1: # some content besides only (. . Fp 0)
162
+ yield f"{file_idx}_{row_idx}", {
163
  "id": example["id"],
164
  "title": example["title"],
165
  "sentence": words,