A 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.
npm install balochi-spellcheck
import SpellChecker from "balochi-spellcheck";
// Initialize spellchecker
const checker = new SpellChecker();
const SpellChecker = require("balochi-spellcheck");
// Initialize spellchecker
const checker = new SpellChecker();
<script src="https://unpkg.com/balochi-spellcheck"></script>
<!-- or -->
<script src="https://cdn.jsdelivr.net/npm/balochi-spellcheck"></script>
<script>
const checker = new SpellChecker();
// Check correctness
console.log(checker.isCorrect("جام"));
// → true
console.log(checker.isCorrect("جامف"));
// → false
// Get suggestions
console.log(checker.suggest("جامف", 2, 5));
// → ["جامی", "جامگ", "جامو", "جام", "جا"]
Creates a spellchecker instance.
customWords
(Array) — Optional wordlist. Defaults to SayadGanj data.
Returns true
if word
exists in the dictionary, otherwise false
.
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
This package uses ~16,000 words from the SayadGanj Dictionary. Full credit goes to the dictionary maintainers and the wider Balochi linguistic community.
- 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
Clone and install:
git clone https://github.com/umairayub79/balochi-spellcheck.git
cd balochi-spellcheck
npm install
Run tests:
npm test
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
MIT License © 2025 Umair Ayub
- SayadGanj Dictionary — primary data source
- Balochi language community for keeping the language alive digitally
- Open-source libraries: fast-levenshtein