Пример #1
0
            while True:
                c = file.read(1)
                if not c or not re.match(r"[A-Za-z]", c):
                    break
            index, word = 0, ""

    elif c.isdigit():
        while True:
            c = file.read(1)
            if not c or  (not c.isalpha() and not c.isdigit()):
                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
Пример #2
0
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
Пример #3
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

Пример #4
0
                    break

    elif c.isdigit():
        while True:
            c = file.read(1)
            if (not c) or ((not c.isdigit()) and
                           (not re.match(r"[A-Za-z]", c)) and (not c == "'")):
                index = 0
                word = ""
                break

    else:
        if word == "":
            continue
        before = time.process_time()
        if not check(word):
            after = time.process_time()
            misspellings += 1
            wrong_words.append(word)
        check_time = after - before

        words += 1
        word = ""
        index = 0

print(wrong_words)

print(f"Total words: 								{words: }")
print(f"Total misspelled words: 			        {misspellings: }")

print(f"Total load time: 							{time_load: .2f}")