Skip to content

Commit

Permalink
fix: Modify log location and regular expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
hleft committed Mar 16, 2023
1 parent c28ae78 commit 413810e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions book_maker/translator/chatgptapi_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def get_translation(self, text):
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
Expand Down Expand Up @@ -245,5 +245,5 @@ def translate_list(self, plist):
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

0 comments on commit 413810e

Please sign in to comment.