"official/nlp/data/__init__.py" did not exist on "2c5c3f3534c8109fed69b6523dc1fe38950596d3"
Commit 9b20e2d0 authored by lintangsutawika's avatar lintangsutawika
Browse files

update choice process

parent 656c310e
......@@ -67,7 +67,7 @@ class TaskConfig(dict):
template_aliases: Union[str, list] = None
doc_to_text: Union[Callable, str] = None
doc_to_target: Union[Callable, str] = None
doc_to_choice: Union[Callable, str] = None
doc_to_choice: Union[Callable, str, dict, list] = None
gold_alias: Union[Callable, str] = None
use_prompt: str = None
description: str = ""
......@@ -317,11 +317,9 @@ class Task(abc.ABC):
def doc_to_choice(self, doc):
if self._config.doc_to_choice is None:
return ast.literal_eval(
utils.apply_template(
self._config.template_aliases + "{{answer_choices}}", doc
)
)
eval_logger.error("doc_to_choice was callsed but not set in config")
elif type(self._config.doc_to_choice) == list:
return self._config.doc_to_choice
elif type(self._config.doc_to_choice) == dict:
return list(self._config.doc_to_choice.values())
elif type(self._config.doc_to_choice) == str:
......@@ -761,7 +759,10 @@ class ConfigurableTask(Task):
if type(doc_to_target) == str:
if doc_to_target in self.features:
return doc[doc_to_target]
if self._config.doc_to_choice is not None:
return self.doc_to_choice(doc)[doc[doc_to_target]]
else:
return doc[doc_to_target]
else:
return utils.apply_template(doc_to_target, doc)
elif callable(doc_to_target):
......
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