Skip to content

Instantly share code, notes, and snippets.

@ugik
Created January 11, 2017 17:49
Show Gist options
  • Save ugik/080b60b24162483d05f534590c6ec3a8 to your computer and use it in GitHub Desktop.
Save ugik/080b60b24162483d05f534590c6ec3a8 to your computer and use it in GitHub Desktop.
part 6
# return the class with highest score for sentence
def classify(sentence):
high_class = None
high_score = 0
# loop through our classes
for c in class_words.keys():
# calculate score of sentence for each class
score = calculate_class_score_commonality(sentence, c, show_details=False)
# keep track of highest score
if score > high_score:
high_class = c
high_score = score
return high_class, high_score
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment