INNER CODE UNIT · Python
_get_ranked_qa_pairs
AMontgomerie/question_generator · questiongenerator.py:287
def _get_ranked_qa_pairs(
self, generated_questions: List[str], qg_answers: List[str], scores, num_questions: int = 10
) -> List[Mapping[str, str]]:
"""Ranks generated questions according to scores, and returns the top num_questions examples.
"""
if num_questions > len(scores):
num_questions = len(scores)
print((
f"\nWas only able to generate {num_questions} questions.",
"For more questions, please input a longer text.")
)
qa_list = []
for i in range(num_questions):
index = scores[i]
qa = {
"question": generated_questions[index].split("?")[0] + "?",