Esempio n. 1
0
dict = dictionary.load(dictionary_name)
if dict is None:
    print "dictionary load failed"
    sys.exit(-1)

text_file = open(text_file_name, "rb")
misspelled = set()
num_total = 0
for line in text_file:
    line = line.replace("-", " ")
    for word in line.split():
        word = sanitize_word(word)
        if len(word) == 0:
            continue
        if not dictionary.check(dict, word):
            num_total += 1
            misspelled.add(word)
text_file.close()

print misspelled
print "dictionary size: %d" % dictionary.size(dict)
print "num misspelled: %d" % num_total
print "num unique: %d" % len(misspelled)

dictionary.unload(dict)

stop = time.clock()
print "time (s):", stop - start

Esempio n. 2
0
                break
            index, word = 0, ""
    elif index > 0:
        words++
        before = time.process_time()
        mispelled = not check(word)
        after = time.process_time()

        time_check += after-before

        if mispelled:
            print(word)
            mispellings++
        index, word = 0, ""
file.close()

before = time.process_time()
n = size()
after = time.process_time()

time_size = after-before

before = time.process_time()
unloaded = unload()
after = time.process_time()

if not unload:
    print(f"Could not unload  {dictionary}")
    exit(1)

start = time.clock()

dict = dictionary.load(dictionary_name)
if dict is None:
    print "dictionary load failed"
    sys.exit(-1)

text_file = open(text_file_name, "rb")
misspelled = set()
num_total = 0
for line in text_file:
    line = line.replace("-", " ")
    for word in line.split():
        word = sanitize_word(word)
        if len(word) == 0:
            continue
        if not dictionary.check(dict, word):
            num_total += 1
            misspelled.add(word)
text_file.close()

print misspelled
print "dictionary size: %d" % dictionary.size(dict)
print "num misspelled: %d" % num_total
print "num unique: %d" % len(misspelled)

dictionary.unload(dict)

stop = time.clock()
print "time (s):", stop - start