typo
Conservative typo correction engine.
The typo object provides Levenshtein-based spelling correction with explicit vocabulary management.
Unlike many text normalization systems, BASA requires users to opt in to typo correction.
Import
from basa import typo
Loading a Vocabulary
Before using typo correction, add words to the vocabulary.
typo.add_to_vocab({
"makan",
"minum",
"berangkat"
})
Correcting Individual Words
typo.correct(
"mkan"
)
Output:
'makan'
Correcting Sentences
typo.correct_text(
"saya mkan dulu"
)
Output:
'saya makan dulu'
Custom Maximum Distance
typo.correct(
"mkan",
max_dist=2
)
The default behavior is intentionally conservative to avoid overcorrection.
Protected Vocabulary
BASA automatically protects normalized slang outputs from typo correction.
Example:
gk
↓
tidak
The word "tidak" is never treated as a typo candidate, preventing interactions between normalization stages.
Vocabulary Management
Add new words:
typo.add_to_vocab({
"tensorflow",
"lightgbm",
"xgboost"
})
This is particularly useful for:
- Technical datasets
- Financial documents
- Domain-specific NLP pipelines
Design Philosophy
The typo engine follows several principles:
- Explicit user control
- Conservative corrections
- Domain adaptability
- Predictable behavior
- Minimal surprises
The long-term roadmap includes:
- Frequency-based ranking
- BK-tree acceleration
- Context-aware corrections
- Regional language support