Exemple #1
0
def ansChecker(trial):
    trial_bag = sanitize.bag_of_words(trial)
    scores = []
    for i in range(len(bags)):
        scores.append(score(bags[i], trial_bag))
    sorter = sorted(range(len(scores)), key=lambda k: scores[k])
    sorter = sorter[::-1]
    bestGuess = []
    bestGuess.append(responses[sorter[0]])
    bestGuess.append(responses[sorter[1]])
    bestGuess.append(responses[sorter[2]])
    bestGuessScores = []
    bestGuessScores.append(grades[sorter[0]])
    bestGuessScores.append(grades[sorter[1]])
    bestGuessScores.append(grades[sorter[2]])
    return (bestGuess, bestGuessScores)
Exemple #2
0
#run(host="0.0.0.0", port=8090)
#we use:

import sanitize
from bow_classifier import score

responses = []
grades = []
f = open('responses.txt')
for line in f:
    s = line.split(':')
    grades.append(int(s[0]))
    responses.append(s[1])
f.close()

bags = [sanitize.bag_of_words(response) for response in responses]


def ansChecker(trial):
    trial_bag = sanitize.bag_of_words(trial)
    scores = []
    for i in range(len(bags)):
        scores.append(score(bags[i], trial_bag))
    sorter = sorted(range(len(scores)), key=lambda k: scores[k])
    sorter = sorter[::-1]
    bestGuess = []
    bestGuess.append(responses[sorter[0]])
    bestGuess.append(responses[sorter[1]])
    bestGuess.append(responses[sorter[2]])
    bestGuessScores = []
    bestGuessScores.append(grades[sorter[0]])
Exemple #3
0
import sanitize
from bow_classifier import score

responses = []
grades = []
f = open('responses.txt')
for line in f:
    s = line.split(':')
    grades.append(int(s[0]))
    responses.append(s[1])
f.close()
print grades
bags = [sanitize.bag_of_words(response) for response in responses]

print "What is entropy?"
trial = raw_input()
print
print

trial_bag = sanitize.bag_of_words(trial)
print trial_bag
print
scores = []
for i in range(len(bags)):
    scores.append(score(bags[i], trial_bag))

sorter = sorted(range(len(scores)), key=lambda k: scores[k])
sorter = sorter[::-1]

for i in range(len(bags)):
    print scores[sorter[i]], ":  ", responses[sorter[i]]