def main(): path_dict = '/home/idris/word_lists/CROSSWD.TXT' d_word_list = load_word_dictionary( path_dict ) l_words_end_s = [word for word in d_word_list if ends_with_letter(word, 's')] path_output = 'output.txt' fout = open(path_output, 'w') #go through list of words ending with s for word_end_s in l_words_end_s: #go through list of ways to split word_ending_with_s for splits in split_word_once( word_end_s ): if word_in_dict(splits[0], d_word_list) and word_in_dict(splits[1], d_word_list): s = '%s, %s %s\n' % (word_end_s, splits[0], splits[1]) syn_test = '%s_%s' % (splits[0], splits[1]) l_syns = check_synonym(word_end_s, syn_test) fout.write(s)
# email: [email protected] # date: 1-30-2011 import sys sys.path.append('/home/idris/work/npr_puzzles') from util import load_word_dictionary from util import permutate from util import swap_letter from util import check_synonym from util import is_len from util import has_string from util import word_in_dict #dict to hold all words d_words = load_word_dictionary() #dict to hold all words of length 6 with letter q d_6q_words = dict() for word in d_words: if has_string(word, 'q') and is_len(word, 6): d_6q_words[word]=None #dict to hold all words of length with letter q, and 'q' swapped for 'n' d_6n_words = dict() for word in d_6q_words: new_word = swap_letter(word,'n',word.find('q')) d_6n_words[new_word] = word for word in d_6n_words: #get all anagrams of words with q already swapped for n