From 413810e2bf280f737322d9fcf39b524e546f2844 Mon Sep 17 00:00:00 2001 From: h Date: Fri, 17 Mar 2023 03:36:50 +0800 Subject: [PATCH] fix: Modify log location and regular expressions --- book_maker/translator/chatgptapi_translator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book_maker/translator/chatgptapi_translator.py b/book_maker/translator/chatgptapi_translator.py index c0e1625..14a03c0 100644 --- a/book_maker/translator/chatgptapi_translator.py +++ b/book_maker/translator/chatgptapi_translator.py @@ -86,7 +86,7 @@ class ChatGPTAPI(Base): t_text = choice.get("message").get("content").encode("utf8").decode() if choice["finish_reason"] == "length": - with open("long_text.txt", "a") as f: + with open("log/long_text.txt", "a") as f: print( f"""================================================== The total token is too long and cannot be completely translated\n @@ -245,5 +245,5 @@ The total token is too long and cannot be completely translated\n self.log_translation_mismatch(plist_len, result_list, new_str, sep, log_path) # del (num), num. sometime (num) will translated to num. - result_list = [re.sub(r"^(\(\d+\)|\d+\.)\s*", "", s) for s in result_list] + result_list = [re.sub(r"^(\(\d+\)|\d+\.|(\d+))\s*", "", s) for s in result_list] return result_list