Пример #1
0
class WordLookup:
    def __init__(self, file_name):
        self.bf = BloomFilter(10000000, 8)
        input_file = open(file_name, "r")
        for file_line in input_file:
            file_line = file_line.rstrip()
            self.bf.add(file_line)
        input_file.close()

    def is_qualified(self, string):
        str_len = len(string)
        if str_len != 6:
            return False
        for i in range(1, str_len - 1):
            first = string[:i]
            second = string[i:]
            if self.bf.lookup(first) and self.bf.lookup(second):
                #print first + '+' + second + '=>' + string
                return True
        return False
Пример #2
0

bit_size = bit_array_size(num_of_items, p)
print("Bit Size: "+str(bit_size))

hash_size = size_of_hash(num_of_items, bit_size)
print("Hash Size: "+str(hash_size))

bf = BloomFilter(num_of_items, hash_size)
word_list = open("word_list.txt").read().splitlines()

for word in word_list:
    bf.add(word)
word_list.close()
    
print(bf.lookup("99"))

print(bf.lookup("donkey")) 
print(bf.lookup("oitqv")) 
print(bf.lookup("fart"))
print(bf.lookup("Max"))
print(bf.lookup("Dichha"))
print(bf.lookup("Khuwalung"))

print("++++Random Word SpellChecker++++")


alpha=""
for i in range(97,123):
    alpha+=chr(i)