concepts.benchmark.clevr.dataset.canonize_answer#

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

Canonize 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 canonized.

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

Returns:

the canonized answer.

Return type:

bool | int | str