def _generate_examples(self, archive, directory):
    """Generate IMDB examples."""
    reg = re.compile(os.path.join("^%s" % directory, "(?P<label>neg|pos)", ""))
    for path, imdb_f in archive:
      res = reg.match(path)
      if not res:
        continue
      text = imdb_f.read().strip()
      yield {
          "text": text,
          "label": res.groupdict()["label"],
      }
Generate IMDB examples.