text_plain_output_5.png text_plain_output_9.png text_plain_output_4.png text_plain_output_6.png text_plain_output_8.png text_plain_output_2.png text_plain_output_1.png
import json

task_id = 2

import json
with open(f'../input/covid19seedsentences/{task_id}.json') as in_fp:
    seed_sentences_json = json.load(in_fp)

bart_summarizer = BartSummarizer()

with open(f'../input/covid19seedsentences/{task_id}_relevant_sentences.json') as in_fp:
    relevant_sentences_json = json.load(in_fp)

answers_results = []
for idx, sub_task_json in enumerate(relevant_sentences_json['subTasks']):
    sub_task_description = sub_task_json['sub_task_description']
    print(f'Working on task: {sub_task_description}')
    best_sentences = seed_sentences_json['subTasks'][idx]['bestSentences']
    relevant_sentences = sub_task_json['relevant_sentences']
    relevant_sentences_texts = [result['sentence'] for result in relevant_sentences]
    sub_task_summary = bart_summarizer.create_summary(' '.join(best_sentences + relevant_sentences_texts))
    answers_results.append(dict(sub_task_description=sub_task_description, relevant_sentences=relevant_sentences, sub_task_summary=sub_task_summary))