epub-translator 0.0.6__py3-none-any.whl → 0.1.0__py3-none-any.whl

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.
Files changed (82) hide show
  1. epub_translator/__init__.py +3 -1
  2. epub_translator/data/fill.jinja +66 -0
  3. epub_translator/data/mmltex/README.md +67 -0
  4. epub_translator/data/mmltex/cmarkup.xsl +1106 -0
  5. epub_translator/data/mmltex/entities.xsl +459 -0
  6. epub_translator/data/mmltex/glayout.xsl +222 -0
  7. epub_translator/data/mmltex/mmltex.xsl +36 -0
  8. epub_translator/data/mmltex/scripts.xsl +375 -0
  9. epub_translator/data/mmltex/tables.xsl +130 -0
  10. epub_translator/data/mmltex/tokens.xsl +328 -0
  11. epub_translator/data/translate.jinja +15 -12
  12. epub_translator/epub/__init__.py +4 -2
  13. epub_translator/epub/common.py +43 -0
  14. epub_translator/epub/math.py +193 -0
  15. epub_translator/epub/placeholder.py +53 -0
  16. epub_translator/epub/spines.py +42 -0
  17. epub_translator/epub/toc.py +505 -0
  18. epub_translator/epub/zip.py +67 -0
  19. epub_translator/iter_sync.py +24 -0
  20. epub_translator/language.py +23 -0
  21. epub_translator/llm/__init__.py +2 -1
  22. epub_translator/llm/core.py +175 -0
  23. epub_translator/llm/error.py +38 -35
  24. epub_translator/llm/executor.py +159 -136
  25. epub_translator/llm/increasable.py +28 -28
  26. epub_translator/llm/types.py +17 -0
  27. epub_translator/serial/__init__.py +2 -0
  28. epub_translator/serial/chunk.py +52 -0
  29. epub_translator/serial/segment.py +17 -0
  30. epub_translator/serial/splitter.py +50 -0
  31. epub_translator/template.py +35 -33
  32. epub_translator/translator.py +205 -168
  33. epub_translator/utils.py +7 -0
  34. epub_translator/xml/__init__.py +4 -3
  35. epub_translator/xml/deduplication.py +38 -0
  36. epub_translator/xml/firendly/__init__.py +2 -0
  37. epub_translator/xml/firendly/decoder.py +75 -0
  38. epub_translator/xml/firendly/encoder.py +84 -0
  39. epub_translator/xml/firendly/parser.py +177 -0
  40. epub_translator/xml/firendly/tag.py +118 -0
  41. epub_translator/xml/firendly/transform.py +36 -0
  42. epub_translator/xml/xml.py +52 -0
  43. epub_translator/xml/xml_like.py +176 -0
  44. epub_translator/xml_translator/__init__.py +3 -0
  45. epub_translator/xml_translator/const.py +2 -0
  46. epub_translator/xml_translator/fill.py +128 -0
  47. epub_translator/xml_translator/format.py +282 -0
  48. epub_translator/xml_translator/fragmented.py +125 -0
  49. epub_translator/xml_translator/group.py +183 -0
  50. epub_translator/xml_translator/progressive_locking.py +256 -0
  51. epub_translator/xml_translator/submitter.py +102 -0
  52. epub_translator/xml_translator/text_segment.py +263 -0
  53. epub_translator/xml_translator/translator.py +178 -0
  54. epub_translator/xml_translator/utils.py +29 -0
  55. epub_translator-0.1.0.dist-info/METADATA +283 -0
  56. epub_translator-0.1.0.dist-info/RECORD +58 -0
  57. epub_translator/data/format.jinja +0 -33
  58. epub_translator/epub/content_parser.py +0 -162
  59. epub_translator/epub/html/__init__.py +0 -1
  60. epub_translator/epub/html/dom_operator.py +0 -62
  61. epub_translator/epub/html/empty_tags.py +0 -23
  62. epub_translator/epub/html/file.py +0 -80
  63. epub_translator/epub/html/texts_searcher.py +0 -46
  64. epub_translator/llm/node.py +0 -201
  65. epub_translator/translation/__init__.py +0 -2
  66. epub_translator/translation/chunk.py +0 -118
  67. epub_translator/translation/splitter.py +0 -78
  68. epub_translator/translation/store.py +0 -36
  69. epub_translator/translation/translation.py +0 -231
  70. epub_translator/translation/types.py +0 -45
  71. epub_translator/translation/utils.py +0 -11
  72. epub_translator/xml/decoder.py +0 -71
  73. epub_translator/xml/encoder.py +0 -95
  74. epub_translator/xml/parser.py +0 -172
  75. epub_translator/xml/tag.py +0 -93
  76. epub_translator/xml/transform.py +0 -34
  77. epub_translator/xml/utils.py +0 -12
  78. epub_translator/zip_context.py +0 -74
  79. epub_translator-0.0.6.dist-info/METADATA +0 -170
  80. epub_translator-0.0.6.dist-info/RECORD +0 -36
  81. {epub_translator-0.0.6.dist-info → epub_translator-0.1.0.dist-info}/LICENSE +0 -0
  82. {epub_translator-0.0.6.dist-info → epub_translator-0.1.0.dist-info}/WHEEL +0 -0
@@ -1,3 +1,5 @@
1
+ from . import language
1
2
  from .llm import LLM
2
3
  from .translator import translate
