Word Games

Overview


Retrieving a List of Words


One of the first steps to analyzing English is to first get a list of English words. Various sources publish English words lists on the Internet.

MIT hosts a list of 10000 comon words at MIT word list

Another list hosted on github (github list) can be found at English word list

Word lists can be hosted in different data formats. In the example lists given above, the file is a simple text file with each word appearing on a new line. That is, each word is separated by a


let data = await $ajax('https://raw.githubusercontent.com/dwyl/english-words/master/words.txt');
let words = data.split('\n').filter(p=>p.trim()!=='');
					
Try it!


Filtering Words


One of the common tasks you will have to with a list of words is to filter the list to match some condition. For example, the popular game Wordle is a game where a player tries to guess a five letter word. This means that only words with 5 letters are relevant to the game.

Filtering words is easy using the filter array function. In the present case, the following code will create a new list of words that are only 5 characters in length.


let words5 = words.filter(p=>p.length===5);
					
Try it!


Contents