mirror of
https://github.com/MadsLorentzen/ai-job-search.git
synced 2026-11-02 13:12:50 +00:00
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:
1 parent
5a29fdc711
commit
894e3917ba
3 files changed
+82
-7
No files matched your search
+18
-7
@@ -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]
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user