JavaScript的拼写检查方法 [英] Javascript Spell Checking Methods

查看:268
本文介绍了JavaScript的拼写检查方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做的乐趣和实践基于Web的游戏字谜。本场比赛presents玩家用一个单词,玩家只需要构造新词出包含在给定字字母。在那里我遇到了麻烦拼写检查提交的文字进行验证。

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.

我最初以为,这将是相当琐碎,我的第一个解决方案是只复制位于USR /共享/字典词典文件和比较提交答案,该文件中的话。不同形式的一句话时,这却会失败。例如,字典里的单词问,但如果用户要输入单词问道,这将被视为错了。

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.

有没有办法使用浏览器的拼写检查功能,也许是使用JavaScript或东西的方法吗?如果没有,我怎么最好的办法这个问题可能?

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?

谢谢!

推荐答案

JavaScript的拼写检查库确实存在。我碰到这个跑了一会儿前:的http://www.chrisfinke.com/2011/03/31/announcing-typo-js-client-side-javascript-spellchecking/

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/

这篇关于JavaScript的拼写检查方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