Skip to content

Commit

Permalink
keep translation only
Browse files Browse the repository at this point in the history
  • Loading branch information
liyuankui authored Mar 6, 2023
1 parent 1a55633 commit 12d42be
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions make_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ def make_bilingual_book(self):
new_p.string = self.translate_model.translate(p.text)
self.p_to_save.append(new_p.text)
p.insert_after(new_p)
if (TRANSLATION_ONLY):
p.extract()
index += 1
if IS_TEST and index > TEST_NUM:
break
Expand Down Expand Up @@ -275,6 +277,12 @@ def save_progress(self):
default="zh-hans",
help="language to translate to",
)
parser.add_argument(
"--translation-only",
dest="translation_only",
action="store_false",
help="remove original paragraphs, and keep translation only",
)
parser.add_argument(
"--resume",
dest="resume",
Expand Down Expand Up @@ -308,6 +316,7 @@ def save_progress(self):

OPENAI_API_KEY = options.openai_key or env.get("OPENAI_API_KEY")
RESUME = options.resume
TRANSLATION_ONLY = options.translation_only
if not OPENAI_API_KEY:
raise Exception("Need openai API key, please google how to")
if not options.book_name.endswith(".epub"):
Expand Down

0 comments on commit 12d42be

Please sign in to comment.