Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Free word list for use programmatically? [closed]

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.

like image 482
Davy8 Avatar asked Apr 21 '09 14:04

Davy8


1 Answers

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.

like image 146
Paolo Bergantino Avatar answered Oct 20 '22 12:10

Paolo Bergantino