def redirect_to_id(element, lookup):
  """Creates mapping of redirect titles to article ids."""
  redirect_title = element["title"]
  article_title = wiki_utils.clean_wikilink(element["redirect"])
  if article_title in lookup:
    yield redirect_title, lookup[article_title]
  else:
    # Even if we haven't seen the article we still use the provided redirect.
    logging.debug("Unresolved redirect: %s", redirect_title)
    beam.metrics.Metrics.counter(__name__, "unresolved redirects").inc()
    yield redirect_title, article_title
Creates mapping of redirect titles to article ids.
language/fruit/beam_pipelines.py