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?
You can use Aspell English dictionary.
Aspell English dictionary is availabe at: ftp://ftp.gnu.org/gnu/aspell/dict/0index.html.
To dump world list from the Aspell dictionary checkout:
- 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
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.
You can easily read data from JSON file using javascript or other programming languages.
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());
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.
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.
Was looking for a simple JSON endpoint I could use for a workbook - wound up uploading one to github:
you can to use this:
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)
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]
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
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 !
I recently found the following npm repo which contains a list of English words from here.
https://github.com/danakt/spell-checker.js
npm i spell-checker-js
const spell = require('spell-checker-js')
// Load dictionary
spell.load('en')
// Checking text
const check = spell.check('Some text to check, blahblahblah, olololo')
console.log(check)
// -> ['blahblahblah', 'olololo']
you can get a worlist here http://marcoagpinto.cidadevirtual.pt/proofingtoolgui.html .. look for the WORDLIST link on the right
try this:
let theWord = 'green'
const validateWord = async() => {
let failed = false;
//Check if it is a valid english word
await fetch(
`https://api.dictionaryapi.dev/api/v2/entries/en/${theWord}`
).then((response) => {
if (response.status == "404") {
alert("Please Enter Valid Word");
failed = true;
}
});
return !failed;
}
© 2022 - 2024 — McMap. All rights reserved.
/usr/share/dict/words
has almost 100,000 words in it. – Revers