mirror of
https://github.com/yihong0618/bilingual_book_maker.git
synced 2025-06-05 19:15:34 +00:00
chore: refactoring
This commit is contained in:
parent
cbe791f4f4
commit
0e2ed334f2
@ -399,12 +399,12 @@ class ChatGPTAPI(Base):
|
|||||||
print(f"Using model list {model_list}")
|
print(f"Using model list {model_list}")
|
||||||
self.model_list = cycle(model_list)
|
self.model_list = cycle(model_list)
|
||||||
|
|
||||||
def add_to_batch_translate_queue(self, book_index, text):
|
|
||||||
self.batch_text_list.append({"book_index": book_index, "text": text})
|
|
||||||
|
|
||||||
def batch_init(self, book_name):
|
def batch_init(self, book_name):
|
||||||
self.book_name = self.sanitize_book_name(book_name)
|
self.book_name = self.sanitize_book_name(book_name)
|
||||||
|
|
||||||
|
def add_to_batch_translate_queue(self, book_index, text):
|
||||||
|
self.batch_text_list.append({"book_index": book_index, "text": text})
|
||||||
|
|
||||||
def sanitize_book_name(self, book_name):
|
def sanitize_book_name(self, book_name):
|
||||||
# Replace any characters that are not alphanumeric, underscore, hyphen, or dot with an underscore
|
# Replace any characters that are not alphanumeric, underscore, hyphen, or dot with an underscore
|
||||||
sanitized_book_name = re.sub(r"[^\w\-_\.]", "_", book_name)
|
sanitized_book_name = re.sub(r"[^\w\-_\.]", "_", book_name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user