normalization
¶
Unified text normalization for artist/album matching.
This module provides a single source of truth for normalizing artist and album names when used for matching, comparison, or as dictionary/cache keys.
All code that compares artist or album names for equality should use normalize_for_matching().
normalize_for_matching
¶
Normalize text for case-insensitive matching and cache keys.
This is THE standard normalization for all artist/album comparisons. Use this everywhere you need to: - Compare artist/album names for equality - Generate cache keys - Group tracks by artist - Look up values in mapping dictionaries
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to normalize (artist name, album name, etc.) |
required |
Returns:
| Type | Description |
|---|---|
str
|
Normalized text: stripped whitespace, lowercased |
Examples:
>>> normalize_for_matching(" Vildhjarta ")
'vildhjarta'
>>> normalize_for_matching("2CELLOS")
'2cellos'
>>> normalize_for_matching("AC/DC")
'ac/dc'
Source code in src/core/models/normalization.py
are_names_equal
¶
Check if two names are equivalent after normalization.
Convenience function for comparing artist/album names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name1
|
str
|
First name to compare |
required |
name2
|
str
|
Second name to compare |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if names are equivalent after normalization |