javascript list of english words for a game

Viewed 21906

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?

9 Answers

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.

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']
Related