Package nltk :: Package misc :: Module wordfinder
[hide private]
[frames] | no frames]

Module wordfinder

source code

Functions [hide private]
 
revword(word) source code
 
step(word, x, xf, y, yf, grid) source code
 
check(word, dir, x, y, grid, rows, cols) source code
C(tuple)
wordfinder(words, rows=20, cols=20, attempts=50, alph='ABCDEFGHIJKLMNOPQRSTUVWXYZ')
Attempt to arrange words into a letter-grid with the specified number of rows and columns.
source code
 
demo() source code
Function Details [hide private]

wordfinder(words, rows=20, cols=20, attempts=50, alph='ABCDEFGHIJKLMNOPQRSTUVWXYZ')

source code 

Attempt to arrange words into a letter-grid with the specified number of rows and columns. Try each word in several positions and directions, until it can be fitted into the grid, or the maximum number of allowable attempts is exceeded. Returns a tuple consisting of the grid and the words that were successfully placed.

Parameters:
  • words (C(list)) - the list of words to be put into the grid
  • rows (C(int)) - the number of rows in the grid
  • cols (C(int)) - the number of columns in the grid
  • attempts (C(int)) - the number of times to attempt placing a word
  • alph (C(list)) - the alpabet, to be used for filling blank cells
Returns: C(tuple)