balochi-spellcheck
v1.0.0
Published
Balochi spellchecker using BK-tree and Levenshtein distance
Downloads
7
Maintainers
Readme
📖 Balochi Spellchecker
A production-ready spellchecker for the Balochi language, built using BK-trees and Levenshtein distance.
This library lets you:
- ✅ Verify if a Balochi word is spelled correctly
- 🔍 Generate suggestions for misspelled words
- 📦 Use it in Node.js, web apps, or as a base for APIs/CLIs
The wordlist (~16,000 words) is sourced from the SayadGanj Dictionary, one of the most comprehensive Balochi lexicons available.
🚀 Installation
npm install balochi-spellcheck✨ Usage
import SpellChecker from "balochi-spellcheck";
// Initialize spellchecker
const checker = new SpellChecker();
// Check correctness
console.log(checker.isCorrect("جام"));
// → true
console.log(checker.isCorrect("جامف"));
// → false
// Get suggestions
console.log(checker.suggest("جامف", 2, 5));
// → ["جامی", "جامگ", "جامو", "جام", "جا"]⚙️ API Reference
new SpellChecker(customWords = [])
Creates a spellchecker instance.
customWords(Array) — Optional wordlist. Defaults to SayadGanj data.
.isCorrect(word: string): boolean
Returns true if word exists in the dictionary, otherwise false.
.suggest(word: string, maxDist = 2, limit = 5): string[]
Returns a ranked array of suggestions.
word(string) — Input word to checkmaxDist(number) — Maximum edit distance allowed (default2)limit(number) — Maximum number of suggestions (default5)
Ranking is done by:
- Lowest edit distance
- Closest word length
📚 Wordlist Source
This package uses ~16,000 words from the SayadGanj Dictionary. Full credit goes to the dictionary maintainers and the wider Balochi linguistic community.
🌍 Real-world Applications
- Spellchecking for editors, keyboards, or search bars
- Autocomplete in Balochi typing tools
- Search improvement (catching typos in queries)
- Language research and digital preservation of Balochi
🛠 Development
Clone and install:
git clone https://github.com/umairayub79/balochi-spellcheck.git
cd balochi-spellcheck
npm installRun tests:
npm test🤝 Contributing
Contributions are welcome!
- Fork the repo
- Add features / bugfixes
- Submit a PR
We especially encourage contributions in:
- Expanding/validating the wordlist
- Improving suggestion ranking
- Adding transliteration & grammar support
🗺 Roadmap
- [ ] Publish hosted REST API
- [ ] Add browser-optimized build (ESM/CDN)
- [ ] Provide Balochi → Latin transliteration helpers
- [ ] Support predictive typing models
📜 License
MIT License © 2025 Umair Ayub
⭐ Acknowledgements
- SayadGanj Dictionary — primary data source
- Balochi language community for keeping the language alive digitally
- Open-source libraries: fast-levenshtein
