Skip to content

Commit

Permalink
docs: Update Implementation Details documentation
Browse files Browse the repository at this point in the history
- Expand core processing flow documentation for BabelDOC translation
- Add detailed stages of PDF translation process
- Include comprehensive technical overview of translation workflow
- Link to specific implementation details and source code references
  • Loading branch information
awwaawwa committed Feb 19, 2025
1 parent c6f3c03 commit 72e151a
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 3 deletions.
81 changes: 81 additions & 0 deletions docs/ImplementationDetails/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Implementation Details

```{note}
This documentation may contain AI-generated content. While we strive for accuracy, there might be inaccuracies. Please report any issues via:
- [GitHub Issues](https://github.com/funstory-ai/BabelDOC/issues)
- Community contribution (PRs welcome!)
```

## Core Processing Flow

The BabelDOC translation process consists of several key stages, executed in the following order:

1. **PDF Parsing and IL Creation**
- Extract text content while preserving character-level information
- Maintain font and style information
- Create structured intermediate layer (IL) representation

2. **Layout OCR**
- Process document layout information
- Handle page boundaries and figure elements
- Manage coordinate systems

3. **Paragraph Recognition**
- Group characters into meaningful paragraphs
- Handle special cases like table of contents
- Maintain layout information for typesetting

4. **Style and Formula Processing**
- Identify and preserve mathematical formulas
- Detect and maintain text styles
- Handle special cases like subscripts/superscripts

5. **IL Translation**
- Translate text while preserving document structure
- Maintain formulas and special formatting
- Support concurrent translation

6. **Typesetting**
- Fit components within original paragraph bounds
- Handle mixed language text spacing
- Support first line indentation

7. **Font Mapping**
- Map font identifiers
- Handle font encoding
- Manage font resources

8. **PDF Generation**
- Create new PDF with translated content
- Preserve original formatting and styles
- Support both monolingual and dual-language output

## Technical Details

For detailed implementation information about each stage, please refer to:

```{toctree}
:maxdepth: 1
PDFParsing/PDFParsing
ParagraphFinding/ParagraphFinding
StylesAndFormulas/StylesAndFormulas
ILTranslator/ILTranslator
Typesetting/Typesetting
PDFCreation/PDFCreation
AsyncTranslate/AsyncTranslate
```

```{note}
Some implementation details are available directly in the source code:
- [Layout OCR](https://github.com/funstory-ai/BabelDOC/blob/main/babeldoc/document_il/midend/layout_parser.py)
- [Font Mapping](https://github.com/funstory-ai/BabelDOC/blob/main/babeldoc/document_il/utils/fontmap.py)
```

## API Reference

For information about using the asynchronous translation API, see:

- [Async Translation API](AsyncTranslate/AsyncTranslate.md)
7 changes: 4 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
---
end-before: <!-- github-only -->
---
```

```{toctree}
---
Expand All @@ -19,9 +20,9 @@ caption: Development
maxdepth: 1
---
contributing
CONTRIBUTING
CONTRIBUTOR_REWARD
Code of Conduct <codeofconduct>
License <license>
Code of Conduct <CODE_OF_CONDUCT>
License <../LICENSE>
Changelog <https://github.com/funstory-ai/BabelDOC/releases>
```

0 comments on commit 72e151a

Please sign in to comment.