"git@developer.sourcefind.cn:modelzoo/resnet50_tensorflow.git" did not exist on "28d7aac1ad338019460ad3e31e085cc41727d8cc"
Commit bf038375 authored by baberabb's avatar baberabb
Browse files

Refactor whitespace check and add handling for multiple_targets

parent a07d05f7
...@@ -674,22 +674,23 @@ class ConfigurableTask(Task): ...@@ -674,22 +674,23 @@ class ConfigurableTask(Task):
check_choices = test_choice check_choices = test_choice
else: else:
check_choices = [test_target] check_choices = [test_target]
# TODO: is this only for multiple-choice?
for choice in check_choices: if self.config.doc_to_choice is not None:
choice_has_whitespace = True if choice.startswith(" ") else False for choice in check_choices:
delimiter_has_whitespace = ( choice_has_whitespace = True if choice[0].isspace() else False
True if self.config.target_delimiter.startswith(" ") else False delimiter_has_whitespace = (
) True if self.config.target_delimiter[-1].isspace() else False
if delimiter_has_whitespace and choice_has_whitespace:
eval_logger.warning(
f'Both target_delimiter and target choice: "{choice}" have whitespace'
)
elif (not delimiter_has_whitespace) and (not choice_has_whitespace):
eval_logger.warning(
f'Both target_delimiter and target choice: "{choice}" does not have whitespace, ignore if the language you are evaluating on does not require/use whitespace'
) )
if delimiter_has_whitespace and choice_has_whitespace:
eval_logger.warning(
f'Both target_delimiter and target choice: "{choice}" have whitespace'
)
elif (not delimiter_has_whitespace) and (not choice_has_whitespace):
eval_logger.warning(
f'Both target_delimiter and target choice: "{choice}" does not have whitespace, ignore if the language you are evaluating on does not require/use whitespace'
)
def download(self, dataset_kwargs=None) -> None: def download(self, dataset_kwargs=None) -> None:
self.dataset = datasets.load_dataset( self.dataset = datasets.load_dataset(
path=self.DATASET_PATH, path=self.DATASET_PATH,
...@@ -1067,6 +1068,9 @@ class ConfigurableTask(Task): ...@@ -1067,6 +1068,9 @@ class ConfigurableTask(Task):
# it assumes that doc_to_target returns a number. # it assumes that doc_to_target returns a number.
choices = self.doc_to_choice(doc) choices = self.doc_to_choice(doc)
gold = choices[gold] gold = choices[gold]
# we expect multiple_targets to be a list.
elif self.multiple_target:
pass
else: else:
gold = str(gold) gold = str(gold)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment