INNER CODE UNIT · Python
generate_qg_inputs
AMontgomerie/question_generator · questiongenerator.py:87
def generate_qg_inputs(self, text: str, answer_style: str) -> Tuple[List[str], List[str]]:
"""Given a text, returns a list of model inputs and a list of corresponding answers.
Model inputs take the form "answer_token <answer text> context_token <context text>" where
the answer is a string extracted from the text, and the context is the wider text surrounding
the context.
"""
VALID_ANSWER_STYLES = ["all", "sentences", "multiple_choice"]
if answer_style not in VALID_ANSWER_STYLES:
raise ValueError(
"Invalid answer style {}. Please choose from {}".format(
answer_style, VALID_ANSWER_STYLES
)
)
inputs = []
answers = []