Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a project that requires a simple dictionary for checking spelling; it will be large, but will lack definitions. The solution we're currently working on has the base word list in a text file, and customizations (extra words, excluded words) in the DB.

The entire list needs to be loaded (best cached I think) for paginated display and customization using an existing JS widget, so what's the best way to store and load the base word list?

My initial thought was to have a text file with one word per line and write my own loader and cache object, but my boss suggested using a ResourceBundle to leverage the built-in caching. I'm thinking that could be done by using the words as keys with empty values and using the keyset of the bundle.

What would be the best solution to this?

share|improve this question
Algorithm/approach discussions are safely on topic here. There's no need to migrate this question to Stack Overflow. – Adam Lear Aug 26 '11 at 19:52
up vote 7 down vote accepted

In general, the data structure your are looking for is called TRIE.

If you are looking to implement this in javascript, be sure to read John Resig's blog on that subject. He evaluated several techniques for a similar problem, highly recommended.

Also, take a look at this question to find java implementations.

share|improve this answer
I'll definitely look into a trie or DAWG if we run into performance issues; thanks! – Mike Partridge Aug 25 '11 at 14:56

Is this for a language that does not already have dictionary files out there? I'm not 100% certain, but I was pretty sure that the Aspell open sourced dictionaries were available to developers...

share|improve this answer
The app doing the work is written in Java and running on multiple platforms (Linux, Windows), so I don't know if this would be the right solution. – Mike Partridge Aug 25 '11 at 15:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.