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

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

问题描述

嘿,我正在制作一个基于 Web 的字谜游戏,以供娱乐和练习.游戏向玩家展示一个单词,玩家只需要从给定单词中包含的字母中构造新单词.我遇到麻烦的地方是对提交的单词进行拼写检查以进行验证.

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/share/dict 的字典文件,并将提交的答案与该文件中的单词进行比较.然而,这在处理单词的不同形式时失败了.例如,字典里有ask"这个词,但是如果用户输入asks"这个词,就会被认为是错误的.

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/annoucing-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天全站免登陆