concepts.benchmark.clevr.dataset.canonicalize_answer#

canonicalize_answer(answer, question_type=None)[source]#

canonicalize the answer to a standard format.

  • For yes/no questions, the answer will be converted to a boolean.

  • For count questions, the answer will be converted to an integer.

  • For other questions, the answer will be kept as it is.

Parameters:
  • answer (str) – the answer to be canonicalized.

  • question_type (str | None) – the question type. If None, the question type will be inferred from the answer.

Returns:

the canonicalized answer.

Return type:

bool | int | str