Пример #1
0
def build_test2(tests):
	n, our_correct, norvig_correct = 0, 0, 0
	for target, incorrect in tests.items():
		for word in incorrect.split():
			n+=1
			if len(word) < 6 or len(word) < 6:
				continue
			our_out = scramble_helpers.suggest(
				word,char_model,similarity_model, word_model_tuple, error_model)
			norvig_out = norvig.correct(word.lower())
			# DEBUGGING
			#print our_out, target, word
			if our_out[0].lower() == target:
				our_correct += 1
			if norvig_out == target:
				norvig_correct += 1
	print "Total misspellings queried " + str(n)
	print "Our correct suggestions: " + str(our_correct/float(n))
	print "Norvig's correct suggestions: " + str(norvig_correct/float(n))
	print
Пример #2
0
def build_test2(tests):
    n, our_correct, norvig_correct = 0, 0, 0
    for target, incorrect in tests.items():
        for word in incorrect.split():
            n += 1
            if len(word) < 6 or len(word) < 6:
                continue
            our_out = scramble_helpers.suggest(word, char_model,
                                               similarity_model,
                                               word_model_tuple, error_model)
            norvig_out = norvig.correct(word.lower())
            # DEBUGGING
            #print our_out, target, word
            if our_out[0].lower() == target:
                our_correct += 1
            if norvig_out == target:
                norvig_correct += 1
    print "Total misspellings queried " + str(n)
    print "Our correct suggestions: " + str(our_correct / float(n))
    print "Norvig's correct suggestions: " + str(norvig_correct / float(n))
    print
Пример #3
0
def build_test1(test):
	f = open(test, "r")
	our_correct = 0
	norvig_correct = 0
	count = 0
	for line in f:
		pair = line.split()
		if len(pair) < 2 or len(pair[0]) < 6 or len(pair[1]) < 6:
			continue
		our_out = scramble_helpers.suggest(
			pair[1],char_model,similarity_model,word_model_tuple, error_model)
		norvig_out = norvig.correct(pair[1].lower())
		if our_out[0].lower() == pair[0].lower():
			our_correct += 1
		if norvig_out.lower() == pair[0].lower():
			norvig_correct += 1
		count += 1
		#print (our_out[0], pair[1],  pair[0])
	print "Total misspellings queried " + str(count)
	print "Our correct suggestions: " + str(our_correct/float(count))
	print "Norvig's correct suggestions: " + str(norvig_correct/float(count))
	print
Пример #4
0
def build_test1(test):
    f = open(test, "r")
    our_correct = 0
    norvig_correct = 0
    count = 0
    for line in f:
        pair = line.split()
        if len(pair) < 2 or len(pair[0]) < 6 or len(pair[1]) < 6:
            continue
        our_out = scramble_helpers.suggest(pair[1], char_model,
                                           similarity_model, word_model_tuple,
                                           error_model)
        norvig_out = norvig.correct(pair[1].lower())
        if our_out[0].lower() == pair[0].lower():
            our_correct += 1
        if norvig_out.lower() == pair[0].lower():
            norvig_correct += 1
        count += 1
        #print (our_out[0], pair[1],  pair[0])
    print "Total misspellings queried " + str(count)
    print "Our correct suggestions: " + str(our_correct / float(count))
    print "Norvig's correct suggestions: " + str(norvig_correct / float(count))
    print