Improve title normalization in discography merge
Updated the normalize_title function to remove unicode accents using NFD normalization and filtering non-spacing marks. This enhances title comparison by handling accented characters more robustly.
This commit is contained in:
parent
a23b033d37
commit
e5457c0214
1 changed files with 9 additions and 1 deletions
|
|
@ -22373,7 +22373,15 @@ def merge_discography_data(owned_releases, spotify_discography):
|
||||||
def normalize_title(title):
|
def normalize_title(title):
|
||||||
"""Normalize title for comparison"""
|
"""Normalize title for comparison"""
|
||||||
import re
|
import re
|
||||||
normalized = title.lower().strip()
|
import unicodedata
|
||||||
|
|
||||||
|
# Normalize unicode characters to decomposed form (NFD)
|
||||||
|
normalized = unicodedata.normalize('NFD', title)
|
||||||
|
# Filter out non-spacing mark characters (accents)
|
||||||
|
normalized = "".join(c for c in normalized if unicodedata.category(c) != 'Mn')
|
||||||
|
|
||||||
|
# Standard normalization
|
||||||
|
normalized = normalized.lower().strip()
|
||||||
normalized = re.sub(r'[^\w\s]', '', normalized)
|
normalized = re.sub(r'[^\w\s]', '', normalized)
|
||||||
normalized = re.sub(r'\s+', ' ', normalized)
|
normalized = re.sub(r'\s+', ' ', normalized)
|
||||||
return normalized.strip()
|
return normalized.strip()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue