Made score ratios much more consistent across the board

This commit is contained in:
Jacob Henry 2018-11-20 17:44:44 -05:00
parent a15ae0fd11
commit 165cb7bc42
3 changed files with 4 additions and 7 deletions

View File

@ -14,7 +14,7 @@ job_range = "AllJobs" # Note that the first row is headers
point_range = "PointRange" point_range = "PointRange"
# How tolerant of spelling errors in names to be # How tolerant of spelling errors in names to be
SHEET_LOOKUP_THRESHOLD = 0.8 SHEET_LOOKUP_THRESHOLD = 80.0
JOB_VAL = 1 JOB_VAL = 1
LATE_VAL = 0.5 LATE_VAL = 0.5

View File

@ -13,7 +13,7 @@ import slack_util
SHEET_ID = "1lPj9GjB00BuIq9GelOWh5GmiGsheLlowPnHLnWBvMOM" SHEET_ID = "1lPj9GjB00BuIq9GelOWh5GmiGsheLlowPnHLnWBvMOM"
MIN_RATIO = 0.8 MIN_RATIO = 80.0
def alert_user(slack: SlackClient, brother: scroll_util.Brother, saywhat: str) -> None: def alert_user(slack: SlackClient, brother: scroll_util.Brother, saywhat: str) -> None:

View File

@ -51,10 +51,7 @@ async def scroll_callback(slack: SlackClient, msg: dict, match: Match) -> None:
sn = int(query) sn = int(query)
result = find_by_scroll(sn) result = find_by_scroll(sn)
except ValueError: except ValueError:
try:
result = await find_by_name(query) result = await find_by_name(query)
except BrotherNotFound:
pass
if result: if result:
result = "Brother {} has scroll {}".format(result.name, result.scroll) result = "Brother {} has scroll {}".format(result.name, result.scroll)
else: else:
@ -96,9 +93,9 @@ async def find_by_name(name: str, threshold: Optional[float] = None) -> Brother:
# Do fuzzy match # Do fuzzy match
found, score = process.extractOne(name, all_names) found, score = process.extractOne(name, all_names)
score = score / 100.0
found_index = all_names.index(found) found_index = all_names.index(found)
found_brother = brothers[found_index] found_brother = brothers[found_index]
print(score)
if (not threshold) or score > threshold: if (not threshold) or score > threshold:
return found_brother return found_brother
else: else: