A lightweight Go library for efficient English word validation using Bloom filters. Perfect for spell-checking, word games, and text validation with minimal memory footprint.
Bloom Words is a Go library that validates English words using Bloom filters—achieving fast lookups with minimal memory usage. Perfect for spell-checking, word validation, and text filtering.
- 🚀 Fast Lookup: O(1) constant-time word lookup using Bloom filter
- 💾 Memory Efficient: Compressed filter using bitsets, much smaller than storing all words
- 📖 Common English Words: Pre-built filter with top 10,000 English words
- 📦 Lightweight: Entire filter embedded in binary, only ~12KB
- 🧪 Well Tested: Includes comprehensive test suite
Quick Stats:
- 10,000 common English words compressed into ~12KB
- Sub-microsecond lookups - test a word in less than 1 microsecond
- Minimal false positive rate: ~1%, optimized for top common words
- Zero false negatives - if a word exists, you'll always find it
go get github.com/oosawy/bloomwordspackage main
import (
"fmt"
"log"
"github.com/oosawy/bloomwords"
)
func main() {
// Initialize the Bloom filter
bw, err := bloomwords.Init()
if err != nil {
log.Fatal(err)
}
// Test if a word exists in the dictionary
if bw.Test("hello") {
fmt.Println("'hello' is a valid word")
}
if !bw.Test("xyzabc") {
fmt.Println("'xyzabc' is likely not a valid word")
}
}Bloom Words uses Go's go:embed directive to embed the pre-built Bloom filter (filter/bloom_words.bf) directly into the binary. This eliminates the need to load external files at runtime and removes external dependencies. The embedded filter is loaded into memory during initialization, and all subsequent word lookups execute in constant O(1) time against this in-memory data.
To rebuild the Bloom filter from the word list:
go run ./cmd/build/build.goThis reads from datasets/common_english_words.txt and generates a new filter/bloom_words.bf.
The English word dataset used in this project is sourced from Common English words on Kaggle.
Run the test suite:
go test -vMIT