How chuajeromepython/bert-spellchecker works
This repository is a local OCR-text correction tool: a terminal user submits text, SymSpell handles spelling and word-boundary errors, and BERT reranks candidates for contextual real-word errors before the result is displayed or saved. Separate scripts prepare domain text and fine-tune the BERT model; synthetic-case generation and accuracy scoring support evaluation. The main script’s excerpt omits some entry-point details, so those workflow links rely on the README; unsampled implementation details are not inferred.
Main entry points: BERT-spellchecker.py Correction CLI · run_accuracy_tests.py Pipeline accuracy scoring · prepare_finetune_data.py Training data preparation · train.txt Train and validation text
Components 13
Correction runtime
- Correction CLI
BERT-spellchecker.py - SymSpell correction
BERT-spellchecker.py - BERT reranking
BERT-spellchecker.py - Fine-tuned model
finetuned-bert-spellchecker
Model preparation
- Domain text
finetune_data/raw - Training data preparation
prepare_finetune_data.py - Train and validation text
finetune_data/train.txt - BERT fine-tuning
finetune_bert.py
Evaluation tools
- Synthetic case generator
gen_synthetic_cases.py - Accuracy cases
accuracy_tests/test_cases.json - Pipeline accuracy scoring
accuracy_tests/run_accuracy_tests.py - Score history
accuracy_tests/results
Other components
- Terminal user
Connections 14
- Terminal user → Correction CLI: enters text
README.md - Correction CLI → SymSpell correction: runs stage one
README.md - Correction CLI → BERT reranking: runs stage two
README.md - Correction CLI → Terminal user: prints or saves
README.md - SymSpell correction → BERT reranking: passes corrected text
BERT-spellchecker.py - BERT reranking → Fine-tuned model: loads model
BERT-spellchecker.py - Domain text → Training data preparation: reads text
prepare_finetune_data.py - Training data preparation → Train and validation text: writes splits
prepare_finetune_data.py - Train and validation text → BERT fine-tuning: loads splits
finetune_bert.py - BERT fine-tuning → Fine-tuned model: saves model
finetune_bert.py - Synthetic case generator → Accuracy cases: generates cases
- Pipeline accuracy scoring → Accuracy cases: loads cases
accuracy_tests/run_accuracy_tests.py - Pipeline accuracy scoring → Correction CLI: loads and calls
accuracy_tests/run_accuracy_tests.py - Pipeline accuracy scoring → Score history: saves scores
accuracy_tests/run_accuracy_tests.py