epub-translator 0.0.2__tar.gz → 0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {epub_translator-0.0.2 → epub_translator-0.0.3}/PKG-INFO +1 -1
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/translator.py +7 -5
- {epub_translator-0.0.2 → epub_translator-0.0.3}/pyproject.toml +1 -1
- {epub_translator-0.0.2 → epub_translator-0.0.3}/LICENSE +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/README.md +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/__init__.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/data/format.jinja +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/data/translate.jinja +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/epub/__init__.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/epub/content_parser.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/epub/html/__init__.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/epub/html/dom_operator.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/epub/html/empty_tags.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/epub/html/file.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/epub/html/texts_searcher.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/llm/__init__.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/llm/error.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/llm/executor.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/llm/increasable.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/llm/node.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/template.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/translation/__init__.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/translation/chunk.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/translation/splitter.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/translation/store.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/translation/translation.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/translation/types.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/translation/utils.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/xml/__init__.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/xml/decoder.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/xml/encoder.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/xml/parser.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/xml/tag.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/xml/transform.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/xml/utils.py +0 -0
- {epub_translator-0.0.2 → epub_translator-0.0.3}/epub_translator/zip_context.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: epub-translator
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: Translate the epub book using LLM. The translated book will retain the original text and list the translated text side by side with the original text.
|
|
5
5
|
License: MIT
|
|
6
6
|
Keywords: epub,llm,translation,translator
|
|
@@ -63,6 +63,7 @@ class _Translator:
|
|
|
63
63
|
try:
|
|
64
64
|
temp_dir = _clean_path(working_path / "temp")
|
|
65
65
|
temp_dir.mkdir(parents=True, exist_ok=True)
|
|
66
|
+
cache_path = working_path / "cache"
|
|
66
67
|
|
|
67
68
|
context = ZipContext(
|
|
68
69
|
epub_path=Path(source_path),
|
|
@@ -70,11 +71,12 @@ class _Translator:
|
|
|
70
71
|
)
|
|
71
72
|
context.replace_ncx(lambda texts: self._translate_ncx(
|
|
72
73
|
texts=texts,
|
|
74
|
+
cache_path=cache_path,
|
|
73
75
|
report_progress=lambda p: self._report_progress(p * 0.1)),
|
|
74
76
|
)
|
|
75
77
|
self._translate_spine(
|
|
76
78
|
context=context,
|
|
77
|
-
|
|
79
|
+
cache_path=cache_path,
|
|
78
80
|
report_progress=lambda p: self._report_progress(0.1 + p * 0.8),
|
|
79
81
|
)
|
|
80
82
|
context.archive(translated_path)
|
|
@@ -84,10 +86,10 @@ class _Translator:
|
|
|
84
86
|
if is_temp_workspace:
|
|
85
87
|
rmtree(working_path, ignore_errors=True)
|
|
86
88
|
|
|
87
|
-
def _translate_ncx(self, texts: list[str], report_progress: ProgressReporter) -> list[str]:
|
|
89
|
+
def _translate_ncx(self, texts: list[str], cache_path: Path, report_progress: ProgressReporter) -> list[str]:
|
|
88
90
|
return list(_translate(
|
|
89
91
|
llm=self._llm,
|
|
90
|
-
cache_path=
|
|
92
|
+
cache_path=cache_path,
|
|
91
93
|
max_chunk_tokens_count=self._max_chunk_tokens_count,
|
|
92
94
|
max_threads_count=1,
|
|
93
95
|
target_language=self._target_language,
|
|
@@ -103,7 +105,7 @@ class _Translator:
|
|
|
103
105
|
),
|
|
104
106
|
))
|
|
105
107
|
|
|
106
|
-
def _translate_spine(self, context: ZipContext,
|
|
108
|
+
def _translate_spine(self, context: ZipContext, cache_path: Path, report_progress: ProgressReporter):
|
|
107
109
|
spine_paths_iter = iter(list(context.search_spine_paths()))
|
|
108
110
|
spine_file: HTMLFile | None = None
|
|
109
111
|
translated_texts: list[str] = []
|
|
@@ -112,7 +114,7 @@ class _Translator:
|
|
|
112
114
|
for translated_text in _translate(
|
|
113
115
|
llm=self._llm,
|
|
114
116
|
gen_fragments_iter=lambda: _gen_fragments(context),
|
|
115
|
-
cache_path=
|
|
117
|
+
cache_path=cache_path,
|
|
116
118
|
max_chunk_tokens_count=self._max_chunk_tokens_count,
|
|
117
119
|
max_threads_count=self._max_threads_count,
|
|
118
120
|
target_language=self._target_language,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "epub-translator"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.3"
|
|
4
4
|
description = "Translate the epub book using LLM. The translated book will retain the original text and list the translated text side by side with the original text."
|
|
5
5
|
keywords=["epub", "llm", "translation", "translator"]
|
|
6
6
|
authors = [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|