views:

676

answers:

6

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 programatically. 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.

+4  A: 

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

You can access them using the file i/o functions. On that note, the best free Python tutorial around is Dive Into Python. It rivals most books.

ryeguy
+15  A: 

Check out this question and this question, which are essentially what you are looking for.

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://www.freebsd.org/cgi/cvsweb.cgi/src/share/dict/web2?rev=1.12;content-type=text%2Fplain

#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.

Paolo Bergantino
Guess I didn't see the dupes in my quick search. Thanks :)
Davy8
Thanks for the edit, I'd give bonus points if I could, but upvote and accept's about all I can do :p
Davy8
+4  A: 

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

Adam Luter
+2  A: 

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

/usr/share/dict/
Eoin Campbell
+1  A: 

For something similar I have used the mozilla English dictionary. It is a zip file (even though it has another extension). Inside you will find en-GB.dic which is the dictionary.

idrosid
+3  A: 

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