BabelDOC 0.3.3__tar.gz → 0.3.5__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.5/.github/ISSUE_TEMPLATE/bug_report.yaml +86 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/.github/ISSUE_TEMPLATE/feature_request.yaml +17 -9
- babeldoc-0.3.5/.github/PULL_REQUEST_TEMPLATE/pr_form.yml +92 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/PKG-INFO +5 -1
- {babeldoc-0.3.3 → babeldoc-0.3.5}/README.md +4 -0
- babeldoc-0.3.5/babeldoc/__init__.py +1 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/const.py +1 -1
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/frontend/il_creater.py +21 -1
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/midend/il_translator.py +2 -2
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/midend/styles_and_formulas.py +2 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/utils/fontmap.py +0 -5
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/high_level.py +3 -1
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/main.py +1 -1
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/translation_config.py +4 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/pyproject.toml +2 -2
- {babeldoc-0.3.3 → babeldoc-0.3.5}/uv.lock +1 -1
- babeldoc-0.3.3/.github/ISSUE_TEMPLATE/bug_report.yaml +0 -85
- babeldoc-0.3.3/babeldoc/__init__.py +0 -1
- {babeldoc-0.3.3 → babeldoc-0.3.5}/.cursorignore +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/.github/dependabot.yml +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/.github/labels.yml +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/.github/release-drafter.yml +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/.github/workflows/codeql.yml +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/.github/workflows/docs.yml +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/.github/workflows/labeler.yml +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/.github/workflows/publish-to-pypi.yml +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/.github/workflows/test.yml +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/.gitignore +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/.pre-commit-config.yaml +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/LICENSE +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/assets/assets.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/assets/embedding_assets_metadata.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/asynchronize/__init__.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/converter.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/__init__.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/babeldoc_exception/BabelDOCException.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/backend/__init__.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/backend/pdf_creater.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/frontend/__init__.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/il_version_1.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/il_version_1.rnc +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/il_version_1.rng +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/il_version_1.xsd +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/midend/__init__.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/midend/add_debug_information.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/midend/detect_scanned_file.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/midend/il_translator_llm_only.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/midend/layout_parser.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/midend/paragraph_finder.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/midend/remove_descent.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/midend/table_parser.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/midend/typesetting.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/translator/__init__.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/translator/cache.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/translator/translator.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/utils/atomic_integer.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/utils/layout_helper.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/utils/priority_thread_pool_executor.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/utils/style_helper.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/xml_converter.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/docvision/README.md +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/docvision/__init__.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/docvision/doclayout.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/docvision/rpc_doclayout.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/docvision/table_detection/rapidocr.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/pdfinterp.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/progress_monitor.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/result_merger.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/split_manager.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/tools/generate_font_metadata.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/tools/italic_assistance.py +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/CODE_OF_CONDUCT.md +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/CONTRIBUTING.md +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/CONTRIBUTOR_REWARD.md +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/ImplementationDetails/AsyncTranslate/AsyncTranslate.md +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/ImplementationDetails/ILTranslator/ILTranslator.md +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/ImplementationDetails/PDFCreation/PDFCreation.md +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/ImplementationDetails/PDFParsing/PDFParsing.md +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/ImplementationDetails/ParagraphFinding/ParagraphFinding.md +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/ImplementationDetails/README.md +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/ImplementationDetails/StylesAndFormulas/StylesAndFormulas.md +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/ImplementationDetails/Typesetting/Typesetting.md +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/README.md +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/deploy.sh +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/images/babeldoc-banner.png +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/images/babeldoc-big-logo-darkmode-with-transparent-background.png +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/images/babeldoc-big-logo-darkmode-with-transparent-background.svg +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/images/babeldoc-big-logo-with-transparent-background.png +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/images/babeldoc-big-logo-with-transparent-background.svg +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/images/babeldoc-big-logo.png +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/images/babeldoc-contributor_reward_example.png +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/images/babeldoc-preview.gif +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/images/babeldoc-small-logo-with-transparent-background.png +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/images/babeldoc-small-logo-with-transparent-background.svg +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/images/babeldoc-small-logo.png +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/index.md +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/intro-to-pdf-object.md +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/docs/requirements.txt +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/mkdocs.yml +0 -0
- {babeldoc-0.3.3 → babeldoc-0.3.5}/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.5
|
|
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.5"
|
|
@@ -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()]
|
|
@@ -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] = [
|
|
@@ -381,7 +381,7 @@ def do_translate(
|
|
|
381
381
|
original_pdf_path = translation_config.input_file
|
|
382
382
|
logger.info(f"start to translate: {original_pdf_path}")
|
|
383
383
|
start_time = time.time()
|
|
384
|
-
|
|
384
|
+
peak_memory_usage = 0
|
|
385
385
|
with MemoryMonitor() as memory_monitor:
|
|
386
386
|
# Check if split translation is enabled
|
|
387
387
|
if not translation_config.split_strategy:
|
|
@@ -504,6 +504,7 @@ def do_translate(
|
|
|
504
504
|
logger.info("start merge results")
|
|
505
505
|
result = merger.merge_results(results)
|
|
506
506
|
logger.info("finish merge results")
|
|
507
|
+
peak_memory_usage = memory_monitor.peak_memory_usage
|
|
507
508
|
|
|
508
509
|
finish_time = time.time()
|
|
509
510
|
result.total_seconds = finish_time - start_time
|
|
@@ -512,6 +513,7 @@ def do_translate(
|
|
|
512
513
|
f"finish translate: {original_pdf_path}, cost: {finish_time - start_time} s",
|
|
513
514
|
)
|
|
514
515
|
result.original_pdf_path = translation_config.input_file
|
|
516
|
+
result.peak_memory_usage = peak_memory_usage
|
|
515
517
|
pm.translate_done(result)
|
|
516
518
|
return result
|
|
517
519
|
|
|
@@ -256,6 +256,7 @@ class TranslateResult:
|
|
|
256
256
|
dual_pdf_path: str | None
|
|
257
257
|
no_watermark_mono_pdf_path: str | None
|
|
258
258
|
no_watermark_dual_pdf_path: str | None
|
|
259
|
+
peak_memory_usage: int | None
|
|
259
260
|
|
|
260
261
|
def __init__(self, mono_pdf_path: str | None, dual_pdf_path: str | None):
|
|
261
262
|
self.mono_pdf_path = mono_pdf_path
|
|
@@ -299,6 +300,9 @@ class TranslateResult:
|
|
|
299
300
|
f"\tNo-watermark Dual-language PDF: {self.no_watermark_dual_pdf_path}"
|
|
300
301
|
)
|
|
301
302
|
|
|
303
|
+
if hasattr(self, "peak_memory_usage") and self.peak_memory_usage:
|
|
304
|
+
result.append(f"\tPeak memory usage: {self.peak_memory_usage} MB")
|
|
305
|
+
|
|
302
306
|
if result:
|
|
303
307
|
result.insert(0, "Translation results:")
|
|
304
308
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "BabelDOC"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.5"
|
|
4
4
|
description = "Yet Another Document Translator"
|
|
5
5
|
license = "AGPL-3.0"
|
|
6
6
|
readme = "README.md"
|
|
@@ -148,7 +148,7 @@ pythonpath = [".", "src"]
|
|
|
148
148
|
testpaths = ["tests"]
|
|
149
149
|
|
|
150
150
|
[bumpver]
|
|
151
|
-
current_version = "0.3.
|
|
151
|
+
current_version = "0.3.5"
|
|
152
152
|
version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"
|
|
153
153
|
|
|
154
154
|
[bumpver.file_patterns]
|
|
@@ -1,85 +0,0 @@
|
|
|
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 asking
|
|
9
|
-
options:
|
|
10
|
-
- label: I have searched the existing issues
|
|
11
|
-
required: true
|
|
12
|
-
- label: I spend at least 5 minutes for thinking and preparing
|
|
13
|
-
required: true
|
|
14
|
-
- label: I have carefully checked the issue, and it is unrelated to the network environment.
|
|
15
|
-
required: true
|
|
16
|
-
- type: markdown
|
|
17
|
-
attributes:
|
|
18
|
-
value: |
|
|
19
|
-
Thank you for using this project and providing feedback!
|
|
20
|
-
- type: textarea
|
|
21
|
-
id: environment
|
|
22
|
-
attributes:
|
|
23
|
-
label: Environment
|
|
24
|
-
description: |
|
|
25
|
-
examples:
|
|
26
|
-
- **OS**: Ubuntu 24.10
|
|
27
|
-
- **Python**: 3.12.0
|
|
28
|
-
- **BalbelDOC**: 1.9.0
|
|
29
|
-
value: |
|
|
30
|
-
- OS:
|
|
31
|
-
- Python:
|
|
32
|
-
- BalbelDOC:
|
|
33
|
-
render: markdown
|
|
34
|
-
validations:
|
|
35
|
-
required: false
|
|
36
|
-
- type: textarea
|
|
37
|
-
id: describe
|
|
38
|
-
attributes:
|
|
39
|
-
label: Describe the bug
|
|
40
|
-
description: A clear and concise description of what the bug is.
|
|
41
|
-
validations:
|
|
42
|
-
required: true
|
|
43
|
-
- type: textarea
|
|
44
|
-
id: reproduce
|
|
45
|
-
attributes:
|
|
46
|
-
label: To Reproduce
|
|
47
|
-
description: Steps to reproduce the behavior
|
|
48
|
-
value: |
|
|
49
|
-
1. Go to '...'
|
|
50
|
-
2. Click on '....'
|
|
51
|
-
3. Scroll down to '....'
|
|
52
|
-
4. See error
|
|
53
|
-
validations:
|
|
54
|
-
required: false
|
|
55
|
-
- type: textarea
|
|
56
|
-
id: expected
|
|
57
|
-
attributes:
|
|
58
|
-
label: Expected behavior
|
|
59
|
-
description: A clear and concise description of what you expected to happen.
|
|
60
|
-
validations:
|
|
61
|
-
required: false
|
|
62
|
-
- type: textarea
|
|
63
|
-
id: logs
|
|
64
|
-
attributes:
|
|
65
|
-
label: Relevant log output and screenshots
|
|
66
|
-
description: Please copy and paste any relevant log output and screenshots. This will be automatically formatted into code, so no need for backticks.
|
|
67
|
-
render: Text
|
|
68
|
-
validations:
|
|
69
|
-
required: false
|
|
70
|
-
- type: textarea
|
|
71
|
-
id: PDFfile
|
|
72
|
-
attributes:
|
|
73
|
-
label: Origin PDF file
|
|
74
|
-
description: |
|
|
75
|
-
if applicable, attach the input PDF file here.
|
|
76
|
-
validations:
|
|
77
|
-
required: false
|
|
78
|
-
- type: textarea
|
|
79
|
-
id: others
|
|
80
|
-
attributes:
|
|
81
|
-
label: Anything else?
|
|
82
|
-
description: |
|
|
83
|
-
Add any other context about the problem here.
|
|
84
|
-
validations:
|
|
85
|
-
required: false
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.3.3"
|
|
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
|
{babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/babeldoc_exception/BabelDOCException.py
RENAMED
|
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
|
{babeldoc-0.3.3 → babeldoc-0.3.5}/babeldoc/document_il/utils/priority_thread_pool_executor.py
RENAMED
|
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
|
{babeldoc-0.3.3 → babeldoc-0.3.5}/docs/ImplementationDetails/AsyncTranslate/AsyncTranslate.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{babeldoc-0.3.3 → babeldoc-0.3.5}/docs/ImplementationDetails/ParagraphFinding/ParagraphFinding.md
RENAMED
|
File without changes
|
|
File without changes
|
{babeldoc-0.3.3 → babeldoc-0.3.5}/docs/ImplementationDetails/StylesAndFormulas/StylesAndFormulas.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{babeldoc-0.3.3 → babeldoc-0.3.5}/docs/images/babeldoc-big-logo-with-transparent-background.png
RENAMED
|
File without changes
|
{babeldoc-0.3.3 → babeldoc-0.3.5}/docs/images/babeldoc-big-logo-with-transparent-background.svg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{babeldoc-0.3.3 → babeldoc-0.3.5}/docs/images/babeldoc-small-logo-with-transparent-background.png
RENAMED
|
File without changes
|
{babeldoc-0.3.3 → babeldoc-0.3.5}/docs/images/babeldoc-small-logo-with-transparent-background.svg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|