Skip to content

Instantly share code, notes, and snippets.

@lettergram
Last active December 29, 2018 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lettergram/4289f01253ce747fc9b2f2ce0e49e6e0 to your computer and use it in GitHub Desktop.
Save lettergram/4289f01253ce747fc9b2f2ce0e49e6e0 to your computer and use it in GitHub Desktop.
question_dict = {
"who","what","where","when","why","how","which","?"
}
command_dict = {
"please","don't","shut","fold","open","close","mix","turn",
"pour","fill","put","add","chop","slice","serve","spread","get",
"heat","grill","hold","swim","swing","listen","hold","pick",
"take","fetch","roll","jump","stand","crouch","hide","crack",
"write","use","order","draw","paint","set","eat","drink","stick",
"cook","bring","sit","stop","play","buy","shop","explain","tidy",
"move","switch","improve","behave","sort","go","fly","flip"
}
correct_questions, correct_statements = 0,0
correct_commands, correct = 0,0
total_questions, total_statements = 0,0
total_commands, total = 0,0
for i in range(len(comments)):
comment = comments[i].lower()
category = comment_categories[i].lower()
classified_category = "statement"
for word in comment.split(" "):
if word in question_dict:
classified_category = "question"
elif word in command_dict:
classified_category = "command"
if category == classified_category:
correct += 1
if category == "question":
correct_questions += 1
elif category == "statement":
correct_statements += 1
elif category == "command":
correct_commands += 1
if category == "question":
total_questions += 1
elif category == "statement":
total_statements += 1
elif category == "command":
total_commands += 1
total += 1
print("Accuracy (questions): %3.2f"
% (float(correct_questions) / float(total_questions)))
print("Accuracy (statements): %3.2f"
% (float(correct_statements) / float(total_statements)))
print("Accuracy (commands): %3.2f"
% (float(correct_commands) / float(total_commands)))
print("Accuracy (Overall): %3.2f" % (float(correct) / float(total)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment