From 61c078f9845d93aa4f55eb21e6d1873ceb745da0 Mon Sep 17 00:00:00 2001 From: Napbad <98138652+Napbad@users.noreply.github.com> Date: Fri, 27 Dec 2024 23:43:55 +0800 Subject: [PATCH] Update step5_splitforsub.py, fix bugs: "arrays must have the same length" --- core/step5_splitforsub.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/step5_splitforsub.py b/core/step5_splitforsub.py index 2e8e8f9..c203688 100644 --- a/core/step5_splitforsub.py +++ b/core/step5_splitforsub.py @@ -127,6 +127,13 @@ def split_for_sub_main(): src = split_src trans = split_trans + # Make sure that the src and the remerged have the same length + # 确保二者有相同的长度,防止报错 + if len(src) > len(remerged): + remerged += [None] * (len(src) - len(remerged)) + elif len(remerged) > len(src): + src += [None] * (len(remerged) - len(src)) + pd.DataFrame({'Source': split_src, 'Translation': split_trans}).to_excel(OUTPUT_SPLIT_FILE, index=False) pd.DataFrame({'Source': src, 'Translation': remerged}).to_excel(OUTPUT_REMERGED_FILE, index=False)