From 32260bb3a83bd1984c399bddd8f47853a34ce517 Mon Sep 17 00:00:00 2001 From: AnirudhG07 Date: Thu, 5 Dec 2024 21:28:28 +0530 Subject: [PATCH 1/2] humaneval jsonl support --- translation/dump.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/translation/dump.py b/translation/dump.py index a3abad4..ad2367d 100644 --- a/translation/dump.py +++ b/translation/dump.py @@ -1,4 +1,5 @@ import json +import os def extract_prompt_from_file(file_path): @@ -11,8 +12,9 @@ def extract_prompt_from_file(file_path): def hinglish_json(): # File path to the JSON file - file_path = "../HumanEval.json" - with open(file_path, "r") as json_file: + base_dir = os.path.dirname(__file__) + path_humaneval = os.path.join(base_dir, "HumanEval.jsonl") + with open(path_humaneval, "r") as json_file: data = json.load(json_file) # modify the data with the hinglish prompts From 65133cde7c327274121150f137d9bc2859e71062 Mon Sep 17 00:00:00 2001 From: AnirudhG07 Date: Thu, 5 Dec 2024 23:53:24 +0530 Subject: [PATCH 2/2] edits for jsonl --- translation/dump.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/translation/dump.py b/translation/dump.py index ad2367d..b1dc56b 100644 --- a/translation/dump.py +++ b/translation/dump.py @@ -14,8 +14,8 @@ def hinglish_json(): # File path to the JSON file base_dir = os.path.dirname(__file__) path_humaneval = os.path.join(base_dir, "HumanEval.jsonl") - with open(path_humaneval, "r") as json_file: - data = json.load(json_file) + with open(path_humaneval, "r") as jsonl_file: + data = [json.loads(line) for line in jsonl_file.readlines()] # modify the data with the hinglish prompts new_data, index = [], 0 @@ -39,7 +39,7 @@ def hinglish_json(): new_data.append(item) # write the new data to the json file - with open("../HinglishEval.json", "w") as json_file: + with open(os.path.join(base_dir, "HinglishEval.json"), "w") as json_file: json.dump(data, json_file)