示例#1
0
def prepare_multiple_choice_answer(answers_json):
    """ Normalize answers from a given answer json in the usual VQA format. """
    multiple_choice_answers = [
        ans_dict['multiple_choice_answer'] for ans_dict in answers_json
    ]
    for answer in multiple_choice_answers:
        yield [process_punctuation(answer)]
示例#2
0
def prepare_v7w_answers(answers_json, decoys_json):
    answers = []
    for ans, decoy in zip(answers_json, decoys_json):
        assert ans['qa_id'] == decoy[
            'qa_id'], 'inconsistent qa_id: {}, decoy_id: {}'.format(
                ans['qa_id'], decoy['qa_id'])
        answers.append(decoy['IoU_decoys'] + decoy['QoU_decoys'] +
                       [ans['answer']])

    answers = [[_a.lower().strip('.') for _a in a] for a in answers]
    for answer in answers:
        yield [process_punctuation(a) for a in answer]
示例#3
0
def prepare_answers(answers_json):
    answers = [[_a.lower().strip('.') for _a in a['multiple_choices']]
               for a in answers_json]
    for answer in answers:
        yield [process_punctuation(a) for a in answer]
示例#4
0
def prepare_questions(questions_json):
    questions = [q['question'] for q in questions_json]
    for question in questions:
        question = question.lower()[:-1]
        yield nltk.word_tokenize(process_punctuation(question))
示例#5
0
def prepare_choices(answers_json):
    answers = [
        a['IoU_decoys'] + a['QoU_decoys'] + [a['answer']] for a in answers_json
    ]
    for answer in answers:
        yield [process_punctuation(a.lower().strip('.')) for a in answer]
示例#6
0
def prepare_answers(answers_json):
    answers = [a['answer'] for a in answers_json]
    for answer in answers:
        yield [process_punctuation(answer.lower().strip('.'))]
示例#7
0
def prepare_questions(questions_json):
    """ Tokenize and normalize questions from a given question json in the usual VQA format. """
    questions = [q['question'] for q in questions_json]
    for question in questions:
        question = question.lower()[:-1]
        yield nltk.word_tokenize(process_punctuation(question))