def rekey_mentions(element):
  """Re-keys mentions in preparation for article merge."""
  if element["is_update"]:
    for entity in element["added_entities"]:
      yield entity["id"], element
  else:
    for entity in element["entities"]:
      yield entity["id"], element
Re-keys mentions in preparation for article merge.
language/fruit/beam_pipelines.py