colin1201/Latin-proofreading
0
Latin Text Proofreading System
A Hugging Face Spaces Gradio app for reviewing Latin OCR output against LLM-corrected text with image alignment.
Features
- Upload OCR text (
.txt) and LLM-proofread text (.txt) - Upload scanned page images (multiple files)
- Optional exact line-to-image alignment with:
- bbox JSON
- hOCR (
.hocr,.html,.xhtml) - ALTO XML (
.xml) - Side-by-side proofreading UI:
- Left: scanned image with focused line box
- Right: OCR line, highlighted LLM changes, editable final text
- Review actions:
- Accept (use LLM line)
- Reject (use OCR line)
- Save manual edit
- Token-level selective acceptance for changed tokens
- Jump to next unresolved changed line
- Accept all unchanged lines
- Export as one ZIP package:
final_proofread.txtreview_log.json
Files
app.py- Main Gradio applicationrequirements.txt- Python dependenciessample_bbox.json- Example bbox input format
Quick Start (Local)
pip install -r requirements.txt
python app.pyHugging Face Spaces Setup
- Create a new Gradio Space.
- Upload:
app.pyrequirements.txtREADME.md- Commit changes and let Space build.
The app should launch automatically with demo.launch().
Input Format Notes
OCR and LLM text files
- Plain UTF-8
.txtfiles - Each line is treated as one review unit
- Line alignment is robust to insertions/deletions
Optional bbox JSON
Use one of these shapes:
{
"pages": [
{
"page_id": 0,
"line_bboxes": [[50, 110, 980, 155], [48, 160, 985, 205]]
},
{
"page_id": 1,
"line_bboxes": [[55, 100, 975, 145]]
}
]
}Or:
{
"0": [[50, 110, 980, 155], [48, 160, 985, 205]],
"1": [[55, 100, 975, 145]]
}Coordinates are pixel values in [x0, y0, x1, y1] order for each page image.
Optional OCR layout files (auto bbox extraction)
You can upload either:
- hOCR file (
.hocr,.html,.htm,.xhtml) withocr_page/ocr_lineandbboxvalues - ALTO XML (
.xml) usingPage+TextLinewithHPOS,VPOS,WIDTH,HEIGHT
The app extracts line boxes in page order and uses them for image highlighting. If both bbox JSON and layout file are provided, bbox JSON is used first.
Export Output
When you click Export Final Package (.zip), the app generates:
final_proofread.txt: consolidated finalized text in reading orderreview_log.json: complete per-line audit log (status, OCR/LLM/final text, page, bbox if available)
Notes
- If neither bbox JSON nor valid hOCR/ALTO layout is provided, the app uses a top-to-bottom estimated line band fallback.
- For best scholarly reproducibility, keep
review_log.jsonwith your final text.
Manual Steps You Need
- You must provide your own OCR and LLM text files (for example
sample_ocr.txtandsample_llm.txt, or your real corpus files). - For exact line highlighting, provide at least one of:
- bbox JSON, or
- hOCR/ALTO layout file.
- Upload page images in the same reading order as the text lines/pages.
