fix(salary): preserve Unicode company identity in lookups (#570)

* fix(salary): preserve Unicode company identity in lookups

* fix(salary): restore accent folding after Nordic spellings

Address MadsLorentzen review feedback on #570: keep Unicode identity normalization and restore ASCII-typed accented-name controls on the documented CLI path.
This commit is contained in:
Rudy Mizrahi Celekli authored and GitHub committed 2026-10-18 07:28:42 +02:00
1 parent 5a29fdc711
commit 894e3917ba
3 files changed
+82 -7

No files matched your search

+18 -7
View File
@@ -174,27 +174,38 @@ def load_data():
def normalize(s):
"""Normalize string for robust fuzzy matching."""
s = s.lower().strip()
s = unicodedata.normalize("NFC", s.casefold()).strip()
for pat in STRIP_PATTERNS:
s = re.sub(pat, "", s)
s = re.sub(r"[^a-zæøåöäü0-9]", "", s)
return s.strip()
return "".join(
char for char in s
if char.isalnum() or unicodedata.category(char).startswith("M")
)
def anglicize(s):
"""Convert Danish/Nordic characters to anglicized equivalents."""
"""Fold Nordic spellings first, then accents for ASCII-typed queries."""
s = s.lower()
for danish, english in SPELLING_VARIANTS.items():
s = s.replace(danish, english)
return s
return "".join(
char for char in unicodedata.normalize("NFKD", s)
if not unicodedata.combining(char)
)
def extract_core_words(s):
"""Extract meaningful words from a company name, ignoring noise."""
s = s.lower()
s = unicodedata.normalize("NFC", s.casefold())
for pat in STRIP_PATTERNS:
s = re.sub(pat, "", s)
words = re.findall(r"[a-zæøåöäü0-9]+", s)
# Keep the same identity as normalize(), including combining marks in
# scripts where NFC cannot compose them into a single letter.
s = "".join(
char if char.isalnum() or unicodedata.category(char).startswith("M") else " "
for char in s
)
words = s.split()
return [w for w in words if len(w) > 1]