<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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"],
      }