mirror of
https://github.com/yihong0618/bilingual_book_maker.git
synced 2025-06-05 19:15:34 +00:00
improve mult line in --accumulated_num
This commit is contained in:
parent
ba87d0aa97
commit
99bcaddff6
@ -198,6 +198,7 @@ The total token is too long and cannot be completely translated\n
|
|||||||
print(newlist[i], file=f)
|
print(newlist[i], file=f)
|
||||||
print(file=f)
|
print(file=f)
|
||||||
if i < len(result_list):
|
if i < len(result_list):
|
||||||
|
print("............................................", file=f)
|
||||||
print(result_list[i], file=f)
|
print(result_list[i], file=f)
|
||||||
print(file=f)
|
print(file=f)
|
||||||
print("=============================", file=f)
|
print("=============================", file=f)
|
||||||
@ -208,6 +209,34 @@ The total token is too long and cannot be completely translated\n
|
|||||||
)
|
)
|
||||||
print("continue")
|
print("continue")
|
||||||
|
|
||||||
|
def join_lines(self, text):
|
||||||
|
lines = text.split("\n")
|
||||||
|
new_lines = []
|
||||||
|
temp_line = []
|
||||||
|
|
||||||
|
# join
|
||||||
|
for line in lines:
|
||||||
|
if line.strip():
|
||||||
|
temp_line.append(line.strip())
|
||||||
|
else:
|
||||||
|
if temp_line:
|
||||||
|
new_lines.append(" ".join(temp_line))
|
||||||
|
temp_line = []
|
||||||
|
new_lines.append(line)
|
||||||
|
|
||||||
|
if temp_line:
|
||||||
|
new_lines.append(" ".join(temp_line))
|
||||||
|
|
||||||
|
text = "\n".join(new_lines)
|
||||||
|
|
||||||
|
# del ^M
|
||||||
|
text = text.replace("^M", "\r")
|
||||||
|
lines = text.split("\n")
|
||||||
|
filtered_lines = [line for line in lines if line.strip() != "\r"]
|
||||||
|
new_text = "\n".join(filtered_lines)
|
||||||
|
|
||||||
|
return new_text
|
||||||
|
|
||||||
def translate_list(self, plist):
|
def translate_list(self, plist):
|
||||||
sep = "\n\n\n\n\n"
|
sep = "\n\n\n\n\n"
|
||||||
# new_str = sep.join([item.text for item in plist])
|
# new_str = sep.join([item.text for item in plist])
|
||||||
@ -224,6 +253,8 @@ The total token is too long and cannot be completely translated\n
|
|||||||
if new_str.endswith(sep):
|
if new_str.endswith(sep):
|
||||||
new_str = new_str[: -len(sep)]
|
new_str = new_str[: -len(sep)]
|
||||||
|
|
||||||
|
new_str = self.join_lines(new_str)
|
||||||
|
|
||||||
plist_len = len(plist)
|
plist_len = len(plist)
|
||||||
|
|
||||||
print(f"plist len = {len(plist)}")
|
print(f"plist len = {len(plist)}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user