BabelDOC 0.1.8__tar.gz → 0.1.10__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.1.10/.github/workflows/docs.yml +33 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/.gitignore +2 -1
- {babeldoc-0.1.8 → babeldoc-0.1.10}/PKG-INFO +4 -3
- {babeldoc-0.1.8 → babeldoc-0.1.10}/README.md +3 -2
- babeldoc-0.1.10/babeldoc/__init__.py +1 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/backend/pdf_creater.py +15 -3
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/midend/il_translator.py +10 -3
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/docvision/doclayout.py +2 -2
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/high_level.py +4 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/main.py +8 -1
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/progress_monitor.py +1 -1
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/translation_config.py +2 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/docs/CONTRIBUTING.md +2 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/docs/CONTRIBUTOR_REWARD.md +25 -23
- {babeldoc-0.1.8 → babeldoc-0.1.10}/docs/ImplementationDetails/AsyncTranslate/AsyncTranslate.md +2 -2
- {babeldoc-0.1.8 → babeldoc-0.1.10}/docs/ImplementationDetails/Typesetting/Typesetting.md +4 -0
- babeldoc-0.1.10/docs/index.md +2 -0
- babeldoc-0.1.10/docs/requirements.txt +4 -0
- babeldoc-0.1.10/mkdocs.yml +152 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/pyproject.toml +10 -3
- {babeldoc-0.1.8 → babeldoc-0.1.10}/uv.lock +657 -177
- babeldoc-0.1.8/babeldoc/__init__.py +0 -1
- {babeldoc-0.1.8 → babeldoc-0.1.10}/.github/ISSUE_TEMPLATE/bug_report.yaml +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/.github/ISSUE_TEMPLATE/feature_request.yaml +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/.github/dependabot.yml +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/.github/labels.yml +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/.github/release-drafter.yml +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/.github/workflows/codeql.yml +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/.github/workflows/labeler.yml +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/.github/workflows/publish-to-pypi.yml +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/.github/workflows/test.yml +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/.pre-commit-config.yaml +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/LICENSE +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/asynchronize/__init__.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/const.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/converter.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/__init__.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/backend/__init__.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/frontend/__init__.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/frontend/il_creater.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/il_version_1.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/il_version_1.rnc +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/il_version_1.rng +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/il_version_1.xsd +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/midend/__init__.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/midend/add_debug_information.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/midend/layout_parser.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/midend/paragraph_finder.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/midend/remove_descent.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/midend/styles_and_formulas.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/midend/typesetting.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/translator/__init__.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/translator/cache.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/translator/translator.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/utils/fontmap.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/utils/layout_helper.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/utils/style_helper.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/document_il/xml_converter.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/docvision/README.md +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/docvision/__init__.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/docvision/rpc_doclayout.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/babeldoc/pdfinterp.py +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/docs/CODE_OF_CONDUCT.md +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/docs/ImplementationDetails/ILTranslator/ILTranslator.md +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/docs/ImplementationDetails/PDFCreation/PDFCreation.md +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/docs/ImplementationDetails/PDFParsing/PDFParsing.md +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/docs/ImplementationDetails/ParagraphFinding/ParagraphFinding.md +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/docs/ImplementationDetails/README.md +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/docs/ImplementationDetails/StylesAndFormulas/StylesAndFormulas.md +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/docs/README.md +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/docs/deploy.sh +0 -0
- /babeldoc-0.1.8/docs/images/banner.png → /babeldoc-0.1.10/docs/images/babeldoc-banner.png +0 -0
- /babeldoc-0.1.8/docs/images/contributor_reward_example.png → /babeldoc-0.1.10/docs/images/babeldoc-contributor_reward_example.png +0 -0
- /babeldoc-0.1.8/docs/images/preview.gif → /babeldoc-0.1.10/docs/images/babeldoc-preview.gif +0 -0
- {babeldoc-0.1.8 → babeldoc-0.1.10}/docs/intro-to-pdf-object.md +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: docs
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
permissions:
|
|
7
|
+
contents: write
|
|
8
|
+
jobs:
|
|
9
|
+
deploy:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
with:
|
|
14
|
+
fetch-depth: 0
|
|
15
|
+
- name: Configure Git Credentials
|
|
16
|
+
run: |
|
|
17
|
+
git config user.name github-actions[bot]
|
|
18
|
+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
|
19
|
+
- name: Setup uv with Python 3.12
|
|
20
|
+
uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355 # v5.2.2
|
|
21
|
+
with:
|
|
22
|
+
python-version: "3.12"
|
|
23
|
+
enable-cache: true
|
|
24
|
+
cache-dependency-glob: "uv.lock"
|
|
25
|
+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
|
|
26
|
+
- uses: actions/cache@v4
|
|
27
|
+
with:
|
|
28
|
+
key: mkdocs-material-${{ env.cache_id }}
|
|
29
|
+
path: .cache
|
|
30
|
+
restore-keys: |
|
|
31
|
+
mkdocs-material-
|
|
32
|
+
- run: uv sync
|
|
33
|
+
- run: uv run mkdocs gh-deploy --force
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: BabelDOC
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.10
|
|
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
|
|
@@ -33,7 +33,7 @@ Description-Content-Type: text/markdown
|
|
|
33
33
|
<!-- # Yet Another Document Translator -->
|
|
34
34
|
|
|
35
35
|
<div align="center">
|
|
36
|
-
<img src="
|
|
36
|
+
<img src="https://s.immersivetranslate.com/assets/r2-uploads/images/babeldoc-banner.png" width="320px" alt="YADT"/>
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
<h2 id="title">BabelDOC</h2>
|
|
@@ -63,7 +63,7 @@ PDF scientific paper translation and bilingual comparison library.
|
|
|
63
63
|
## Preview
|
|
64
64
|
|
|
65
65
|
<div align="center">
|
|
66
|
-
<img src="
|
|
66
|
+
<img src="https://s.immersivetranslate.com/assets/r2-uploads/images/babeldoc-preview.png" width="80%"/>
|
|
67
67
|
</div>
|
|
68
68
|
|
|
69
69
|
## Getting Started
|
|
@@ -155,6 +155,7 @@ uv run babeldoc --bing --files example.pdf --files example2.pdf
|
|
|
155
155
|
- `--ignore-cache`: Ignore translation cache and force retranslation
|
|
156
156
|
- `--no-dual`: Do not output bilingual PDF files
|
|
157
157
|
- `--no-mono`: Do not output monolingual PDF files
|
|
158
|
+
- `--min-text-length`: Minimum text length to translate (default: 5)
|
|
158
159
|
- `--openai`: Use OpenAI for translation (default: False)
|
|
159
160
|
- `--bing`: Use Bing for translation (default: False)
|
|
160
161
|
- `--google`: Use Google Translate for translation (default: False)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- # Yet Another Document Translator -->
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
|
-
<img src="
|
|
4
|
+
<img src="https://s.immersivetranslate.com/assets/r2-uploads/images/babeldoc-banner.png" width="320px" alt="YADT"/>
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
<h2 id="title">BabelDOC</h2>
|
|
@@ -31,7 +31,7 @@ PDF scientific paper translation and bilingual comparison library.
|
|
|
31
31
|
## Preview
|
|
32
32
|
|
|
33
33
|
<div align="center">
|
|
34
|
-
<img src="
|
|
34
|
+
<img src="https://s.immersivetranslate.com/assets/r2-uploads/images/babeldoc-preview.png" width="80%"/>
|
|
35
35
|
</div>
|
|
36
36
|
|
|
37
37
|
## Getting Started
|
|
@@ -123,6 +123,7 @@ uv run babeldoc --bing --files example.pdf --files example2.pdf
|
|
|
123
123
|
- `--ignore-cache`: Ignore translation cache and force retranslation
|
|
124
124
|
- `--no-dual`: Do not output bilingual PDF files
|
|
125
125
|
- `--no-mono`: Do not output monolingual PDF files
|
|
126
|
+
- `--min-text-length`: Minimum text length to translate (default: 5)
|
|
126
127
|
- `--openai`: Use OpenAI for translation (default: False)
|
|
127
128
|
- `--bing`: Use Bing for translation (default: False)
|
|
128
129
|
- `--google`: Use Google Translate for translation (default: False)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.10"
|
|
@@ -12,9 +12,12 @@ from babeldoc.translation_config import TranslationConfig
|
|
|
12
12
|
|
|
13
13
|
logger = logging.getLogger(__name__)
|
|
14
14
|
|
|
15
|
+
SUBSET_FONT_STAGE_NAME = "Subset font"
|
|
16
|
+
SAVE_PDF_STAGE_NAME = "Save PDF"
|
|
17
|
+
|
|
15
18
|
|
|
16
19
|
class PDFCreater:
|
|
17
|
-
stage_name = "
|
|
20
|
+
stage_name = "Generate drawing instructions"
|
|
18
21
|
|
|
19
22
|
def __init__(
|
|
20
23
|
self,
|
|
@@ -249,7 +252,7 @@ class PDFCreater:
|
|
|
249
252
|
self.font_mapper.add_font(pdf, self.docs)
|
|
250
253
|
with self.translation_config.progress_monitor.stage_start(
|
|
251
254
|
self.stage_name,
|
|
252
|
-
len(self.docs.page)
|
|
255
|
+
len(self.docs.page),
|
|
253
256
|
) as pbar:
|
|
254
257
|
for page in self.docs.page:
|
|
255
258
|
translation_config.raise_if_cancelled()
|
|
@@ -346,9 +349,18 @@ class PDFCreater:
|
|
|
346
349
|
pdf.update_stream(op_container, draw_op.tobytes())
|
|
347
350
|
pdf[page.page_number].set_contents(op_container)
|
|
348
351
|
pbar.advance()
|
|
349
|
-
|
|
352
|
+
translation_config.raise_if_cancelled()
|
|
353
|
+
with self.translation_config.progress_monitor.stage_start(
|
|
354
|
+
SUBSET_FONT_STAGE_NAME,
|
|
355
|
+
1,
|
|
356
|
+
) as pbar:
|
|
350
357
|
if not translation_config.skip_clean:
|
|
351
358
|
pdf.subset_fonts(fallback=False)
|
|
359
|
+
pbar.advance()
|
|
360
|
+
with self.translation_config.progress_monitor.stage_start(
|
|
361
|
+
SAVE_PDF_STAGE_NAME,
|
|
362
|
+
2,
|
|
363
|
+
) as pbar:
|
|
352
364
|
if not translation_config.no_mono:
|
|
353
365
|
if translation_config.debug:
|
|
354
366
|
translation_config.raise_if_cancelled()
|
|
@@ -2,7 +2,6 @@ import concurrent.futures
|
|
|
2
2
|
import json
|
|
3
3
|
import logging
|
|
4
4
|
from pathlib import Path
|
|
5
|
-
from typing import List, Union
|
|
6
5
|
|
|
7
6
|
from tqdm import tqdm
|
|
8
7
|
|
|
@@ -179,7 +178,7 @@ class ILTranslator:
|
|
|
179
178
|
def __init__(
|
|
180
179
|
self,
|
|
181
180
|
unicode: str,
|
|
182
|
-
placeholders:
|
|
181
|
+
placeholders: list[RichTextPlaceholder | FormulaPlaceholder],
|
|
183
182
|
base_style: PdfStyle = None,
|
|
184
183
|
):
|
|
185
184
|
self.unicode = unicode
|
|
@@ -489,7 +488,8 @@ class ILTranslator:
|
|
|
489
488
|
) and text.replace(" ", "") == "".join(
|
|
490
489
|
x.char_unicode for x in placeholder.composition.pdf_character
|
|
491
490
|
).replace(
|
|
492
|
-
" ",
|
|
491
|
+
" ",
|
|
492
|
+
"",
|
|
493
493
|
):
|
|
494
494
|
comp = PdfParagraphComposition(
|
|
495
495
|
pdf_same_style_characters=placeholder.composition,
|
|
@@ -547,6 +547,13 @@ class ILTranslator:
|
|
|
547
547
|
tracker.set_input(translate_input.unicode)
|
|
548
548
|
|
|
549
549
|
text = translate_input.unicode
|
|
550
|
+
|
|
551
|
+
if len(text) < self.translation_config.min_text_length:
|
|
552
|
+
logger.debug(
|
|
553
|
+
f"Text too short to translate, skip. Text: {text}. Paragraph id: {paragraph.debug_id}.",
|
|
554
|
+
)
|
|
555
|
+
return
|
|
556
|
+
|
|
550
557
|
translated_text = self.translate_engine.translate(text)
|
|
551
558
|
|
|
552
559
|
tracker.set_output(translated_text)
|
|
@@ -76,7 +76,7 @@ os_name = platform.system()
|
|
|
76
76
|
|
|
77
77
|
providers = []
|
|
78
78
|
|
|
79
|
-
if os_name == "Darwin": # Temporarily disable CoreML due to
|
|
79
|
+
if os_name == "Darwin" and False: # Temporarily disable CoreML due to some issues
|
|
80
80
|
providers.append(
|
|
81
81
|
(
|
|
82
82
|
"CoreMLExecutionProvider",
|
|
@@ -91,7 +91,7 @@ if os_name == "Darwin": # Temporarily disable CoreML due to batch inference iss
|
|
|
91
91
|
# workaround for CoreML batch inference issues
|
|
92
92
|
max_batch_size = 1
|
|
93
93
|
else:
|
|
94
|
-
max_batch_size =
|
|
94
|
+
max_batch_size = 1
|
|
95
95
|
providers.append("CPUExecutionProvider") # CPU执行提供者作为通用后备选项
|
|
96
96
|
|
|
97
97
|
|
|
@@ -20,6 +20,8 @@ from babeldoc import asynchronize
|
|
|
20
20
|
from babeldoc.const import CACHE_FOLDER
|
|
21
21
|
from babeldoc.const import get_cache_file_path
|
|
22
22
|
from babeldoc.converter import TranslateConverter
|
|
23
|
+
from babeldoc.document_il.backend.pdf_creater import SAVE_PDF_STAGE_NAME
|
|
24
|
+
from babeldoc.document_il.backend.pdf_creater import SUBSET_FONT_STAGE_NAME
|
|
23
25
|
from babeldoc.document_il.backend.pdf_creater import PDFCreater
|
|
24
26
|
from babeldoc.document_il.frontend.il_creater import ILCreater
|
|
25
27
|
from babeldoc.document_il.midend.add_debug_information import AddDebugInformation
|
|
@@ -48,6 +50,8 @@ TRANSLATE_STAGES = [
|
|
|
48
50
|
Typesetting.stage_name,
|
|
49
51
|
FontMapper.stage_name,
|
|
50
52
|
PDFCreater.stage_name,
|
|
53
|
+
SUBSET_FONT_STAGE_NAME,
|
|
54
|
+
SAVE_PDF_STAGE_NAME,
|
|
51
55
|
]
|
|
52
56
|
|
|
53
57
|
resfont_map = {
|
|
@@ -20,7 +20,7 @@ from babeldoc.document_il.translator.translator import set_translate_rate_limite
|
|
|
20
20
|
from babeldoc.translation_config import TranslationConfig
|
|
21
21
|
|
|
22
22
|
logger = logging.getLogger(__name__)
|
|
23
|
-
__version__ = "0.1.
|
|
23
|
+
__version__ = "0.1.10"
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
def create_parser():
|
|
@@ -75,6 +75,12 @@ def create_parser():
|
|
|
75
75
|
type=str,
|
|
76
76
|
help="Pages to translate. If not set, translate all pages. like: 1,2,1-,-3,3-5",
|
|
77
77
|
)
|
|
78
|
+
translation_params.add_argument(
|
|
79
|
+
"--min-text-length",
|
|
80
|
+
type=int,
|
|
81
|
+
default=5,
|
|
82
|
+
help="Minimum text length to translate (default: 5)",
|
|
83
|
+
)
|
|
78
84
|
translation_params.add_argument(
|
|
79
85
|
"--lang-in",
|
|
80
86
|
"-li",
|
|
@@ -421,6 +427,7 @@ async def main():
|
|
|
421
427
|
disable_rich_text_translate=args.disable_rich_text_translate,
|
|
422
428
|
enhance_compatibility=args.enhance_compatibility,
|
|
423
429
|
report_interval=args.report_interval,
|
|
430
|
+
min_text_length=args.min_text_length,
|
|
424
431
|
)
|
|
425
432
|
|
|
426
433
|
# Create progress handler
|
|
@@ -111,7 +111,7 @@ class ProgressMonitor:
|
|
|
111
111
|
def stage_update(self, stage, n: int):
|
|
112
112
|
with self.lock:
|
|
113
113
|
report_time_delta = time.time() - self.last_report_time
|
|
114
|
-
if report_time_delta < self.report_interval:
|
|
114
|
+
if report_time_delta < self.report_interval and stage.total > 3:
|
|
115
115
|
return
|
|
116
116
|
if self.progress_change_callback:
|
|
117
117
|
self.progress_change_callback(
|
|
@@ -36,6 +36,7 @@ class TranslationConfig:
|
|
|
36
36
|
disable_rich_text_translate: bool = False, # 是否禁用富文本翻译
|
|
37
37
|
enhance_compatibility: bool = False, # 增强兼容性模式
|
|
38
38
|
report_interval: float = 0.1, # Progress report interval in seconds
|
|
39
|
+
min_text_length: int = 5, # Minimum text length to translate
|
|
39
40
|
):
|
|
40
41
|
self.input_file = input_file
|
|
41
42
|
self.translator = translator
|
|
@@ -60,6 +61,7 @@ class TranslationConfig:
|
|
|
60
61
|
disable_rich_text_translate or enhance_compatibility
|
|
61
62
|
)
|
|
62
63
|
self.report_interval = report_interval
|
|
64
|
+
self.min_text_length = min_text_length
|
|
63
65
|
if progress_monitor:
|
|
64
66
|
if progress_monitor.cancel_event is None:
|
|
65
67
|
progress_monitor.cancel_event = threading.Event()
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# BabelDOC/PDFMathTranslate 贡献者奖励规则
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
## 月度活跃贡献者奖励规则
|
|
4
|
+
|
|
5
|
+
### 一、资格标准
|
|
6
|
+
#### **贡献类型要求**
|
|
6
7
|
- 需提交 **至少 1 个有效 PR**(Pull Request),或进行 **PR 审核、文档编写** 等贡献。
|
|
7
8
|
- 有效贡献定义:
|
|
8
9
|
- 非简单的文档错别字修复
|
|
@@ -10,11 +11,11 @@
|
|
|
10
11
|
- 需做出实质性贡献(如功能开发、Bug 修复、性能优化、架构调整、技术文档编写、PR 审核等)
|
|
11
12
|
- 示例合格贡献:新增功能模块、修复逻辑错误、优化算法效率、编写技术文档等
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
#### **时间范围**
|
|
14
15
|
- 每月 1 日至月末最后一天合并的 PR 计入当月统计
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
### 二、申请流程
|
|
18
|
+
#### **申请条件**
|
|
18
19
|
- PR 需被成功合并至[funstory-ai/BabelDOC](https://github.com/funstory-ai/BabelDOC/pulls) 仓库或 [Byaidu/PDFMathTranslate](https://github.com/Byaidu/PDFMathTranslate/pulls)的主分支。
|
|
19
20
|
- 审核 PR、撰写 wiki 等贡献也必须是以上两个仓库。
|
|
20
21
|
- 同一贡献者每月仅可申请一次(无论提交 PR 数量)
|
|
@@ -22,7 +23,7 @@
|
|
|
22
23
|
- 对于 PR,只有发起者可以申请兑换码
|
|
23
24
|
- 仅可使用当月的贡献申请兑换码(特殊情况请联系 aw@funstory.ai 说明)
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
#### **申请方式**
|
|
26
27
|
- 发送邮件至 **aw@funstory.ai**
|
|
27
28
|
- 邮件标题格式:`[贡献者会员兑换码申请] GitHub用户名-月份`(例:`[贡献者会员兑换码申请] awwaawwa-2024-07`)
|
|
28
29
|
- 邮件正文需包含:
|
|
@@ -31,51 +32,52 @@
|
|
|
31
32
|
- 附件要求:
|
|
32
33
|
- PR 页面完整截图(需包含合并状态、仓库名称及点击头像后弹出来的侧边栏,如下图所示)
|
|
33
34
|
|
|
34
|
-

|
|
35
|
+

|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
#### **奖励说明**
|
|
37
38
|
- 奖励内容:[沉浸式翻译(Immersive Translate)](https://immersivetranslate.com/zh-Hans/pricing/)月度会员兑换码
|
|
38
39
|
- 兑换码使用:在[沉浸式翻译官网兑换页](https://immersivetranslate.com/zh-Hans/exchange)输入即可激活
|
|
39
40
|
- 会员权益:沉浸式翻译 Pro 会员一个月(详见[官网价格页](https://immersivetranslate.com/zh-Hans/pricing/)说明)
|
|
40
41
|
- 兑换码为专属福利,不可转让
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
### 三、审核与发放
|
|
44
|
+
#### **审核周期**
|
|
44
45
|
- 我们会尽力在收到申请邮件后 1 个工作日内完成审核
|
|
45
46
|
- 审核时间可能因申请数量、审核复杂度等因素有所延长
|
|
46
47
|
- 审核通过后,兑换码将通过邮件方式发送
|
|
47
48
|
- 若审核未通过,我们会通过邮件说明原因
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
#### **兑换码规则**
|
|
50
51
|
- 使用方式:[官网兑换页](https://immersivetranslate.com/zh-Hans/exchange)输入兑换码激活
|
|
51
52
|
- 权益内容:月度会员(具体权益见[官网价格页](https://immersivetranslate.com/zh-Hans/pricing/)说明)
|
|
52
53
|
- 不可转让
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
### 四、注意事项
|
|
56
|
+
#### **禁止行为**
|
|
56
57
|
- 将完整功能拆分为多个无关 PR 提交
|
|
57
58
|
- 提交质量不合格或具有潜在危害的代码
|
|
58
59
|
- 提供虚假或误导性的申请材料
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
#### **特别说明**
|
|
61
62
|
- funstory.ai 保留对贡献价值的评估权、规则的最终解释权等所有必要权利
|
|
62
|
-
-
|
|
63
|
+
- 规则如有实质性更新(格式调整等除外),将提前 1 天在 [BabelDOC GitHub PR](https://github.com/funstory-ai/BabelDOC/pulls) 公告
|
|
63
64
|
- 过期未使用的兑换码不予补发
|
|
64
65
|
- 自 2025 年 2 月 1 日起的贡献可以申请兑换码
|
|
65
66
|
- 为了确认您是 Pull Request (PR) 的发起者,防止他人冒领,我们可能会要求您使用发起者账号在 PR 下方留言指定的随机数字。
|
|
66
67
|
|
|
68
|
+
## 常见问题解答(FAQ)
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
### **常见问题解答(FAQ)**
|
|
70
|
+
**Q:如何判断文档翻译贡献是否有效?**
|
|
70
71
|
|
|
71
|
-
Q:如何判断文档翻译贡献是否有效?
|
|
72
72
|
A:系统性的人工翻译(如完整章节的翻译并经过人工校对)视为有效贡献。零散段落翻译或仅依赖机器翻译的内容不计入有效贡献。
|
|
73
73
|
|
|
74
|
-
Q
|
|
75
|
-
|
|
74
|
+
**Q:兑换码过期了可以补发吗?**
|
|
75
|
+
|
|
76
|
+
A:为确保公平性,过期的兑换码将不予补发,请在有效期内及时使用。
|
|
77
|
+
|
|
78
|
+
**Q:为什么这个文档是中文的?**
|
|
76
79
|
|
|
77
|
-
Q:为什么这个文档是中文的?
|
|
78
80
|
A:因为目前应该是中文贡献者多吧,所以就先写中文的。后面再撰写英文版的。
|
|
79
81
|
|
|
80
82
|
---
|
|
81
|
-
**规则公示**:本规则文档存放于 BabelDOC 仓库 [CONTRIBUTOR_REWARD.md](https://github.com/funstory-ai/BabelDOC/blob/main/docs/CONTRIBUTOR_REWARD.md)
|
|
83
|
+
**规则公示**:本规则文档存放于 BabelDOC 仓库 [CONTRIBUTOR_REWARD.md](https://github.com/funstory-ai/BabelDOC/blob/main/docs/CONTRIBUTOR_REWARD.md),并在 [Contributor Reward - BabelDOC](https://funstory-ai.github.io/BabelDOC/CONTRIBUTOR_REWARD/) 展示。
|
{babeldoc-0.1.8 → babeldoc-0.1.10}/docs/ImplementationDetails/AsyncTranslate/AsyncTranslate.md
RENAMED
|
@@ -12,7 +12,7 @@ The `yadt.high_level.async_translate` function provides an asynchronous interfac
|
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
|
-
```python
|
|
15
|
+
```python linenums="1"
|
|
16
16
|
async def translate_with_progress():
|
|
17
17
|
config = TranslationConfig(
|
|
18
18
|
input_file="example.pdf",
|
|
@@ -131,7 +131,7 @@ The translation process can be cancelled in several ways:
|
|
|
131
131
|
|
|
132
132
|
Example of programmatic cancellation:
|
|
133
133
|
|
|
134
|
-
```python
|
|
134
|
+
```python linenums="1"
|
|
135
135
|
async def translate_with_cancellation():
|
|
136
136
|
config = TranslationConfig(
|
|
137
137
|
input_file="example.pdf",
|
|
@@ -107,3 +107,7 @@ However, for special cases like "图 1" translated to "Figure 1", even with the
|
|
|
107
107
|
4. No global page information consideration, inconsistent text sizes.
|
|
108
108
|
|
|
109
109
|
5. No advanced typography features, poor reading experience.
|
|
110
|
+
|
|
111
|
+
## Related Resources
|
|
112
|
+
|
|
113
|
+
[UTR #59: East Asian Spacing](https://www.unicode.org/reports/tr59/) specifies which characters need spacing between them.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com>
|
|
2
|
+
|
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
# of this software and associated documentation files (the "Software"), to
|
|
5
|
+
# deal in the Software without restriction, including without limitation the
|
|
6
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
7
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
# furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
|
11
|
+
# all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
18
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
19
|
+
# IN THE SOFTWARE.
|
|
20
|
+
|
|
21
|
+
# Project information
|
|
22
|
+
site_name: BabelDOC
|
|
23
|
+
site_url: https://squidfunk.github.io/mkdocs-material/
|
|
24
|
+
site_author: funstory.ai
|
|
25
|
+
site_description: >-
|
|
26
|
+
Write your documentation in Markdown and create a professional static site in
|
|
27
|
+
minutes – searchable, customizable, in 60+ languages, for all devices
|
|
28
|
+
|
|
29
|
+
# Repository
|
|
30
|
+
repo_name: funstory-ai/BabelDOC
|
|
31
|
+
repo_url: https://github.com/funstory-ai/BabelDOC
|
|
32
|
+
edit_uri: edit/main/docs/
|
|
33
|
+
|
|
34
|
+
# Copyright
|
|
35
|
+
copyright: Copyright © 2025 funstory.ai
|
|
36
|
+
|
|
37
|
+
# Configuration
|
|
38
|
+
theme:
|
|
39
|
+
name: material
|
|
40
|
+
# custom_dir: material/overrides
|
|
41
|
+
features:
|
|
42
|
+
- announce.dismiss
|
|
43
|
+
- content.action.edit
|
|
44
|
+
- content.action.view
|
|
45
|
+
- content.code.annotate
|
|
46
|
+
- content.code.copy
|
|
47
|
+
- content.code.select
|
|
48
|
+
# - content.footnote.tooltips
|
|
49
|
+
# - content.tabs.link
|
|
50
|
+
- content.tooltips
|
|
51
|
+
# - header.autohide
|
|
52
|
+
# - navigation.expand
|
|
53
|
+
- navigation.footer
|
|
54
|
+
- navigation.indexes
|
|
55
|
+
# - navigation.instant
|
|
56
|
+
# - navigation.instant.prefetch
|
|
57
|
+
# - navigation.instant.progress
|
|
58
|
+
# - navigation.prune
|
|
59
|
+
- navigation.sections
|
|
60
|
+
- navigation.tabs
|
|
61
|
+
# - navigation.tabs.sticky
|
|
62
|
+
- navigation.top
|
|
63
|
+
- navigation.tracking
|
|
64
|
+
- search.highlight
|
|
65
|
+
- search.share
|
|
66
|
+
- search.suggest
|
|
67
|
+
- toc.follow
|
|
68
|
+
# - toc.integrate
|
|
69
|
+
palette:
|
|
70
|
+
- media: "(prefers-color-scheme)"
|
|
71
|
+
toggle:
|
|
72
|
+
icon: material/brightness-auto
|
|
73
|
+
name: Switch to light mode
|
|
74
|
+
- media: "(prefers-color-scheme: light)"
|
|
75
|
+
scheme: default
|
|
76
|
+
primary: white
|
|
77
|
+
accent: indigo
|
|
78
|
+
toggle:
|
|
79
|
+
icon: material/brightness-7
|
|
80
|
+
name: Switch to dark mode
|
|
81
|
+
- media: "(prefers-color-scheme: dark)"
|
|
82
|
+
scheme: slate
|
|
83
|
+
primary: black
|
|
84
|
+
accent: indigo
|
|
85
|
+
toggle:
|
|
86
|
+
icon: material/brightness-4
|
|
87
|
+
name: Switch to system preference
|
|
88
|
+
font:
|
|
89
|
+
text: Roboto
|
|
90
|
+
code: Roboto Mono
|
|
91
|
+
favicon: assets/favicon.png
|
|
92
|
+
icon:
|
|
93
|
+
logo: logo
|
|
94
|
+
|
|
95
|
+
# Plugins
|
|
96
|
+
plugins:
|
|
97
|
+
- search:
|
|
98
|
+
separator: '[\s\u200b\-_,:!=\[\]()"`/]+|\.(?!\d)|&[lg]t;|(?!\b)(?=[A-Z][a-z])'
|
|
99
|
+
- minify:
|
|
100
|
+
minify_html: true
|
|
101
|
+
- git-authors
|
|
102
|
+
- git-revision-date-localized:
|
|
103
|
+
enable_creation_date: true
|
|
104
|
+
# Additional configuration
|
|
105
|
+
extra:
|
|
106
|
+
status:
|
|
107
|
+
new: Recently added
|
|
108
|
+
deprecated: Deprecated
|
|
109
|
+
social:
|
|
110
|
+
- icon: fontawesome/brands/github
|
|
111
|
+
link: https://github.com/funstory-ai/BabelDOC
|
|
112
|
+
- icon: fontawesome/brands/python
|
|
113
|
+
link: https://pypi.org/project/BabelDOC/
|
|
114
|
+
|
|
115
|
+
# Extensions
|
|
116
|
+
markdown_extensions:
|
|
117
|
+
- github-callouts
|
|
118
|
+
- markdown_include.include
|
|
119
|
+
- pymdownx.highlight:
|
|
120
|
+
anchor_linenums: true
|
|
121
|
+
line_spans: __span
|
|
122
|
+
pygments_lang_class: true
|
|
123
|
+
- pymdownx.inlinehilite
|
|
124
|
+
- pymdownx.snippets
|
|
125
|
+
- pymdownx.superfences
|
|
126
|
+
- def_list
|
|
127
|
+
- pymdownx.tasklist:
|
|
128
|
+
custom_checkbox: true
|
|
129
|
+
not_in_nav: |
|
|
130
|
+
/tutorials/**/*.md
|
|
131
|
+
|
|
132
|
+
# Page tree
|
|
133
|
+
nav:
|
|
134
|
+
- Home: index.md
|
|
135
|
+
- API:
|
|
136
|
+
- Async Translation API: ImplementationDetails/AsyncTranslate/AsyncTranslate.md
|
|
137
|
+
- Implementation Details:
|
|
138
|
+
- ImplementationDetails/README.md
|
|
139
|
+
- PDF Parsing: ImplementationDetails/PDFParsing/PDFParsing.md
|
|
140
|
+
- Layout Parser(.py): https://github.com/funstory-ai/BabelDOC/blob/main/babeldoc/document_il/midend/layout_parser.py
|
|
141
|
+
- Paragraph Finding: ImplementationDetails/ParagraphFinding/ParagraphFinding.md
|
|
142
|
+
- Styles and Formulas: ImplementationDetails/StylesAndFormulas/StylesAndFormulas.md
|
|
143
|
+
- IL Translator: ImplementationDetails/ILTranslator/ILTranslator.md
|
|
144
|
+
- Typesetting: ImplementationDetails/Typesetting/Typesetting.md
|
|
145
|
+
- Font Mapper(.py): https://github.com/funstory-ai/BabelDOC/blob/main/babeldoc/document_il/utils/fontmap.py
|
|
146
|
+
- PDF Creation: ImplementationDetails/PDFCreation/PDFCreation.md
|
|
147
|
+
- Intro To PDF Object: intro-to-pdf-object.md
|
|
148
|
+
- Community:
|
|
149
|
+
- Code of Conduct: CODE_OF_CONDUCT.md
|
|
150
|
+
- Contributing:
|
|
151
|
+
- Contributing: CONTRIBUTING.md
|
|
152
|
+
- Contributor Reward: CONTRIBUTOR_REWARD.md
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "BabelDOC"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.10"
|
|
4
4
|
description = "Yet Another Document Translator"
|
|
5
5
|
license = "AGPL-3.0"
|
|
6
6
|
readme = "README.md"
|
|
@@ -108,16 +108,23 @@ max-complexity = 10 # 函数圈复杂度阈值
|
|
|
108
108
|
"**/__init__.py" = ["F401"] # 允许未使用的导入
|
|
109
109
|
# 忽略 S311 警告,因为这是有意的
|
|
110
110
|
"babeldoc/document_il/midend/paragraph_finder.py" = ["S311"]
|
|
111
|
-
|
|
111
|
+
"docs/*" = ["A001"]
|
|
112
112
|
[dependency-groups]
|
|
113
113
|
dev = [
|
|
114
114
|
"bumpver>=2024.1130",
|
|
115
|
+
"markdown-callouts>=0.4.0",
|
|
116
|
+
"markdown-include>=0.8.1",
|
|
117
|
+
"mkdocs-git-authors-plugin>=0.9.2",
|
|
118
|
+
"mkdocs-git-committers-plugin-2>=2.5.0",
|
|
119
|
+
"mkdocs-git-revision-date-localized-plugin>=1.3.0",
|
|
120
|
+
"mkdocs-material[recommended]>=9.6.4",
|
|
115
121
|
"pre-commit>=4.1.0",
|
|
122
|
+
"pygments>=2.19.1",
|
|
116
123
|
"ruff>=0.9.2",
|
|
117
124
|
]
|
|
118
125
|
|
|
119
126
|
[bumpver]
|
|
120
|
-
current_version = "0.1.
|
|
127
|
+
current_version = "0.1.10"
|
|
121
128
|
version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"
|
|
122
129
|
|
|
123
130
|
[bumpver.file_patterns]
|