Merge pull request #175 from yihong0618/fix

fix: Modify log location and regular expressions
This commit is contained in:
hleft 2023-03-17 03:48:04 +08:00 committed by GitHub
commit d6e978c03d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -86,7 +86,7 @@ class ChatGPTAPI(Base):
t_text = choice.get("message").get("content").encode("utf8").decode() t_text = choice.get("message").get("content").encode("utf8").decode()
if choice["finish_reason"] == "length": if choice["finish_reason"] == "length":
with open("long_text.txt", "a") as f: with open("log/long_text.txt", "a") as f:
print( print(
f"""================================================== f"""==================================================
The total token is too long and cannot be completely translated\n 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) self.log_translation_mismatch(plist_len, result_list, new_str, sep, log_path)
# del (num), num. sometime (num) will translated to num. # 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 return result_list