mirror of
https://github.com/yihong0618/bilingual_book_maker.git
synced 2025-06-04 02:20:18 +00:00
fix: use test instead of string
This commit is contained in:
parent
cd8ac84fa8
commit
0442b12094
@ -23,12 +23,12 @@ Make bilingual epub books Using AI translate
|
|||||||
e.g.
|
e.g.
|
||||||
```shell
|
```shell
|
||||||
# 如果你想快速测一下
|
# 如果你想快速测一下
|
||||||
python3 make.py - --book_name animal_farm.epub --openai_key ${openai_key} --no_limit --test
|
python3 make.py - --book_name test_books/animal_farm.epub --openai_key ${openai_key} --no_limit --test
|
||||||
# or do it
|
# or do it
|
||||||
python3 make.py - --book_name animal_farm.epub --openai_key ${openai_key}
|
python3 make.py - --book_name test_books/animal_farm.epub --openai_key ${openai_key}
|
||||||
# or 用 gpt3 模型
|
# or 用 gpt3 模型
|
||||||
export OPENAI_API_KEY=${your_api_key}
|
export OPENAI_API_KEY=${your_api_key}
|
||||||
python3 make.py --book_name animal_farm.epub --model gpt3 --no_limit
|
python3 make.py --book_name test_books/animal_farm.epub --model gpt3 --no_limit
|
||||||
```
|
```
|
||||||
|
|
||||||
## 注意
|
## 注意
|
||||||
|
4
make.py
4
make.py
@ -139,11 +139,11 @@ class BEPUB:
|
|||||||
is_test_done = IS_TEST and index > 20
|
is_test_done = IS_TEST and index > 20
|
||||||
for p in p_list:
|
for p in p_list:
|
||||||
if not is_test_done:
|
if not is_test_done:
|
||||||
if p.string and not p.string.isdigit():
|
if p.text and not p.text.isdigit():
|
||||||
new_p = copy(p)
|
new_p = copy(p)
|
||||||
# TODO banch of p to translate then combine
|
# TODO banch of p to translate then combine
|
||||||
# PR welcome here
|
# PR welcome here
|
||||||
new_p.string = self.translate_model.translate(p.string)
|
new_p.string = self.translate_model.translate(p.text)
|
||||||
p.insert_after(new_p)
|
p.insert_after(new_p)
|
||||||
index += 1
|
index += 1
|
||||||
i.content = soup.prettify().encode()
|
i.content = soup.prettify().encode()
|
||||||
|
BIN
test_books/animal_farm_bilingual.epub
Normal file
BIN
test_books/animal_farm_bilingual.epub
Normal file
Binary file not shown.
BIN
test_books/lemo.epub
Normal file
BIN
test_books/lemo.epub
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user