def get_candidate_text(json_dict, idx):
  """Returns a text representation of the candidate at the given index."""
  # No candidate at this index.
  if idx < 0 or idx >= len(json_dict["passage_answer_candidates"]):
    raise ValueError("Invalid index for passage candidate: {}".format(idx))

  return get_text_span(json_dict, json_dict["passage_answer_candidates"][idx])
Returns a text representation of the candidate at the given index.
language/canine/tydiqa/data.py