3
- from .translation import Language, ProgressReporter
4
+
5
+ __all__ = ["LLM", "translate", "language"]
@@ -0,0 +1,66 @@
1
+ You must fill translated text into XML template while preserving ALL tag structure.
2
+
3
+ CRITICAL: Every tag with id="X" in XML template MUST appear in your output.
4
+
5
+ ---
6
+
7
+ INPUT FORMAT:
8
+
9
+ You will receive:
10
+ 1. Source text (original language)
11
+ 2. XML template (with id attributes and structure)
12
+ 3. Translated text (target language)
13
+
14
+ Your task: Map the translated text back into the XML structure by comparing with source text.
15
+
16
+ ---
17
+
18
+ CRITICAL RULE - Tags with NO tail:
19
+
20
+ When a tag has NO text after its closing tag in XML template:
21
+ → Put ALL remaining text INSIDE that tag
22
+
23
+ EXAMPLE (MOST COMMON ERROR):
24
+
25
+ XML template:
26
+ ```xml
27
+ <a id="1">
28
+ <span id="2">4</span>
29
+ The methodology of
30
+ <span id="3">Robotics</span>
31
+ </a>
32
+ ```
33
+
34
+ Source: "4 The methodology of Robotics"
35
+ Translated: "4 机器人学的方法论"
36
+
37
+ ANALYSIS:
38
+ - <span id="3"> has NO text after </span> (the </a> comes immediately)
39
+ - So ALL remaining text after id="2" must go into id="3"
40
+
41
+ CORRECT output:
42
+ ```xml
43
+ <a id="1">
44
+ <span id="2">4</span>
45
+
46
+ <span id="3">机器人学的方法论</span>
47
+ </a>
48
+ ```
49
+
50
+ WRONG outputs:
51
+ ❌ <a id="1"><span id="2">4</span> 机器人学的方法论</a>
52
+ (Missing id="3" completely!)
53
+
54
+ ❌ <a id="1"><span id="2">4</span> <span id="3">机器人学</span>的方法论</a>
55
+ (Added tail "的方法论" to id="3", but source has no tail!)
56
+
57
+ ---
58
+
59
+ OUTPUT FORMAT:
60
+ ```xml
61
+ <xml>
62
+ ... your output ...
63
+ </xml>
64
+ ```
65
+
66
+ Begin.
@@ -0,0 +1,67 @@
1
+ # XSLT MathML Library
2
+
3
+ This directory contains XSLT stylesheets from the **XSLT MathML Library 2.1.2**, a set of XSLT stylesheets to transform MathML 2.0 to LaTeX.
4
+
5
+ **Note**: These files are included for reference purposes. Our project uses a custom Python implementation to convert MathML to LaTeX, but we keep these XSLT files as a reference for understanding MathML element mappings and conversion rules.
6
+
7
+ ## File Manifest
8
+
9
+ - `mmltex.xsl` - Main stylesheet
10
+ - `tokens.xsl` - Token elements (mi, mn, mo, etc.)
11
+ - `glayout.xsl` - Layout elements (mfrac, msqrt, etc.)
12
+ - `scripts.xsl` - Script elements (msub, msup, etc.)
13
+ - `tables.xsl` - Table elements (mtable, mtr, mtd)
14
+ - `entities.xsl` - Entity definitions
15
+ - `cmarkup.xsl` - Content markup elements
16
+
17
+ ## Original Project Information
18
+
19
+ **Original Author**: Vasil Yaroshevich
20
+
21
+ **Original Website**: http://www.raleigh.ru/MathML/mmltex/
22
+
23
+ **Archived Links**:
24
+ - Sourceforge Project: https://sourceforge.net/projects/xsltml/files/xsltml/
25
+ - Archived Documentation: https://web.archive.org/web/20160109063934/http://www.raleigh.ru/MathML/mmltex/index.php
26
+ - Google Translated (English): https://translate.google.com/translate?sl=ru&tl=en&u=https%3A%2F%2Fweb.archive.org%2Fweb%2F20160114170851%2Fhttp%3A%2F%2Fwww.raleigh.ru%2FMathML%2Fmmltex%2Findex.php
27
+
28
+ ---
29
+
30
+ ## Copyright
31
+
32
+ Copyright (C) 2001-2003 Vasil Yaroshevich
33
+
34
+ Permission is hereby granted, free of charge, to any person
35
+ obtaining a copy of this software and associated documentation
36
+ files (the "Software"), to deal in the Software without
37
+ restriction, including without limitation the rights to use,
38
+ copy, modify, merge, publish, distribute, sublicense, and/or
39
+ sell copies of the Software, and to permit persons to whom the
40
+ Software is furnished to do so, subject to the following
41
+ conditions:
42
+
43
+ The above copyright notice and this permission notice shall be
44
+ included in all copies or substantial portions of the Software.
45
+
46
+ Except as contained in this notice, the names of individuals
47
+ credited with contribution to this software shall not be used in
48
+ advertising or otherwise to promote the sale, use or other
49
+ dealings in this Software without prior written authorization
50
+ from the individuals in question.
51
+
52
+ Any stylesheet derived from this Software that is publically
53
+ distributed will be identified with a different name and the
54
+ version strings in any derived Software will be changed so that
55
+ no possibility of confusion between the derived package and this
56
+ Software will exist.
57
+
58
+ ## Warranty
59
+
60
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
61
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
62
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
63
+ NONINFRINGEMENT. IN NO EVENT SHALL NORMAN WALSH OR ANY OTHER
64
+ CONTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
65
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
66
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
67
+ OTHER DEALINGS IN THE SOFTWARE.