checking words in a dictionary [closed]

我的未来我决定 提交于 2020-01-11 03:27:09

问题


I need to determine if an unknown 5 or 6 letter string is a valid word, i.e. is in the dictionary. I could submit the string/word to an online dictionary, but I need to check this string/word, which will be different each time, for about 100 to 150 times. This seems to be a bit time consuming.

My next thought would be to try to get a dictionary program of my own. It would need to be in Java as my program is written in Java. Does the Java API already have a class for doing this? Can I get a descent one that someone has already coded, and all I have to do is submit the string/word to it?

My program is not being used for spell checking. I want to write a program for unscrambling the Jumbled Word Puzzles when I get stuck on a scrambled word. Thanks for your suggestions.


回答1:


You could use one of the open source dictionaries and load it into a database: ftp://ftp.cerias.purdue.edu/pub/dict/ and ftp://ftp.ox.ac.uk/pub/wordlists/




回答2:


For scrambled words, you might want to look at the Jumble algorithm, an implementation of which is seen here.




回答3:


If you don't need spell checking this would be really easy. Just load all your words into a HashSet and then check to see if that set contains the word you want to test. There are tons of word lists available.

If you do need a spell checker, then check out aspell or other free APIs.




回答4:


aspell and its associated word lists and dictionaries might be the answer.




回答5:


I think aspell has a Java version.

edit: actually it looks like you might do better with this aspell spinoff called Jazzy.




回答6:


Maybe you can check some wordlist: http://wordlist.sourceforge.net/

This page has some word lists in text format, so you can process in Java yourself, most easily using a HashSet. You need to use more efficient data structures if efficiency is important.




回答7:


Maybe you could try Peter Norvig's spelling checker. I think it's an elegant way to get 80-90% accuracy.



来源:https://stackoverflow.com/questions/2032064/checking-words-in-a-dictionary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!