from flamebroiler import Trie
import resource
import timeit
import sys
import os
import time

words_t = Trie()
words_d = {}
for w in open("/usr/share/dict/words"):
    word = unicode(w.strip().lower())
    words_t[word] = word
    words_d[word] = word

for pair in ["ab", "td", "ym", "yr"]:
    print pair
    d_match = set([words_d[k] for k in words_d.keys() if k.startswith(pair)])
    t_match = set(words_t.suffixes(pair))
    if t_match == d_match:
        print 'yes'
    else:
        print "only in trie (of %s)" % len(t_match)
        print t_match.difference(d_match)
        
        print "only in dict (of %s)" % len(d_match)
        print d_match.difference(t_match)
Example #2
0
from flamebroiler import Trie

fruits = ["apple", "peach", "pear", "mango", "lemon", "lime", "applesauce", "pineapple", "kiwi", "passionfruit"]

trie = Trie()
for fruit in fruits:
    trie[fruit] = fruit

if __name__ == "__main__":
    for fruit in fruits + [fruit.upper() for fruit in fruits]:
        f = trie.get(fruit, False)
        print fruit, "YES %s" % f if f else "NO"

    print trie.suffixes("pe")
from flamebroiler import Trie
import resource
import timeit
import sys
import os
import time

words = Trie()
s = set()
for w in open("/usr/share/dict/words"):
    word = w.strip().lower()
    if word.startswith('ae'):
        s.add(word)

        if word == "aeolist":
            words.print_dot()
        
        words[word] = word
        
        if word == "aeolist":
            words.print_dot()
        if word == "aeolistic":
            words.print_dot()

"""
if len(sys.argv) > 1:
    words.print_dot()
else:
    suffixes = words.suffixes("ae")
    print len(suffixes), len(s)
    print s.difference(set(suffixes))