Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Spell Checking Methods

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!

like image 520
danem Avatar asked May 29 '11 06:05

danem


2 Answers

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/

like image 199
Eevee Avatar answered Sep 22 '22 07:09

Eevee


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..

like image 26
nickf Avatar answered Sep 23 '22 07:09

nickf