Skip to content

Fix main.py#409

Open
JinWoong-Jung wants to merge 1 commit intoagwaBom:mainfrom
JinWoong-Jung:fix_main_py
Open

Fix main.py#409
JinWoong-Jung wants to merge 1 commit intoagwaBom:mainfrom
JinWoong-Jung:fix_main_py

Conversation

@JinWoong-Jung
Copy link
Copy Markdown

  1. path_to_file_list (5~6 lines)
    a. Changed code : lines = open(path, 'r').read().split('\n')
    b. Why it is wrong before :
The original used open(path, 'w') (write mode) and returned a non-existent variable lines, causing runtime errors and preventing file reading.

  2. Backslash escaping in process_file (13 line)
    a. Changed code : file = file.replace('', '\')
    b. Why it is wrong before
: The original file.replace('', '') did nothing, so backslashes were never escaped.

  3. Wrong variable processed in loop (28 line)
    a. Changed code : german_file = process_file(german_file)
    b. Why it is wrong before
: The original mistakenly processed german_file into english_file again, overwriting the English path and ignoring the German path.

  4. Incorrect JSON template keys (20 line)
    a. Changed code :
template_start = '{"English":"'
template_mid = '","German":"'
template_end = '"}'
    b. Why it is wrong before
: The original template used "German" twice, producing invalid or misleading JSON output.

  5. Corrected JSON concatenation order (30 line)
    a. Changed code : processed_file_list.append(template_start + english_file + template_mid + german_file + template_end)
    b. Why it is wrong before
: The original concatenated the template pieces in an incorrect order, generating malformed JSON strings.

  6. write_file_list file mode and writing logic (36~38 lines)
    a. Changed code :
with open(path, 'w') as f:
for file in file_list:
f.write(file + '\n')
    b. Why it is wrong before
: The original opened the file in read mode ('r') and wrote only '\n' without writing the actual strings.

  7. Incorrect function arguments in main (46~48 lines)
    a. Changed code :
english_file_list = path_to_file_list(english_path), german_file_list = path_to_file_list(german_path)
processed_file_list = train_file_list_to_json(english_file_list, german_file_list)
    b. Why it is wrong before
: The original incorrectly called train_file_list_to_json(german_path) using file paths instead of file lists, causing wrong behavior and mismatched inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant