Skip to content

Commit

Permalink
Merge pull request #406 from UCF/hf-catalog-match-code
Browse files Browse the repository at this point in the history
Updated to match using plan code when possible
  • Loading branch information
jmbarne3 authored Jan 9, 2024
2 parents 265f01f + 16a3283 commit 1597bb0
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions programs/utilities/catalog_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,33 @@ def match(self, catalog_entry):
matched with this MatchableProgram by program name, and stores
the match and its match score if it does.
"""
match_score = fuzz.token_sort_ratio(
self.name_clean,
catalog_entry.name_clean
match_score = self.__get_code_match(
catalog_entry
)

if match_score != 100:
match_score = fuzz.token_sort_ratio(
self.name_clean,
catalog_entry.name_clean
)

if match_score >= self.__get_match_threshold(catalog_entry):
self.matches.append((match_score, catalog_entry))


def __get_code_match(self, catalog_entry):
"""
Tries to match the "code" field with the
plan_code of the program.
"""
if catalog_entry.data and \
'code' in catalog_entry.data and \
self.program.plan_code == catalog_entry.data['code']:
return 100

return 0


def get_best_match(self):
"""
Returns the match in self.matches with the highest match score.
Expand Down Expand Up @@ -326,6 +346,8 @@ def clean_name(program_name):
"""
name = program_name

name = program_name.replace(' Undergraduate', '').replace(' Graduate', '')

# Ensure we're working with a str object, not bytes:
if type(name) is bytes:
name = name.decode()
Expand Down

0 comments on commit 1597bb0

Please sign in to comment.