From 02df98651e8e0c2522b4ae940f76cc4cb6115521 Mon Sep 17 00:00:00 2001 From: shreya Date: Fri, 1 Nov 2024 19:20:25 +0530 Subject: [PATCH] lowered the output directory name --- src/scribe_data/cli/get.py | 2 +- src/scribe_data/utils.py | 6 +++--- .../language_data_extraction/english/verbs/format_verbs.py | 3 ++- src/scribe_data/wikidata/query_data.py | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/scribe_data/cli/get.py b/src/scribe_data/cli/get.py index b45fc4779..c02908aab 100644 --- a/src/scribe_data/cli/get.py +++ b/src/scribe_data/cli/get.py @@ -169,7 +169,7 @@ def get_data( ): print(f"Updated data was saved in: {Path(output_dir).resolve()}.") - json_input_path = Path(output_dir) / f"{language.capitalize()}/{data_type}.json" + json_input_path = Path(output_dir) / f"{language}/{data_type}.json" # Proceed with conversion only if the output type is not JSON. if output_type != "json": diff --git a/src/scribe_data/utils.py b/src/scribe_data/utils.py index f0a16340e..5ce3639cb 100644 --- a/src/scribe_data/utils.py +++ b/src/scribe_data/utils.py @@ -279,7 +279,7 @@ def load_queried_data( tuple(Any, str) A tuple containing the loaded data and the path to the data file. """ - data_path = Path(file_path) / language / f"{data_type}.json" + data_path = Path(file_path) / language.lower() / f"{data_type}.json" with open(data_path, encoding="utf-8") as f: return json.load(f), data_path @@ -314,7 +314,7 @@ def export_formatted_data( None """ export_path = ( - Path(file_path) / language.capitalize() / f"{data_type.replace('-', '_')}.json" + Path(file_path) / language.lower() / f"{data_type.replace('-', '_')}.json" ) with open(export_path, "w", encoding="utf-8") as file: @@ -322,7 +322,7 @@ def export_formatted_data( file.write("\n") print( - f"Wrote file {language.capitalize()}/{data_type.replace('-', '_')}.json with {len(formatted_data):,} {data_type}." + f"Wrote file {language.lower()}/{data_type.replace('-', '_')}.json with {len(formatted_data):,} {data_type}." ) diff --git a/src/scribe_data/wikidata/language_data_extraction/english/verbs/format_verbs.py b/src/scribe_data/wikidata/language_data_extraction/english/verbs/format_verbs.py index b9983352a..3414ae077 100644 --- a/src/scribe_data/wikidata/language_data_extraction/english/verbs/format_verbs.py +++ b/src/scribe_data/wikidata/language_data_extraction/english/verbs/format_verbs.py @@ -25,9 +25,10 @@ from scribe_data.utils import export_formatted_data, load_queried_data -LANGUAGE = "English" +LANGUAGE = "english" DATA_TYPE = "verbs" + parser = argparse.ArgumentParser() parser.add_argument("--file-path") args = parser.parse_args() diff --git a/src/scribe_data/wikidata/query_data.py b/src/scribe_data/wikidata/query_data.py index b88dfc71e..54b70ee1c 100644 --- a/src/scribe_data/wikidata/query_data.py +++ b/src/scribe_data/wikidata/query_data.py @@ -154,7 +154,7 @@ def query_data( target_type = q.parent.name updated_path = output_dir[2:] if output_dir.startswith("./") else output_dir - export_dir = Path(updated_path) / lang.capitalize() + export_dir = Path(updated_path) / lang export_dir.mkdir(parents=True, exist_ok=True) file_name = f"{target_type}.json"