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-spellcheckimport 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 installRun tests:
npm testContributions 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