Commit bf038375 authored by baberabb's avatar baberabb
Browse files

Refactor whitespace check and add handling for multiple_targets

parent a07d05f7
...@@ -674,11 +674,12 @@ class ConfigurableTask(Task): ...@@ -674,11 +674,12 @@ 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?
if self.config.doc_to_choice is not None:
for choice in check_choices: for choice in check_choices:
choice_has_whitespace = True if choice.startswith(" ") else False choice_has_whitespace = True if choice[0].isspace() else False
delimiter_has_whitespace = ( delimiter_has_whitespace = (
True if self.config.target_delimiter.startswith(" ") else False True if self.config.target_delimiter[-1].isspace() else False
) )
if delimiter_has_whitespace and choice_has_whitespace: if delimiter_has_whitespace and choice_has_whitespace:
...@@ -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