mirror of
https://github.com/MadsLorentzen/ai-job-search.git
synced 2026-09-17 00:26:26 +00:00
fix(salary): stop dropping the dotted A.M.B.A. suffix in company-name matching (#356)
The A.M.B.A. STRIP_PATTERNS regex ended in a literal dot followed by \b, but \b can't fire right after a non-word character when the next char is also non-word (space/end-of-string) - so it never matched any realistic company name. The sibling undotted 'amba' suffix stripped fine, so 'Arla Foods A.M.B.A.' and 'Arla Foods amba' normalized to different strings and scored 86 vs 100 against the same query. Made the trailing dot optional so the boundary resolves correctly.
This commit is contained in:
@@ -102,6 +102,12 @@ class TestMatchScoreExactMatch(unittest.TestCase):
|
||||
def test_exact_match_after_suffix_stripping(self):
|
||||
self.assertEqual(match_score("Mærsk", "Mærsk A/S"), 100)
|
||||
|
||||
def test_exact_match_after_dotted_amba_suffix_stripping(self):
|
||||
# "A.M.B.A." (dotted) is the same legal-suffix family as the
|
||||
# undotted "amba" pattern above it in STRIP_PATTERNS and must
|
||||
# strip just as cleanly.
|
||||
self.assertEqual(match_score("Arla Foods", "Arla Foods A.M.B.A."), 100)
|
||||
|
||||
|
||||
class TestMatchScoreSubstring(unittest.TestCase):
|
||||
def test_query_contained_in_entry_gives_high_score(self):
|
||||
@@ -332,6 +338,14 @@ class UtilityTests(unittest.TestCase):
|
||||
self.assertEqual(normalize("Chr. Hansen, Denmark Division"), "chrhansen")
|
||||
self.assertEqual(normalize("Simple Corp ApS"), "simplecorp")
|
||||
|
||||
def test_normalize_strips_dotted_amba_suffix_same_as_undotted(self):
|
||||
# The dotted form ("A.M.B.A.") must normalize identically to the
|
||||
# undotted form ("amba"), same as A/S vs ApS variants above.
|
||||
self.assertEqual(
|
||||
normalize("Arla Foods A.M.B.A."), normalize("Arla Foods amba")
|
||||
)
|
||||
self.assertEqual(normalize("Arla Foods A.M.B.A."), "arlafoods")
|
||||
|
||||
def test_anglicize_replaces_danish_chars(self):
|
||||
self.assertEqual(anglicize("ørsted"), "orsted")
|
||||
self.assertEqual(anglicize("mærsk"), "maersk")
|
||||
|
||||
Reference in New Issue
Block a user