BabelDOC 0.3.4__tar.gz → 0.3.6__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.
- babeldoc-0.3.6/.github/ISSUE_TEMPLATE/bug_report.yaml +86 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/.github/ISSUE_TEMPLATE/feature_request.yaml +17 -9
- babeldoc-0.3.6/.github/PULL_REQUEST_TEMPLATE/pr_form.yml +92 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/PKG-INFO +5 -1
- {babeldoc-0.3.4 → babeldoc-0.3.6}/README.md +4 -0
- babeldoc-0.3.6/babeldoc/__init__.py +1 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/assets/embedding_assets_metadata.py +207 -2
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/const.py +1 -1
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/frontend/il_creater.py +21 -1
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/midend/il_translator.py +2 -2
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/midend/styles_and_formulas.py +2 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/midend/typesetting.py +17 -1
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/utils/fontmap.py +12 -5
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/high_level.py +3 -1
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/main.py +1 -1
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/translation_config.py +4 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/pyproject.toml +2 -2
- {babeldoc-0.3.4 → babeldoc-0.3.6}/uv.lock +324 -318
- babeldoc-0.3.4/.github/ISSUE_TEMPLATE/bug_report.yaml +0 -85
- babeldoc-0.3.4/babeldoc/__init__.py +0 -1
- {babeldoc-0.3.4 → babeldoc-0.3.6}/.cursorignore +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/.github/dependabot.yml +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/.github/labels.yml +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/.github/release-drafter.yml +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/.github/workflows/codeql.yml +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/.github/workflows/docs.yml +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/.github/workflows/labeler.yml +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/.github/workflows/publish-to-pypi.yml +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/.github/workflows/test.yml +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/.gitignore +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/.pre-commit-config.yaml +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/LICENSE +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/assets/assets.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/asynchronize/__init__.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/converter.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/__init__.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/babeldoc_exception/BabelDOCException.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/backend/__init__.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/backend/pdf_creater.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/frontend/__init__.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/il_version_1.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/il_version_1.rnc +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/il_version_1.rng +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/il_version_1.xsd +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/midend/__init__.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/midend/add_debug_information.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/midend/detect_scanned_file.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/midend/il_translator_llm_only.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/midend/layout_parser.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/midend/paragraph_finder.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/midend/remove_descent.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/midend/table_parser.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/translator/__init__.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/translator/cache.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/translator/translator.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/utils/atomic_integer.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/utils/layout_helper.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/utils/priority_thread_pool_executor.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/utils/style_helper.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/document_il/xml_converter.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/docvision/README.md +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/docvision/__init__.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/docvision/doclayout.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/docvision/rpc_doclayout.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/docvision/table_detection/rapidocr.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/pdfinterp.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/progress_monitor.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/result_merger.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/split_manager.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/tools/generate_font_metadata.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/babeldoc/tools/italic_assistance.py +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/CODE_OF_CONDUCT.md +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/CONTRIBUTING.md +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/CONTRIBUTOR_REWARD.md +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/ImplementationDetails/AsyncTranslate/AsyncTranslate.md +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/ImplementationDetails/ILTranslator/ILTranslator.md +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/ImplementationDetails/PDFCreation/PDFCreation.md +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/ImplementationDetails/PDFParsing/PDFParsing.md +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/ImplementationDetails/ParagraphFinding/ParagraphFinding.md +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/ImplementationDetails/README.md +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/ImplementationDetails/StylesAndFormulas/StylesAndFormulas.md +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/ImplementationDetails/Typesetting/Typesetting.md +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/README.md +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/deploy.sh +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/images/babeldoc-banner.png +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/images/babeldoc-big-logo-darkmode-with-transparent-background.png +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/images/babeldoc-big-logo-darkmode-with-transparent-background.svg +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/images/babeldoc-big-logo-with-transparent-background.png +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/images/babeldoc-big-logo-with-transparent-background.svg +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/images/babeldoc-big-logo.png +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/images/babeldoc-contributor_reward_example.png +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/images/babeldoc-preview.gif +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/images/babeldoc-small-logo-with-transparent-background.png +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/images/babeldoc-small-logo-with-transparent-background.svg +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/images/babeldoc-small-logo.png +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/index.md +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/intro-to-pdf-object.md +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/docs/requirements.txt +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/mkdocs.yml +0 -0
- {babeldoc-0.3.4 → babeldoc-0.3.6}/tests/test_translation_config.py +0 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
name: "🐞 Bug Report"
|
|
2
|
+
description: Create a report to help us improve
|
|
3
|
+
labels: ['bug']
|
|
4
|
+
body:
|
|
5
|
+
- type: checkboxes
|
|
6
|
+
id: checks
|
|
7
|
+
attributes:
|
|
8
|
+
label: Before you submit
|
|
9
|
+
options:
|
|
10
|
+
- label: I have searched existing issues
|
|
11
|
+
required: true
|
|
12
|
+
- label: I spent at least 5 minutes investigating and preparing this report
|
|
13
|
+
required: true
|
|
14
|
+
- label: I confirmed this is not caused by a network issue
|
|
15
|
+
required: true
|
|
16
|
+
|
|
17
|
+
- type: markdown
|
|
18
|
+
attributes:
|
|
19
|
+
value: |
|
|
20
|
+
Thank you for using **BabelDOC** and helping us improve it! 🙏
|
|
21
|
+
|
|
22
|
+
- type: textarea
|
|
23
|
+
id: environment
|
|
24
|
+
attributes:
|
|
25
|
+
label: Environment
|
|
26
|
+
description: Provide your system details (required)
|
|
27
|
+
value: |
|
|
28
|
+
- OS:
|
|
29
|
+
- Python:
|
|
30
|
+
- BabelDOC:
|
|
31
|
+
render: markdown
|
|
32
|
+
validations:
|
|
33
|
+
required: true
|
|
34
|
+
|
|
35
|
+
- type: textarea
|
|
36
|
+
id: describe
|
|
37
|
+
attributes:
|
|
38
|
+
label: Describe the bug
|
|
39
|
+
description: A clear and concise description of what the bug is.
|
|
40
|
+
validations:
|
|
41
|
+
required: true
|
|
42
|
+
|
|
43
|
+
- type: textarea
|
|
44
|
+
id: reproduce
|
|
45
|
+
attributes:
|
|
46
|
+
label: Steps to Reproduce
|
|
47
|
+
description: Help us reproduce the issue
|
|
48
|
+
value: |
|
|
49
|
+
1. Go to '...'
|
|
50
|
+
2. Click on '...'
|
|
51
|
+
3. See error
|
|
52
|
+
validations:
|
|
53
|
+
required: false
|
|
54
|
+
|
|
55
|
+
- type: textarea
|
|
56
|
+
id: expected
|
|
57
|
+
attributes:
|
|
58
|
+
label: Expected Behavior
|
|
59
|
+
description: What did you expect to happen?
|
|
60
|
+
validations:
|
|
61
|
+
required: false
|
|
62
|
+
|
|
63
|
+
- type: textarea
|
|
64
|
+
id: logs
|
|
65
|
+
attributes:
|
|
66
|
+
label: Relevant Log Output or Screenshots
|
|
67
|
+
description: Copy and paste any logs or attach screenshots. This will be formatted automatically.
|
|
68
|
+
render: text
|
|
69
|
+
validations:
|
|
70
|
+
required: false
|
|
71
|
+
|
|
72
|
+
- type: file
|
|
73
|
+
id: pdf
|
|
74
|
+
attributes:
|
|
75
|
+
label: Original PDF File
|
|
76
|
+
description: Upload the input PDF if applicable.
|
|
77
|
+
validations:
|
|
78
|
+
required: false
|
|
79
|
+
|
|
80
|
+
- type: textarea
|
|
81
|
+
id: others
|
|
82
|
+
attributes:
|
|
83
|
+
label: Additional Context
|
|
84
|
+
description: Anything else we should know?
|
|
85
|
+
validations:
|
|
86
|
+
required: false
|
|
@@ -1,33 +1,41 @@
|
|
|
1
|
-
name: Feature
|
|
2
|
-
description: Suggest
|
|
1
|
+
name: "✨ Feature Request"
|
|
2
|
+
description: Suggest a new idea or improvement for BabelDOC
|
|
3
3
|
labels: ['enhancement']
|
|
4
4
|
body:
|
|
5
|
+
- type: markdown
|
|
6
|
+
attributes:
|
|
7
|
+
value: |
|
|
8
|
+
Thank you for helping improve **BabelDOC**! Please fill out the form below to suggest a feature.
|
|
9
|
+
|
|
5
10
|
- type: textarea
|
|
6
11
|
id: describe
|
|
7
12
|
attributes:
|
|
8
13
|
label: Is your feature request related to a problem?
|
|
9
|
-
description:
|
|
14
|
+
description: If applicable, describe what problem this feature would solve.
|
|
10
15
|
placeholder: Ex. I'm always frustrated when ...
|
|
11
16
|
validations:
|
|
12
17
|
required: false
|
|
18
|
+
|
|
13
19
|
- type: textarea
|
|
14
20
|
id: solution
|
|
15
21
|
attributes:
|
|
16
22
|
label: Describe the solution you'd like
|
|
17
|
-
description:
|
|
23
|
+
description: What would you like to see happen?
|
|
18
24
|
validations:
|
|
19
|
-
required:
|
|
25
|
+
required: true
|
|
26
|
+
|
|
20
27
|
- type: textarea
|
|
21
|
-
id:
|
|
28
|
+
id: alternatives
|
|
22
29
|
attributes:
|
|
23
30
|
label: Describe alternatives you've considered
|
|
24
|
-
description:
|
|
31
|
+
description: Have you thought of other ways to solve this?
|
|
25
32
|
validations:
|
|
26
33
|
required: false
|
|
34
|
+
|
|
27
35
|
- type: textarea
|
|
28
36
|
id: additional
|
|
29
37
|
attributes:
|
|
30
38
|
label: Additional context
|
|
31
|
-
description:
|
|
39
|
+
description: Any other context, examples, or screenshots?
|
|
32
40
|
validations:
|
|
33
|
-
required: false
|
|
41
|
+
required: false
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
name: Pull Request
|
|
2
|
+
description: Submit a pull request to contribute to BabelDOC
|
|
3
|
+
title: "[PR] <Your concise title here>"
|
|
4
|
+
labels:
|
|
5
|
+
- needs triage
|
|
6
|
+
body:
|
|
7
|
+
- type: markdown
|
|
8
|
+
attributes:
|
|
9
|
+
value: |
|
|
10
|
+
## 👋 Thanks for contributing to **BabelDOC**!
|
|
11
|
+
|
|
12
|
+
Please fill out this form to help us review your pull request effectively.
|
|
13
|
+
|
|
14
|
+
- type: input
|
|
15
|
+
id: issue
|
|
16
|
+
attributes:
|
|
17
|
+
label: Related Issue(s)
|
|
18
|
+
description: If this pull request closes or is related to one or more issues, list them here (e.g., #37)
|
|
19
|
+
placeholder: "#37"
|
|
20
|
+
validations:
|
|
21
|
+
required: false
|
|
22
|
+
|
|
23
|
+
- type: textarea
|
|
24
|
+
id: summary
|
|
25
|
+
attributes:
|
|
26
|
+
label: Description
|
|
27
|
+
description: Describe the purpose of this pull request and what was changed.
|
|
28
|
+
placeholder: |
|
|
29
|
+
- What does this PR introduce or fix?
|
|
30
|
+
- What is the motivation behind it?
|
|
31
|
+
validations:
|
|
32
|
+
required: true
|
|
33
|
+
|
|
34
|
+
- type: dropdown
|
|
35
|
+
id: pr_type
|
|
36
|
+
attributes:
|
|
37
|
+
label: PR Type
|
|
38
|
+
description: What kind of change is this?
|
|
39
|
+
multiple: true
|
|
40
|
+
options:
|
|
41
|
+
- enhancement
|
|
42
|
+
- bug
|
|
43
|
+
- documentation
|
|
44
|
+
- refactor
|
|
45
|
+
- test
|
|
46
|
+
- chore
|
|
47
|
+
validations:
|
|
48
|
+
required: true
|
|
49
|
+
|
|
50
|
+
- type: checkboxes
|
|
51
|
+
id: checklist
|
|
52
|
+
attributes:
|
|
53
|
+
label: Contributor Checklist
|
|
54
|
+
options:
|
|
55
|
+
- label: I’ve read the **CONTRIBUTING.md** guide
|
|
56
|
+
required: true
|
|
57
|
+
- label: My changes follow the project’s code style and guidelines
|
|
58
|
+
required: true
|
|
59
|
+
- label: I’ve linked the related issue(s) in the description above
|
|
60
|
+
- label: I’ve updated relevant documentation (if applicable)
|
|
61
|
+
- label: I’ve added necessary tests (if applicable)
|
|
62
|
+
- label: All new and existing tests passed locally
|
|
63
|
+
- label: I understand that due to limited maintainer resources, only small pull requests are accepted. Suggestions with proof-of-concept patches are appreciated, and my patch may be rewritten if necessary.
|
|
64
|
+
|
|
65
|
+
- type: textarea
|
|
66
|
+
id: testing
|
|
67
|
+
attributes:
|
|
68
|
+
label: Testing Instructions
|
|
69
|
+
description: Provide step-by-step instructions on how to test your changes
|
|
70
|
+
placeholder: |
|
|
71
|
+
1. Run `...`
|
|
72
|
+
2. Visit `...`
|
|
73
|
+
3. Click `...`
|
|
74
|
+
4. Verify `...`
|
|
75
|
+
validations:
|
|
76
|
+
required: false
|
|
77
|
+
|
|
78
|
+
- type: textarea
|
|
79
|
+
id: screenshots
|
|
80
|
+
attributes:
|
|
81
|
+
label: Screenshots (if applicable)
|
|
82
|
+
description: If UI changes were made, please attach before/after screenshots.
|
|
83
|
+
validations:
|
|
84
|
+
required: false
|
|
85
|
+
|
|
86
|
+
- type: textarea
|
|
87
|
+
id: notes
|
|
88
|
+
attributes:
|
|
89
|
+
label: Additional Notes
|
|
90
|
+
description: Anything else the reviewer should know?
|
|
91
|
+
validations:
|
|
92
|
+
required: false
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: BabelDOC
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.6
|
|
4
4
|
Summary: Yet Another Document Translator
|
|
5
5
|
Project-URL: Homepage, https://github.com/funstory-ai/BabelDOC
|
|
6
6
|
Project-URL: Issues, https://github.com/funstory-ai/BabelDOC/issues
|
|
@@ -72,6 +72,9 @@ Description-Content-Type: text/markdown
|
|
|
72
72
|
<a href="https://t.me/+Z9_SgnxmsmA5NzBl">
|
|
73
73
|
<img src="https://img.shields.io/badge/Telegram-2CA5E0?style=flat-squeare&logo=telegram&logoColor=white"></a>
|
|
74
74
|
</p>
|
|
75
|
+
|
|
76
|
+
<a href="https://trendshift.io/repositories/13358" target="_blank"><img src="https://trendshift.io/api/badge/repositories/13358" alt="funstory-ai%2FBabelDOC | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
|
77
|
+
|
|
75
78
|
</div>
|
|
76
79
|
|
|
77
80
|
PDF scientific paper translation and bilingual comparison library.
|
|
@@ -211,6 +214,7 @@ uv run babeldoc --files example.pdf --files example2.pdf --openai --openai-model
|
|
|
211
214
|
> 1. Currently, only OpenAI-compatible LLM is supported. For more translator support, please use [PDFMathTranslate](https://github.com/Byaidu/PDFMathTranslate).
|
|
212
215
|
> 2. It is recommended to use models with strong compatibility with OpenAI, such as: `glm-4-flash`, `deepseek-chat`, etc.
|
|
213
216
|
> 3. Currently, it has not been optimized for traditional translation engines like Bing/Google, it is recommended to use LLMs.
|
|
217
|
+
> 4. You can use [litellm](https://github.com/BerriAI/litellm) to access multiple models.
|
|
214
218
|
|
|
215
219
|
### OpenAI Specific Options
|
|
216
220
|
|
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
<a href="https://t.me/+Z9_SgnxmsmA5NzBl">
|
|
27
27
|
<img src="https://img.shields.io/badge/Telegram-2CA5E0?style=flat-squeare&logo=telegram&logoColor=white"></a>
|
|
28
28
|
</p>
|
|
29
|
+
|
|
30
|
+
<a href="https://trendshift.io/repositories/13358" target="_blank"><img src="https://trendshift.io/api/badge/repositories/13358" alt="funstory-ai%2FBabelDOC | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
|
31
|
+
|
|
29
32
|
</div>
|
|
30
33
|
|
|
31
34
|
PDF scientific paper translation and bilingual comparison library.
|
|
@@ -165,6 +168,7 @@ uv run babeldoc --files example.pdf --files example2.pdf --openai --openai-model
|
|
|
165
168
|
> 1. Currently, only OpenAI-compatible LLM is supported. For more translator support, please use [PDFMathTranslate](https://github.com/Byaidu/PDFMathTranslate).
|
|
166
169
|
> 2. It is recommended to use models with strong compatibility with OpenAI, such as: `glm-4-flash`, `deepseek-chat`, etc.
|
|
167
170
|
> 3. Currently, it has not been optimized for traditional translation engines like Bing/Google, it is recommended to use LLMs.
|
|
171
|
+
> 4. You can use [litellm](https://github.com/BerriAI/litellm) to access multiple models.
|
|
168
172
|
|
|
169
173
|
### OpenAI Specific Options
|
|
170
174
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.6"
|
|
@@ -64,6 +64,19 @@ EMBEDDING_FONT_METADATA = {
|
|
|
64
64
|
"sha3_256": "4324a60d507c691e6efc97420647f4d2c2d86d9de35009d1c769861b76074ae6",
|
|
65
65
|
"size": 15515760,
|
|
66
66
|
},
|
|
67
|
+
"KleeOne-Regular.ttf": {
|
|
68
|
+
"ascent": 1160,
|
|
69
|
+
"bold": 0,
|
|
70
|
+
"descent": -288,
|
|
71
|
+
"encoding_length": 2,
|
|
72
|
+
"file_name": "KleeOne-Regular.ttf",
|
|
73
|
+
"font_name": "Klee One Regular",
|
|
74
|
+
"italic": 0,
|
|
75
|
+
"monospace": 0,
|
|
76
|
+
"serif": 1,
|
|
77
|
+
"sha3_256": "8585c29f89b322d937f83739f61ede5d84297873e1465cad9a120a208ac55ce0",
|
|
78
|
+
"size": 8724704,
|
|
79
|
+
},
|
|
67
80
|
"LXGWWenKaiGB-Regular.ttf": {
|
|
68
81
|
"ascent": 928,
|
|
69
82
|
"bold": 0,
|
|
@@ -103,6 +116,123 @@ EMBEDDING_FONT_METADATA = {
|
|
|
103
116
|
"sha3_256": "66ccd0ffe8e56cd585dabde8d1292c3f551b390d8ed85f81d7a844825f9c2379",
|
|
104
117
|
"size": 13100328,
|
|
105
118
|
},
|
|
119
|
+
"MaruBuri-Regular.ttf": {
|
|
120
|
+
"ascent": 800,
|
|
121
|
+
"bold": 0,
|
|
122
|
+
"descent": -200,
|
|
123
|
+
"encoding_length": 2,
|
|
124
|
+
"file_name": "MaruBuri-Regular.ttf",
|
|
125
|
+
"font_name": "MaruBuri Regular",
|
|
126
|
+
"italic": 0,
|
|
127
|
+
"monospace": 0,
|
|
128
|
+
"serif": 1,
|
|
129
|
+
"sha3_256": "abb672dde7b89e06914ce27c59159b7a2933f26207bfcc47981c67c11c41e6d1",
|
|
130
|
+
"size": 3268988,
|
|
131
|
+
},
|
|
132
|
+
"NotoSans-Bold.ttf": {
|
|
133
|
+
"ascent": 1069,
|
|
134
|
+
"bold": 1,
|
|
135
|
+
"descent": -293,
|
|
136
|
+
"encoding_length": 2,
|
|
137
|
+
"file_name": "NotoSans-Bold.ttf",
|
|
138
|
+
"font_name": "Noto Sans Bold",
|
|
139
|
+
"italic": 0,
|
|
140
|
+
"monospace": 0,
|
|
141
|
+
"serif": 1,
|
|
142
|
+
"sha3_256": "ecd38d472c1cad07d8a5dffd2b5a0f72edcd40fff2b4e68d770da8f2ef343a82",
|
|
143
|
+
"size": 630964,
|
|
144
|
+
},
|
|
145
|
+
"NotoSans-BoldItalic.ttf": {
|
|
146
|
+
"ascent": 1069,
|
|
147
|
+
"bold": 1,
|
|
148
|
+
"descent": -293,
|
|
149
|
+
"encoding_length": 2,
|
|
150
|
+
"file_name": "NotoSans-BoldItalic.ttf",
|
|
151
|
+
"font_name": "Noto Sans Bold Italic",
|
|
152
|
+
"italic": 1,
|
|
153
|
+
"monospace": 0,
|
|
154
|
+
"serif": 1,
|
|
155
|
+
"sha3_256": "0b6c690a4a6b7d605b2ecbde00c7ac1a23e60feb17fa30d8b972d61ec3ff732b",
|
|
156
|
+
"size": 644340,
|
|
157
|
+
},
|
|
158
|
+
"NotoSans-Italic.ttf": {
|
|
159
|
+
"ascent": 1069,
|
|
160
|
+
"bold": 0,
|
|
161
|
+
"descent": -293,
|
|
162
|
+
"encoding_length": 2,
|
|
163
|
+
"file_name": "NotoSans-Italic.ttf",
|
|
164
|
+
"font_name": "Noto Sans Italic",
|
|
165
|
+
"italic": 1,
|
|
166
|
+
"monospace": 0,
|
|
167
|
+
"serif": 1,
|
|
168
|
+
"sha3_256": "830652f61724c017e5a29a96225b484a2ccbd25f69a1b3f47e5f466a2dbed1ad",
|
|
169
|
+
"size": 642344,
|
|
170
|
+
},
|
|
171
|
+
"NotoSans-Regular.ttf": {
|
|
172
|
+
"ascent": 1069,
|
|
173
|
+
"bold": 0,
|
|
174
|
+
"descent": -293,
|
|
175
|
+
"encoding_length": 2,
|
|
176
|
+
"file_name": "NotoSans-Regular.ttf",
|
|
177
|
+
"font_name": "Noto Sans Regular",
|
|
178
|
+
"italic": 0,
|
|
179
|
+
"monospace": 0,
|
|
180
|
+
"serif": 1,
|
|
181
|
+
"sha3_256": "7dfe2bbf97dc04c852d1223b220b63430e6ad03b0dbb28ebe6328a20a2d45eb8",
|
|
182
|
+
"size": 629024,
|
|
183
|
+
},
|
|
184
|
+
"NotoSerif-Bold.ttf": {
|
|
185
|
+
"ascent": 1069,
|
|
186
|
+
"bold": 1,
|
|
187
|
+
"descent": -293,
|
|
188
|
+
"encoding_length": 2,
|
|
189
|
+
"file_name": "NotoSerif-Bold.ttf",
|
|
190
|
+
"font_name": "Noto Serif Bold",
|
|
191
|
+
"italic": 0,
|
|
192
|
+
"monospace": 0,
|
|
193
|
+
"serif": 1,
|
|
194
|
+
"sha3_256": "28d88d924285eadb9f9ce49f2d2b95473f89a307b226c5f6ebed87a654898312",
|
|
195
|
+
"size": 506864,
|
|
196
|
+
},
|
|
197
|
+
"NotoSerif-BoldItalic.ttf": {
|
|
198
|
+
"ascent": 1069,
|
|
199
|
+
"bold": 1,
|
|
200
|
+
"descent": -293,
|
|
201
|
+
"encoding_length": 2,
|
|
202
|
+
"file_name": "NotoSerif-BoldItalic.ttf",
|
|
203
|
+
"font_name": "Noto Serif Bold Italic",
|
|
204
|
+
"italic": 1,
|
|
205
|
+
"monospace": 0,
|
|
206
|
+
"serif": 1,
|
|
207
|
+
"sha3_256": "b69ee56af6351b2fb4fbce623f8e1c1f9fb19170686a9e5db2cf260b8cf24ac7",
|
|
208
|
+
"size": 535724,
|
|
209
|
+
},
|
|
210
|
+
"NotoSerif-Italic.ttf": {
|
|
211
|
+
"ascent": 1069,
|
|
212
|
+
"bold": 0,
|
|
213
|
+
"descent": -293,
|
|
214
|
+
"encoding_length": 2,
|
|
215
|
+
"file_name": "NotoSerif-Italic.ttf",
|
|
216
|
+
"font_name": "Noto Serif Italic",
|
|
217
|
+
"italic": 1,
|
|
218
|
+
"monospace": 0,
|
|
219
|
+
"serif": 1,
|
|
220
|
+
"sha3_256": "9b7773c24ab8a29e3c1c03efa4ab652d051e4c209134431953463aa946d62868",
|
|
221
|
+
"size": 535340,
|
|
222
|
+
},
|
|
223
|
+
"NotoSerif-Regular.ttf": {
|
|
224
|
+
"ascent": 1069,
|
|
225
|
+
"bold": 0,
|
|
226
|
+
"descent": -293,
|
|
227
|
+
"encoding_length": 2,
|
|
228
|
+
"file_name": "NotoSerif-Regular.ttf",
|
|
229
|
+
"font_name": "Noto Serif Regular",
|
|
230
|
+
"italic": 0,
|
|
231
|
+
"monospace": 0,
|
|
232
|
+
"serif": 1,
|
|
233
|
+
"sha3_256": "c2bbe984e65bafd3bcd38b3cb1e1344f3b7b79d6beffc7a3d883b57f8358559d",
|
|
234
|
+
"size": 504932,
|
|
235
|
+
},
|
|
106
236
|
"SourceHanSansCN-Bold.ttf": {
|
|
107
237
|
"ascent": 1160,
|
|
108
238
|
"bold": 1,
|
|
@@ -424,21 +554,96 @@ TW_FONT_FAMILY = {
|
|
|
424
554
|
"base": ["SourceHanSansCN-Regular.ttf"],
|
|
425
555
|
}
|
|
426
556
|
|
|
557
|
+
KR_FONT_FAMILY = {
|
|
558
|
+
"script": ["MaruBuri-Regular.ttf"],
|
|
559
|
+
"normal": [
|
|
560
|
+
"SourceHanSerifKR-Bold.ttf",
|
|
561
|
+
"SourceHanSerifKR-Regular.ttf",
|
|
562
|
+
"SourceHanSansKR-Bold.ttf",
|
|
563
|
+
"SourceHanSansKR-Regular.ttf",
|
|
564
|
+
"SourceHanSerifCN-Bold.ttf",
|
|
565
|
+
"SourceHanSerifCN-Regular.ttf",
|
|
566
|
+
"SourceHanSansCN-Bold.ttf",
|
|
567
|
+
"SourceHanSansCN-Regular.ttf",
|
|
568
|
+
],
|
|
569
|
+
"fallback": [
|
|
570
|
+
"GoNotoKurrent-Regular.ttf",
|
|
571
|
+
"GoNotoKurrent-Bold.ttf",
|
|
572
|
+
],
|
|
573
|
+
"base": ["SourceHanSansCN-Regular.ttf"],
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
JP_FONT_FAMILY = {
|
|
577
|
+
"script": ["KleeOne-Regular.ttf"],
|
|
578
|
+
"normal": [
|
|
579
|
+
"SourceHanSerifJP-Bold.ttf",
|
|
580
|
+
"SourceHanSerifJP-Regular.ttf",
|
|
581
|
+
"SourceHanSansJP-Bold.ttf",
|
|
582
|
+
"SourceHanSansJP-Regular.ttf",
|
|
583
|
+
"SourceHanSerifCN-Bold.ttf",
|
|
584
|
+
"SourceHanSerifCN-Regular.ttf",
|
|
585
|
+
"SourceHanSansCN-Bold.ttf",
|
|
586
|
+
"SourceHanSansCN-Regular.ttf",
|
|
587
|
+
],
|
|
588
|
+
"fallback": [
|
|
589
|
+
"GoNotoKurrent-Regular.ttf",
|
|
590
|
+
"GoNotoKurrent-Bold.ttf",
|
|
591
|
+
],
|
|
592
|
+
"base": ["SourceHanSansCN-Regular.ttf"],
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
EN_FONT_FAMILY = {
|
|
596
|
+
"script": [
|
|
597
|
+
"NotoSans-Italic.ttf",
|
|
598
|
+
"NotoSans-BoldItalic.ttf",
|
|
599
|
+
"NotoSerif-Italic.ttf",
|
|
600
|
+
"NotoSerif-BoldItalic.ttf",
|
|
601
|
+
],
|
|
602
|
+
"normal": [
|
|
603
|
+
"NotoSerif-Regular.ttf",
|
|
604
|
+
"NotoSerif-Bold.ttf",
|
|
605
|
+
"NotoSans-Regular.ttf",
|
|
606
|
+
"NotoSans-Bold.ttf",
|
|
607
|
+
"SourceHanSerifCN-Bold.ttf",
|
|
608
|
+
"SourceHanSerifCN-Regular.ttf",
|
|
609
|
+
"SourceHanSansCN-Bold.ttf",
|
|
610
|
+
"SourceHanSansCN-Regular.ttf",
|
|
611
|
+
],
|
|
612
|
+
"fallback": [
|
|
613
|
+
"GoNotoKurrent-Regular.ttf",
|
|
614
|
+
"GoNotoKurrent-Bold.ttf",
|
|
615
|
+
],
|
|
616
|
+
"base": [
|
|
617
|
+
"NotoSans-Regular.ttf",
|
|
618
|
+
],
|
|
619
|
+
}
|
|
620
|
+
|
|
427
621
|
ALL_FONT_FAMILY = {
|
|
428
622
|
"CN": CN_FONT_FAMILY,
|
|
429
623
|
"HK": HK_FONT_FAMILY,
|
|
430
624
|
"TW": TW_FONT_FAMILY,
|
|
625
|
+
"KR": KR_FONT_FAMILY,
|
|
626
|
+
"JP": JP_FONT_FAMILY,
|
|
627
|
+
"EN": EN_FONT_FAMILY,
|
|
431
628
|
}
|
|
432
629
|
|
|
433
630
|
|
|
434
631
|
def get_font_family(lang_code: str):
|
|
435
632
|
lang_code = lang_code.upper()
|
|
436
|
-
if "
|
|
633
|
+
if "KR" in lang_code:
|
|
634
|
+
font_family = KR_FONT_FAMILY
|
|
635
|
+
elif "JP" in lang_code:
|
|
636
|
+
font_family = JP_FONT_FAMILY
|
|
637
|
+
elif "HK" in lang_code:
|
|
437
638
|
font_family = HK_FONT_FAMILY
|
|
438
639
|
elif "TW" in lang_code:
|
|
439
640
|
font_family = TW_FONT_FAMILY
|
|
440
|
-
|
|
641
|
+
elif "EN" in lang_code:
|
|
642
|
+
font_family = EN_FONT_FAMILY
|
|
643
|
+
elif "CN" in lang_code:
|
|
441
644
|
font_family = CN_FONT_FAMILY
|
|
645
|
+
else:
|
|
646
|
+
font_family = EN_FONT_FAMILY
|
|
442
647
|
verify_font_family(font_family)
|
|
443
648
|
return font_family
|
|
444
649
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import base64
|
|
2
|
+
import functools
|
|
2
3
|
import logging
|
|
3
4
|
import re
|
|
4
5
|
from functools import wraps
|
|
@@ -180,6 +181,7 @@ class ILCreater:
|
|
|
180
181
|
self.xobj_stack = []
|
|
181
182
|
self.current_page_font_name_id_map = {}
|
|
182
183
|
self.current_page_font_char_bounding_box_map = {}
|
|
184
|
+
self.mupdf_font_map: dict[int, pymupdf.Font] = {}
|
|
183
185
|
|
|
184
186
|
def on_finish(self):
|
|
185
187
|
self.progress.__exit__(None, None, None)
|
|
@@ -364,11 +366,20 @@ class ILCreater:
|
|
|
364
366
|
else:
|
|
365
367
|
encoding_length = 1
|
|
366
368
|
try:
|
|
367
|
-
|
|
369
|
+
if xref_id in self.mupdf_font_map:
|
|
370
|
+
mupdf_font = self.mupdf_font_map[xref_id]
|
|
371
|
+
else:
|
|
372
|
+
mupdf_font = pymupdf.Font(
|
|
373
|
+
fontbuffer=self.mupdf.extract_font(xref_id)[3]
|
|
374
|
+
)
|
|
375
|
+
mupdf_font.has_glyph = functools.lru_cache(maxsize=10240, typed=True)(
|
|
376
|
+
mupdf_font.has_glyph,
|
|
377
|
+
)
|
|
368
378
|
bold = mupdf_font.is_bold
|
|
369
379
|
italic = mupdf_font.is_italic
|
|
370
380
|
monospaced = mupdf_font.is_monospaced
|
|
371
381
|
serif = mupdf_font.is_serif
|
|
382
|
+
self.mupdf_font_map[xref_id] = mupdf_font
|
|
372
383
|
except Exception:
|
|
373
384
|
bold = None
|
|
374
385
|
italic = None
|
|
@@ -547,6 +558,15 @@ class ILCreater:
|
|
|
547
558
|
font_size=char.size,
|
|
548
559
|
graphic_state=gs,
|
|
549
560
|
)
|
|
561
|
+
|
|
562
|
+
if font:
|
|
563
|
+
font_xref_id = font.xref_id
|
|
564
|
+
if font_xref_id in self.mupdf_font_map:
|
|
565
|
+
mupdf_font = self.mupdf_font_map[font_xref_id]
|
|
566
|
+
# if "(cid:" not in char_unicode:
|
|
567
|
+
# if mupdf_cid := mupdf_font.has_glyph(ord(char_unicode)):
|
|
568
|
+
# char_id = mupdf_cid
|
|
569
|
+
|
|
550
570
|
pdf_char = il_version_1.PdfCharacter(
|
|
551
571
|
box=bbox,
|
|
552
572
|
pdf_character_id=char_id,
|
|
@@ -449,11 +449,11 @@ class ILTranslator:
|
|
|
449
449
|
combined_placeholder_pattern = "|".join(placeholder_patterns)
|
|
450
450
|
|
|
451
451
|
def remove_placeholder(text: str):
|
|
452
|
-
return re.sub(combined_placeholder_pattern, "", text)
|
|
452
|
+
return re.sub(combined_placeholder_pattern, "", text, flags=re.IGNORECASE)
|
|
453
453
|
|
|
454
454
|
# 找到所有匹配
|
|
455
455
|
last_end = 0
|
|
456
|
-
for match in re.finditer(combined_pattern, output):
|
|
456
|
+
for match in re.finditer(combined_pattern, output, flags=re.IGNORECASE):
|
|
457
457
|
# 处理匹配之前的普通文本
|
|
458
458
|
if match.start() > last_end:
|
|
459
459
|
text = output[last_end : match.start()]
|
|
@@ -97,7 +97,23 @@ class TypesettingUnit:
|
|
|
97
97
|
unicode = self.try_get_unicode()
|
|
98
98
|
if not unicode:
|
|
99
99
|
return True
|
|
100
|
-
if re.match(
|
|
100
|
+
if re.match(
|
|
101
|
+
r"^["
|
|
102
|
+
r"a-z"
|
|
103
|
+
r"A-Z"
|
|
104
|
+
r"0-9"
|
|
105
|
+
r"\u00C0-\u00FF" # Latin-1 Supplement
|
|
106
|
+
r"\u0100-\u017F" # Latin Extended A
|
|
107
|
+
r"\u0180-\u024F" # Latin Extended B
|
|
108
|
+
r"\u1E00-\u1EFF" # Latin Extended Additional
|
|
109
|
+
r"\u2C60-\u2C7F" # Latin Extended C
|
|
110
|
+
r"\uA720-\uA7FF" # Latin Extended D
|
|
111
|
+
r"\uAB30-\uAB6F" # Latin Extended E
|
|
112
|
+
r"\u0250-\u02A0" # IPA Extensions
|
|
113
|
+
r"\u0400-\u04FF" # Cyrillic
|
|
114
|
+
r"]+$",
|
|
115
|
+
unicode,
|
|
116
|
+
):
|
|
101
117
|
return False
|
|
102
118
|
return True
|
|
103
119
|
|
|
@@ -60,11 +60,6 @@ class FontMapper:
|
|
|
60
60
|
f.font_id: f for f in self.fonts.values()
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
for font in self.fontid2font.values():
|
|
64
|
-
font.char_lengths = functools.lru_cache(maxsize=10240, typed=True)(
|
|
65
|
-
font.char_lengths,
|
|
66
|
-
)
|
|
67
|
-
|
|
68
63
|
self.fontid2font["base"] = self.fontid2font[self.base_font_ids[0]]
|
|
69
64
|
|
|
70
65
|
self.normal_fonts: list[pymupdf.Font] = [
|
|
@@ -109,6 +104,8 @@ class FontMapper:
|
|
|
109
104
|
char_unicode: str,
|
|
110
105
|
font_type: str,
|
|
111
106
|
):
|
|
107
|
+
if font_type == "script" and not italic:
|
|
108
|
+
return None
|
|
112
109
|
current_char = ord(char_unicode)
|
|
113
110
|
for font in self.type2font[font_type]:
|
|
114
111
|
if not font.has_glyph(current_char):
|
|
@@ -144,6 +141,12 @@ class FontMapper:
|
|
|
144
141
|
)
|
|
145
142
|
return None
|
|
146
143
|
|
|
144
|
+
script_font_map_result = self.map_in_type(
|
|
145
|
+
bold, italic, monospaced, serif, char_unicode, "script"
|
|
146
|
+
)
|
|
147
|
+
if script_font_map_result:
|
|
148
|
+
return script_font_map_result
|
|
149
|
+
|
|
147
150
|
for script_font in self.script_fonts:
|
|
148
151
|
if italic and script_font.has_glyph(current_char):
|
|
149
152
|
return script_font
|
|
@@ -160,6 +163,10 @@ class FontMapper:
|
|
|
160
163
|
if fallback_font_map_result is not None:
|
|
161
164
|
return fallback_font_map_result
|
|
162
165
|
|
|
166
|
+
for font in self.fallback_fonts:
|
|
167
|
+
if font.has_glyph(current_char):
|
|
168
|
+
return font
|
|
169
|
+
|
|
163
170
|
logger.warning(
|
|
164
171
|
f"Can't find font for {char_unicode}({current_char}). "
|
|
165
172
|
f"Original font: {original_font.name}[{original_font.font_id}]. "
|