javascript list of english words for a game
Asked Answered
M

10

25

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?

Moffatt answered 15/7, 2012 at 16:26 Comment(4)
Have you checked out this? dreamsteep.com/projects/the-english-open-word-list.html You could at least get the words from that list which would remove the task of handwriting every single word.Lesialesion
Use the list from a friendly neighborhood Linux installation. /usr/share/dict/words has almost 100,000 words in it.Revers
That English Open Word List looks great! But somewhat dated...looks like it hasn't been updated in 15 years (not a HUGE deal, but yes, lots of words get added each year)Introject
You can take a look at Aspell as well. It has english dictionary (ftp.gnu.org/gnu/aspell/dict/0index.html). To dump world list from the dictionary checkout superuser.com/questions/137957/….Chammy
C
8

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:

The command to dump English list of words should look something like:

aspell -d en dump master | aspell -l en expand > words.txt
Chammy answered 16/5, 2016 at 12:33 Comment(0)
C
5

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.

Callboard answered 29/9, 2018 at 14:0 Comment(0)
H
4

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());

requirebin

Handclasp answered 16/5, 2016 at 12:51 Comment(1)
Worth noting that Random Words includes a very small subset of the English languageTitration
C
4

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.

Coincidental answered 19/5, 2016 at 21:28 Comment(1)
Careful, there are some naughty and rather offensive words in here. Depending on their use, they may not be words you want appearing in your product.Ladonnalady
L
3

Was looking for a simple JSON endpoint I could use for a workbook - wound up uploading one to github:

https://gist.githubusercontent.com/jesseditson/1e6b2b524814320515ccfe7e2f856eda/raw/17d61fa1e80e14b13c4525b09f84148772586b59/words.json

Landfall answered 7/5, 2018 at 18:51 Comment(0)
P
1

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)
Presswork answered 24/10, 2019 at 3:20 Comment(0)
F
1

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 !

Forgave answered 18/1, 2020 at 11:4 Comment(0)
T
1

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']
Titration answered 21/9, 2021 at 15:49 Comment(0)
F
0

you can get a worlist here http://marcoagpinto.cidadevirtual.pt/proofingtoolgui.html .. look for the WORDLIST link on the right

Fourinhand answered 18/7, 2016 at 7:34 Comment(0)
C
0

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;
}
Christmastide answered 12/7, 2023 at 11:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.