From 8c45c6e019ac69eda00f2a4b8604c184583d748d Mon Sep 17 00:00:00 2001 From: denzen Date: Wed, 19 Nov 2025 19:31:03 +0900 Subject: [PATCH 1/2] Fixed lots of errors and missing code --- main.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index 0d1f17b..44a5eac 100644 --- a/main.py +++ b/main.py @@ -2,7 +2,7 @@ def path_to_file_list(path: str) -> List[str]: """Reads a file and returns a list of lines in the file""" - li = open(path, 'w') + lines = open(path, 'r').read().split('\n') return lines def train_file_list_to_json(english_file_list: List[str], german_file_list: List[str]) -> List[str]: @@ -10,14 +10,14 @@ def train_file_list_to_json(english_file_list: List[str], german_file_list: List # Preprocess unwanted characters def process_file(file): if '\\' in file: - file = file.replace('\\', '\\') + file = file.replace('\\', '\\\\') if '/' or '"' in file: file = file.replace('/', '\\/') file = file.replace('"', '\\"') return file # Template for json file - template_start = '{\"German\":\"' + template_start = '{\"English\":\"' template_mid = '\",\"German\":\"' template_end = '\"}' @@ -25,17 +25,17 @@ def process_file(file): processed_file_list = [] for english_file, german_file in zip(english_file_list, german_file_list): english_file = process_file(english_file) - english_file = process_file(german_file) + german_file = process_file(german_file) - processed_file_list.append(template_mid + english_file + template_start + german_file + template_start) + processed_file_list.append(template_start + english_file + template_mid + german_file + template_end) return processed_file_list def write_file_list(file_list: List[str], path: str) -> None: """Writes a list of strings to a file, each string on a new line""" - with open(path, 'r') as f: + with open(path, 'w') as f: for file in file_list: - f.write('\n') + f.write(file + '\n') if __name__ == "__main__": path = './' @@ -43,8 +43,8 @@ def write_file_list(file_list: List[str], path: str) -> None: english_path = './english.txt' english_file_list = path_to_file_list(english_path) - german_file_list = train_file_list_to_json(german_path) + german_file_list = path_to_file_list(german_path) - processed_file_list = path_to_file_list(english_file_list, german_file_list) + processed_file_list = train_file_list_to_json(english_file_list, german_file_list) write_file_list(processed_file_list, path+'concated.json') From 17877549348454e44302c622d2bb8b314d1224c9 Mon Sep 17 00:00:00 2001 From: denzenn Date: Fri, 28 Nov 2025 23:10:05 +0900 Subject: [PATCH 2/2] Add MIT License to the project --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3880dd4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 denzenn + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.