From e5c2794c06fb07ede34be2422ef75879f5688027 Mon Sep 17 00:00:00 2001 From: Tomas Kucharik Date: Sun, 20 Feb 2022 21:34:12 +0100 Subject: [PATCH] removed load save functions --- squad_transform.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/squad_transform.py b/squad_transform.py index 358f563..d6410df 100644 --- a/squad_transform.py +++ b/squad_transform.py @@ -1,20 +1,9 @@ import json from dotenv import load_dotenv + from squad_utils import print_squad -def load(filename): - with open(filename, "r") as f: - squad = json.load(f) - - return squad - - -def save(filename, squad): - with open(filename, "w") as f: - json.dump(squad, f, indent=2) - - def sort_qas_by_answer_index(squad): for article in squad['data']: for paragraph in article['paragraphs']: @@ -83,11 +72,13 @@ def add_special_chars_to_paragraph(paragraph): if __name__ == "__main__": load_dotenv() - squad = load('./squad-test.json') + with open("./squad-test.json", "r") as f: + squad = json.load(f) sort_qas_by_answer_index(squad) transform_squad(squad) print_squad(squad) - save("./squad-test-translated.json", squad) + with open("./squad-test-translated.json", "w") as f: + json.dump(squad, f, indent=2)