javascript 游戏英文单词列表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11493594/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
javascript list of english words for a game
提问by Adam Meyer
I'm making a simple JS game that needs a list of English dictionary words. Will I need to build the list myself, or is it possible to access the system's or browser's spell-check dictionary - or maybe there's another solution?
我正在制作一个简单的 JS 游戏,需要一个英语词典单词列表。我是否需要自己构建列表,或者是否可以访问系统或浏览器的拼写检查字典 - 或者可能有其他解决方案?
回答by Nemanja Trifunovic
You can use AspellEnglish dictionary.
Aspell English dictionary is availabe at: ftp://ftp.gnu.org/gnu/aspell/dict/0index.html.
您可以使用Aspell英语词典。
Aspell 英语词典位于:ftp://ftp.gnu.org/gnu/aspell/dict/0index.html 。
To dump world list from the Aspell dictionary checkout:
从 Aspell 词典检出转储世界列表:
- https://superuser.com/questions/137957/how-to-convert-aspell-dictionary-to-simple-list-of-words
- http://www.commandlinefu.com/commands/view/10619/dump-an-aspell-dictionary-as-a-word-list
- http://aspell.net/man-html/Dumping-the-Contents-of-the-Word-List.html
- https://superuser.com/questions/137957/how-to-convert-aspell-dictionary-to-simple-list-of-words
- http://www.commandlinefu.com/commands/view/10619/dump-an-aspell-dictionary-as-a-word-list
- http://aspell.net/man-html/Dumping-the-Contents-of-the-Word-List.html
The command to dump English list of words should look something like:
转储英文单词列表的命令应该类似于:
aspell -d en dump master | aspell -l en expand > words.txt
回答by maioman
with node you can install random-words
使用节点,您可以安装随机词
npm install random-words
import it and you're done:
导入它,你就完成了:
var randomWords = require('random-words');
console.log(randomWords());
回答by JayTheKay
The wordlist for Firefox spellchecking seems to come from this repository: https://github.com/marcoagpinto/aoo-mozilla-en-dict. So you could download it there to get a word list.
Firefox 拼写检查的词表似乎来自这个存储库:https: //github.com/marcoagpinto/aoo-mozilla-en-dict。所以你可以在那里下载它以获得一个单词列表。
You can also install the dictionary as addon (https://addons.mozilla.org/en-GB/firefox/language-tools/) but I don't know if or how the dictionary-addons can be accessed with JavaScript directly from inside the browser.
您还可以将字典安装为插件(https://addons.mozilla.org/en-GB/firefox/language-tools/),但我不知道是否或如何使用 JavaScript 直接从浏览器里面。
回答by kofifus
you can get a worlist here http://marcoagpinto.cidadevirtual.pt/proofingtoolgui.html.. look for the WORDLIST link on the right
你可以在这里得到一个 worlist http://marcoagpinto.cidadevirtual.pt/proofingtoolgui.html.. 寻找右边的 WORDLIST 链接
回答by Jesse
Was looking for a simple JSON endpoint I could use for a workbook - wound up uploading one to github:
正在寻找一个可以用于工作簿的简单 JSON 端点 - 最后将一个上传到 github:
回答by aryaman
Easiest solution that I found is getting a text or JSON file from anywhere(on web) which contains all the English words(not meanings like in dictionary). I got it from this repository, this contains a text file and a JSON file.
我发现的最简单的解决方案是从任何地方(在网络上)获取一个文本或 JSON 文件,其中包含所有英语单词(不是字典中的意思)。我从这个存储库中得到它,它包含一个文本文件和一个 JSON 文件。
You can easily read data from JSON file using javascript or other programming languages.
您可以使用 javascript 或其他编程语言轻松地从 JSON 文件中读取数据。
回答by x-rw
you can to use this:
你可以使用这个:
https://www.javascriptspellcheck.com/JavaScript_SpellChecking_Dictionaries
https://www.javascriptspellcheck.com/JavaScript_SpellChecking_Dictionaries
there are many languages:
有多种语言:
Afrikaans (South Africa)
American English (USA)
Australian English
Brazil (Modern Brazilian Portuguese)
British English (UK)
Catalan (Catalonia)
Canadian English
Danish Dictionary (Dansk)
Dutch & Flemish (Nederlands)
Gaelic
German Dictionary (Deutsch)
French (Francais)
Frisian (Frysk, Seeltersk & Mooring)
International English
Italian (Italiano)
Malaysian (Bahasa Malaysia)
Portuguese (Portugues - Brazil and Portugal)
Spanish (Espanol - Americas & Spain)
Swedish (Svenska)
Welsh (Cymric)
回答by Aryaveer Singh Rawat
As Linked by @aryaman , I too used that GitHub page when I needed an Array for Auto-correct TextBox. https://github.com/dwyl/english-words/blob/master/words.txt[][1]
正如@aryaman 链接的那样,当我需要一个用于自动更正文本框的数组时,我也使用了该 GitHub 页面。https://github.com/dwyl/english-words/blob/master/words.txt[][1]
But If you are looking for a Javascript Array Soultion, Just Create a Python File in the Same directory as The words.txt file and type this into Python File
但是,如果您正在寻找 Javascript Array Soultion,只需在与 words.txt 文件相同的目录中创建一个 Python 文件并将其输入到 Python 文件中
filepath = 'words.txt'
print("var anyname = [")
with open(filepath) as fp:
for cnt, line in enumerate(fp):
print("'{}',".format(line))
print("]")
Just Copy Paste the Output to your Code File and Done !
只需将输出复制粘贴到您的代码文件中即可!
! Note - It's really big file, I recommend you to use this one from the same respoitory https://github.com/dwyl/english-words/blob/master/words_alpha.txt[][1]. It contains words without any Numbers. Also, Python Script could take 2-3 hours, mine is currently running that's why I'm writing this. I will soon Edit The Answer with Direct Link to File if it is done !
!注意 - 这是一个非常大的文件,我建议您使用来自同一个 repoitory https://github.com/dwyl/english-words/blob/master/words_alpha.txt[][1] 的这个文件 。它包含没有任何数字的单词。此外,Python 脚本可能需要 2-3 个小时,我的当前正在运行,这就是我写这篇文章的原因。如果完成,我将很快使用直接链接到文件来编辑答案!