13

Hey, I'm making a Web Based anagram game for fun and practice. The game presents the player with a word and the player needs only to construct new words out of letters contained in the given word. Where I am running into trouble is spellchecking the submitted words for validation purposes.

I initially thought that this would be fairly trivial, and my first solution was to just copy the dictionary file that is located at usr/share/dict and compare the submitted answers to the words in that file. This however fails when dealing with different forms of a word. For instance, the dictionary has the word "ask", but if the user were to enter the word "asks", it would be considered wrong.

Knowing that I can't hope to write a functional spellchecking algorithm (nor do I want to spend the time trying to tackle that) I thought that I may be able to use the browsers built in spell checking capabilities. But my searching for an answer to this hasn't produced any useful results.

Is there a way to use the browsers spellchecking capabilities, perhaps using javascript or something? And if not, how might I best approach this problem?

Thanks!

sorin
  • 161,544
  • 178
  • 535
  • 806
danem
  • 1,495
  • 5
  • 19
  • 35
  • there are premade libraries that can do this for your, i will post the link as soon as i find it – Ibu May 29 '11 at 06:05

4 Answers4

8

John Resig (of jQuery fame) recently wrote a series of blog posts about fast spell checking for a Javascript-based anagram game he's working on.

http://ejohn.org/blog/dictionary-lookups-in-javascript/
http://ejohn.org/blog/javascript-trie-performance-analysis/
http://ejohn.org/blog/revised-javascript-dictionary-search/

You might be able to skip to the last one where he wraps up all his findings there. It is quite in depth, measuring up look-up speed, download time, initialization time..

nickf
  • 537,072
  • 198
  • 649
  • 721
4

JavaScript spell-checking libraries do exist. I ran across this a little while ago: http://www.chrisfinke.com/2011/03/31/announcing-typo-js-client-side-javascript-spellchecking/

Eevee
  • 47,412
  • 11
  • 95
  • 127
  • 1
    I've just checked it. it's meant to be used for Chrome extensions. It's un-usable for anything else. – vsync Jan 13 '14 at 20:14
  • 1
    @vsync the second paragraph says: "there's no reason it wouldn't work in other JavaScript environments" – Eevee Jan 14 '14 at 02:35
  • 1
    I tried it just yesterday on my FF, and it flipped on me with an exception about "CHROME" something. then I read on the project's page in Github: "Typo.js is a JavaScript spellchecker that uses Hunspell-style dictionaries. Its main use is to allow Chrome extensions to perform client-side spellchecking." – vsync Jan 14 '14 at 09:32
  • typojs is extremely slow. If you hand it gibberish long words it can't handle it. – Arash Saidi Mar 29 '16 at 21:45
2

There are plenty of free dictionaries online that include plurals, hyphenations etc.

E.g. a quick Google search found these dictionaries which support the spell checking functions of OpenOffice.

Have a Google. You can always aggregate several dictionaries into a massive super-dictionary!

Have fun.

Rob.

orftz
  • 1,138
  • 13
  • 22
ITRob
  • 61
  • 5
2

I've used JSpell Evolution before. Once you get past the annoying installation/setup process, it works pretty well.

Kon
  • 27,113
  • 11
  • 60
  • 86