46

A friend of mine was talking about a word game she liked to play where you try to convert one word to another (they have the same number of letters) by switching one letter at a time, where each iteration produces a real word.

Example:

MOON --> WOLF
GOON
GOOF
GOLF
WOLF

I figured it'd be a fun little project to write a program to generate solutions, and taking it further, given 2 words, determine if a solution exists and the number of iterations in optimal solution.

Problem is I'm having trouble finding free word lists that I can easily access programmatically. I'm also thinking about using this as an excuse to learn Python, so it'd be great if anyone knows of free word lists and pointers on how to parse and access it from Python. The algorithm for figuring out how to find an optimal path I'll work on my own.

dreftymac
  • 31,404
  • 26
  • 119
  • 182
Davy8
  • 30,868
  • 25
  • 115
  • 173
  • It's a pity that this question has been "closed" since it is one of the first search results for a google search for "word list" or similar, obviously very helpful and searched for. (Maybe there are better variants of the question but they aren't found, so...) To be constructive, let me just suggest to check out http://nltk.org and/or `pip install ntlk` and then `import ntlk ; ntlk.download('words')` to fetch a basic corpus, and thereafter `from nltk.corpus import words ; wordlist = words.words()`. – Max May 27 '22 at 14:11

7 Answers7

74

Options:

  1. Look for /usr/share/dict/words on your common or garden variety Unix install.
  2. http://www.ibiblio.org/webster/
  3. http://wordlist.sourceforge.net/
  4. http://svnweb.freebsd.org/csrg/share/dict/ (click the 'revision' tag of the file 'words')

#4 is the one I used for my own Python experiment into word games, and it worked nicely.

For bonus points, here's something to get you started on your word program:

import re
startwith = "MOON"
endwith = "GOLF"
cklength = re.compile('.{' + str(len(startwith)) + '}(\n)?$', re.I)
filename = "C:/dict.txt"
words = set(x.strip().upper() for x in open(filename) if x.match(cklength))

Words will then be a set of all 4 letter words in the dictionary. You can do your logic from there.

Greg Sadetsky
  • 4,863
  • 1
  • 38
  • 48
Paolo Bergantino
  • 480,997
  • 81
  • 517
  • 436
  • freebsd has switched to Subversion for source control so that link no longer works - here's an updated link http://svnweb.freebsd.org/base/head/share/dict/web2?view=co – Peter Gibson Feb 17 '14 at 04:23
  • For option 1, how do I acquire it as a list. ( do I open and parse or is there a quicker way?) – matttm Aug 31 '17 at 19:15
33

Most unix (which includes osx) have a file /usr/share/dict/words.

Adam Luter
  • 2,193
  • 1
  • 15
  • 20
7

You can find a 2.2mb list of english words here.

You can access them using the file i/o functions.

rvighne
  • 20,755
  • 11
  • 51
  • 73
ryeguy
  • 65,519
  • 58
  • 198
  • 260
6

if you have access to a linux install, there should be some word lists in

/usr/share/dict/
Eoin Campbell
  • 43,500
  • 17
  • 101
  • 157
4

Have a look at the databases in dict.org. These are actually dictionary databases, so you would need to extract the word definitions yourself. You could start from Wordnet.

kgiannakakis
  • 103,016
  • 27
  • 158
  • 194
2

I was having the same issue and with some digging into a scrabble based site, I found several of their word lists in a nice text format. They have an English version at https://www.wordgamedictionary.com/english-word-list/

Cesar Bielich
  • 4,754
  • 9
  • 39
  • 81
  • 5
    Did you vet this list at all? I'm seeing some things that don't look like valid words to me: 'tween, 10000, 1760s, 1st_Earl_Baldwin_of_Bewdley, 365_days, 5-hydroxy-3-methylglutaryl-coenzyme_A_reductase, etc... – james.garriss Oct 04 '12 at 17:11
2

For something similar I have used the Mozilla Firefox English dictionary. Find the English variant you want, e.g. US English, and right-click save to (the "Add to Firefox" button). The file you get is XPI type but it's really a camouflaged ZIP file. Inside you will find en-GB.dic which is the dictionary content.

enter image description here

Inside dictionaries directory:

enter image description here

CoderGuy123
  • 6,219
  • 5
  • 59
  • 89
idrosid
  • 7,983
  • 5
  • 44
  • 41