Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce917e6
commit 1e5dc44
Showing
13 changed files
with
256 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env python | ||
# encoding: utf-8 | ||
""" | ||
determine.py | ||
Created by Christopher K. Lee on 2011-12-07. | ||
Copyright (c) 2011 __MyCompanyName__. All rights reserved. | ||
""" | ||
import time | ||
|
||
def determineAnswer(results, choices, correct): | ||
determine_start_time = time.time() | ||
points = [0, 0, 0] | ||
confidence = 0 | ||
|
||
# Loop through all score dict results | ||
for r in results: | ||
# Score set cannot be empty | ||
if ( r != {}): | ||
|
||
# Max and min values | ||
highestChoice = "" | ||
a1 = min(r.values()) | ||
z1 = max(r.values()) | ||
|
||
# Iterate through dict | ||
for key, val in r.iteritems(): | ||
if val == z1: # If value is max | ||
for c in choices: | ||
if key == c: # Max key is choice | ||
points[choices.index(c)] += 1 # Add point value | ||
highestChoice = key | ||
t = float(val) | ||
if a1 != 0: | ||
r[key] = t/a1 # Normalize | ||
|
||
# Find normalized min val | ||
a2 = min(r.values()) | ||
z2 = max(r.values()) | ||
|
||
# Multiplier of 1st vs 2nd | ||
for val in r.itervalues(): | ||
if val != a2 and val != z2: | ||
confidence += r[highestChoice]/val | ||
|
||
determine_stop_time = time.time() | ||
de_time = (determine_stop_time - determine_start_time) | ||
|
||
# Return true if correct w/ confidence | ||
answer_index = points.index(max(points)) | ||
if answer_index == correct: | ||
return [[1, answer_index], confidence, de_time] | ||
else: | ||
return [[0, answer_index], confidence, de_time] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Which of these describes the tail of a healthy platypus | ||
['platypus', 'tail', 'describes', 'healthy'] | ||
{'healthy': (66, 'JJ'), 'tail': (24, 'NN'), 'describes': (26, 'NNS'), 'platypus': (0, 'NN')} | ||
{'short': (619, 'JJ'), 'long': (1285, 'RB'), 'fat': (80, 'JJ'), 'strong': (569, 'JJ'), 'squishy': (0, 'JJ'), 'pinkish': (0, 'NN')} | ||
{} | ||
{'fat and strong': 31, 'short and pinkish': 21, 'long and squishy': 61} | ||
{'fat and strong': 87436, 'short and pinkish': 43, 'long and squishy': 41256} | ||
{'fat and strong': 35894, 'short and pinkish': 0, 'long and squishy': 0} | ||
##### | ||
Total Time: 94.278013 | ||
NLTK Time: 92.599376 | ||
AI Time: 1.678637 | ||
URL Time: 0.658323 | ||
Keyword (Q) Time: 26.682972 | ||
Keyword (A) Time: 21.475645 | ||
Tokens (Q) Time: 0.000251 | ||
Tokens (URL) Time: 44.440508 | ||
Map Instance Time: 0.023398 | ||
Score1 Time: 0.128347 | ||
Score2 Time: 0.101162 | ||
Score3 Time: 0.341729 | ||
Score4 Time: 0.425678 | ||
##### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Which sport do players use a stick to cradle the ball | ||
['sport', 'players', 'stick', 'ball'] | ||
{'players': (33, 'NNS'), 'sport': (20, 'NN'), 'stick': (59, 'NN'), 'ball': (109, 'NN')} | ||
{'lacrosse': (0, 'NN'), 'field': (432, 'NN'), 'hockey': (1, 'NN'), 'ice': (56, 'NN')} | ||
{'lacrosse': 156, 'field hockey': 19} | ||
{'lacrosse': 156, 'ice hockey': 24, 'field hockey': 114} | ||
{'lacrosse': 276910, 'ice hockey': 5484, 'field hockey': 71631} | ||
{'lacrosse': 105350, 'ice hockey': 184708, 'field hockey': 210210} | ||
|
||
##### | ||
Total Time: 71.615634 | ||
NLTK Time: 70.140234 | ||
AI Time: 1.475400 | ||
URL Time: 0.645202 | ||
Keyword (Q) Time: 29.591298 | ||
Keyword (A) Time: 26.574528 | ||
Tokens (Q) Time: 0.000405 | ||
Tokens (URL) Time: 13.974003 | ||
Map Instance Time: 0.007040 | ||
Score1 Time: 0.032136 | ||
Score2 Time: 0.019258 | ||
Score3 Time: 0.151532 | ||
Score4 Time: 0.620232 | ||
##### |
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters