import logging


def verify_mention_index(original, reconstructed):
  """Verify that reconstruction succeeded relative to original mention_index."""

  def df_to_strings(df):
    """Returns unique IDs for the mentions in df."""
    return df.apply(
        lambda r: "{}:{}-{}".format(r["docid"], r["mention"], r["position"]),
        axis=1).values

  expected_records = set(df_to_strings(original))
  got_records = set(df_to_strings(reconstructed))
  missing = expected_records.difference(got_records)
  for missed in missing:
    logging.warning("Missing mention: %s", missed)
  return not missing