소스 검색

Merge branch 'main' of https://github.com/Byaidu/PDFMathTranslate

Byaidu 1 년 전
부모
커밋
4a47cbdf44
2개의 변경된 파일114개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 1
      README.md
  2. 111 0
      README_zh-CN.md

+ 3 - 1
README.md

@@ -1,3 +1,5 @@
+English | [简体中文](README_zh-CN.md)
+
 # PDFMathTranslate
 
 <p align="center">
@@ -75,7 +77,7 @@ pdf2zh example.pdf -s deeplx
 ### Use regex to specify formula fonts and characters that need to be preserved
 
 ```bash
-pdf2zh BDA3.pdf -f "(CM[^RT].*|MS.*|XY.*|MT.*|BL.*|.*0700|.*0500|.*Italic)" -c "(\(|\||\)|\+|=|\d|[\u0080-\ufaff])"
+pdf2zh example.pdf -f "(CM[^RT].*|MS.*|.*Ital)" -c "(\(|\||\)|\+|=|\d|[\u0080-\ufaff])"
 ```
 
 ## Preview

+ 111 - 0
README_zh-CN.md

@@ -0,0 +1,111 @@
+[English](README.md) | 简体中文
+
+# PDFMathTranslate
+
+<p align="center">
+  <!-- PyPI -->
+  <a href="https://pypi.org/project/pdf2zh/">
+    <img src="https://img.shields.io/pypi/v/pdf2zh"/>
+  </a>
+  <!-- License -->
+  <a href="./LICENSE">
+    <img src="https://img.shields.io/github/license/Byaidu/PDFMathTranslate"/>
+  </a>
+</p>
+
+PDF 文档翻译及双语对照
+
+- 📊 保留公式和图表
+
+- 📄 保留可索引目录
+
+- 🌐 支持多种翻译服务
+
+## 安装
+
+要求 Python 版本 >=3.8, <=3.11
+
+```bash
+pip install -U "pdf2zh>=1.5.3"
+```
+
+## 使用
+
+命令行中执行翻译指令,在工作目录下生成翻译文档 `example-zh.pdf` 和双语对照文档 `example-dual.pdf`。
+
+### 翻译完整文档
+
+```bash
+pdf2zh example.pdf
+```
+
+### 翻译部分文档
+
+```bash
+pdf2zh example.pdf -p 1-3,5
+```
+
+### 使用指定语言翻译
+
+参考 [Languages Codes](https://developers.google.com/admin-sdk/directory/v1/languages)
+
+```bash
+pdf2zh example.pdf -li en -lo ja
+```
+
+### 使用 Ollama 翻译
+
+参考 [Ollama](https://github.com/ollama/ollama)
+
+```bash
+pdf2zh example.pdf -s gemma2
+```
+
+### 使用 DeepLX 翻译
+
+参考 [DeepLX](https://github.com/OwO-Network/DeepLX)
+
+1. 设置环境变量构建 endpoint:`{DEEPLX_URL}/{DEEPLX_TOKEN}/translate`:
+   - `DEEPLX_URL`, e.g., `export DEEPLX_URL=https://api.deeplx.org`
+   - `DEEPLX_TOKEN`, e.g., `export DEEPLX_TOKEN=ABCDEFG`
+
+2. 执行:
+```bash
+pdf2zh example.pdf -s deeplx
+```
+
+### 使用正则表达式指定需要保留样式的字体和字符
+
+```bash
+pdf2zh example.pdf -f "(CM[^RT].*|MS.*|.*Ital)" -c "(\(|\||\)|\+|=|\d|[\u0080-\ufaff])"
+```
+
+## 预览
+
+![image](https://github.com/user-attachments/assets/57e1cde6-c647-4af8-8f8f-587a40050dde)
+
+![image](https://github.com/user-attachments/assets/0e6d7e44-18cd-443a-8a84-db99edf2c268)
+
+![image](https://github.com/user-attachments/assets/5fe6af83-2f5b-47b1-9dd1-4aee6bc409de)
+
+## 致谢
+
+文档合并: [PyMuPDF](https://github.com/pymupdf/PyMuPDF)
+
+文档解析: [Pdfminer.six](https://github.com/pdfminer/pdfminer.six)
+
+文档提取: [MinerU](https://github.com/opendatalab/MinerU)
+
+多线程翻译: [MathTranslate](https://github.com/SUSYUSTC/MathTranslate)
+
+布局解析: [DocLayout-YOLO](https://github.com/opendatalab/DocLayout-YOLO)
+
+## Star History
+
+<a href="https://star-history.com/#Byaidu/PDFMathTranslate&Date">
+ <picture>
+   <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Byaidu/PDFMathTranslate&type=Date&theme=dark" />
+   <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Byaidu/PDFMathTranslate&type=Date" />
+   <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Byaidu/PDFMathTranslate&type=Date" />
+ </picture>
+</a>