mirror of
https://github.com/yihong0618/bilingual_book_maker.git
synced 2025-06-05 19:15:34 +00:00
parent
1b64fe0315
commit
bd7fd501e7
@ -270,10 +270,9 @@ class EPUBBookLoader(BaseBookLoader):
|
|||||||
for item in complete_book.get_items():
|
for item in complete_book.get_items():
|
||||||
if item.file_name != fixname:
|
if item.file_name != fixname:
|
||||||
new_book.add_item(item)
|
new_book.add_item(item)
|
||||||
|
if soup_complete:
|
||||||
complete_item.content = soup_complete.encode()
|
complete_item.content = soup_complete.encode()
|
||||||
|
|
||||||
# =================================================
|
|
||||||
index = self.process_item(
|
index = self.process_item(
|
||||||
complete_item,
|
complete_item,
|
||||||
index,
|
index,
|
||||||
@ -367,6 +366,7 @@ class EPUBBookLoader(BaseBookLoader):
|
|||||||
if self.is_test and index >= self.test_num:
|
if self.is_test and index >= self.test_num:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if soup:
|
||||||
item.content = soup.encode()
|
item.content = soup.encode()
|
||||||
new_book.add_item(item)
|
new_book.add_item(item)
|
||||||
|
|
||||||
@ -465,6 +465,7 @@ class EPUBBookLoader(BaseBookLoader):
|
|||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
# for save temp book
|
# for save temp book
|
||||||
|
if soup:
|
||||||
item.content = soup.encode()
|
item.content = soup.encode()
|
||||||
new_temp_book.add_item(item)
|
new_temp_book.add_item(item)
|
||||||
name, _ = os.path.splitext(self.epub_name)
|
name, _ = os.path.splitext(self.epub_name)
|
||||||
|
@ -113,7 +113,7 @@ class TXTBookLoader(BaseBookLoader):
|
|||||||
|
|
||||||
def _save_progress(self):
|
def _save_progress(self):
|
||||||
try:
|
try:
|
||||||
with open(self.bin_path, "w") as f:
|
with open(self.bin_path, "w", encoding="utf-8") as f:
|
||||||
f.write("\n".join(self.p_to_save))
|
f.write("\n".join(self.p_to_save))
|
||||||
except:
|
except:
|
||||||
raise Exception("can not save resume file")
|
raise Exception("can not save resume file")
|
||||||
|
@ -90,7 +90,7 @@ class ChatGPTAPI(Base):
|
|||||||
# work well or exception finish by length limit
|
# work well or exception finish by length limit
|
||||||
choice = completion["choices"][0]
|
choice = completion["choices"][0]
|
||||||
|
|
||||||
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("log/long_text.txt", "a") as f:
|
with open("log/long_text.txt", "a") as f:
|
||||||
@ -212,7 +212,6 @@ The total token is too long and cannot be completely translated\n
|
|||||||
print(result_list[i], file=f)
|
print(result_list[i], file=f)
|
||||||
print(file=f)
|
print(file=f)
|
||||||
print("=============================", file=f)
|
print("=============================", file=f)
|
||||||
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
|
|
||||||
|
|
||||||
print(
|
print(
|
||||||
f"bug: {plist_len} paragraphs of text translated into {len(result_list)} paragraphs",
|
f"bug: {plist_len} paragraphs of text translated into {len(result_list)} paragraphs",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user