A production-style Python project that converts document files into raw corpus .txt files for downstream tokenization and language model workflows.
- Professional PyQt6 desktop UI
- App icon and menu bar actions (including Open Output Folder)
- Tesseract OCR executable path selection (
tesseract.exe) - Automatic OCR language discovery from installed Tesseract language packs
- Multi-language OCR selection (e.g.,
eng,deu, etc.) - Configurable Office COM ProgIDs for
.docextraction (Word/WPS/custom) - Single-file or full-folder conversion
- Extension filtering in UI
- OCR fallback for low-text PDF pages
- Structured corpus output with paragraph-level
[SEP]separators - Persistent settings (last paths, selected languages, options)
- Built-in System Check button for deployment diagnostics
.pdf.docx.doc(requires Microsoft Word +pywin32OR LibreOffice).png,.jpg,.jpeg,.bmp,.tif,.tiff
doc2pdf/
app/
assets/
app_icon.svg
config.py
services/
converter.py
extractors.py
text_processing.py
ui/
main_window.py
worker.py
main.py
requirements.txt
scripts/
build_windows.ps1
- Install Python 3.10+.
- Install Tesseract OCR for Windows.
- Install dependencies:
pip install -r requirements.txtpython main.pyWorkflow:
- Select
tesseract.exe - Click Load & Detect Languages
- Choose OCR languages
- (Optional) Set Office COM ProgIDs for
.doccompatibility - Choose single file or input folder
- Choose output folder
- Configure options and click Start Conversion
Specify the virtual environment used for the build (recommended):
.\scripts\build_windows.ps1 -VenvPath "D:\code\language_model\tokenization\llmenv"You can pass either the venv folder or python.exe directly:
.\scripts\build_windows.ps1 -VenvPath "D:\code\language_model\tokenization\llmenv\Scripts\python.exe"If -VenvPath is omitted, the script tries in order:
$env:VIRTUAL_ENV(if you already activated a venv).venvin the project folder..\llmenvnext to the project folderpythonon PATH (with a warning)
Clean build (remove previous build/ and dist/ first):
.\scripts\build_windows.ps1 -VenvPath "D:\path\to\your\venv" -CleanDebug build with visible console output (recommended when EXE behaves differently):
.\scripts\build_windows.ps1 -VenvPath "D:\path\to\your\venv" -Clean -ConsoleGenerated executable:
dist/CorpusConverter/CorpusConverter.exe- Runtime log file:
%USERPROFILE%\CorpusConverter\logs\app.log
.docextraction uses Word COM first, then LibreOffice fallback.- If OCR languages are missing, install additional Tesseract language data (
.traineddatafiles). - Output files are generated in UTF-8 encoding.