Module text

Source
Expand description

Text normalization: this is the piece that decides whether “The Beatles”, “Beatles, The” and “beatles” designate the same entity.

All entity matching rests on normalize, until M1 brings identifiers that do not depend on spelling. When MusicBrainz arrives (M1), these normalized keys will remain the safety net for unidentified files.

Functions§

disc_folder
The disc a folder name announces, when it announces one.
extract_year
Extracts the first year from a tag date, whatever its shape (1986, 1986-03-05, 05/03/1986, 1986.03).
file_name
Last component of a path, extension included.
folder
Containing directory of a path, without its trailing separator.
format_duration
Formats a duration as h:mm:ss or m:ss.
format_size
Formats a size in bytes in a readable way.
is_under
true when a path is the folder itself or something inside it.
normalize
Matching key: lowercase, without diacritics, without punctuation, with normalized spacing and the leading article moved.
parse_track_number
Reads a track number in the 5 or 5/12 form, returning (number, total).
plural
A count and its noun, agreeing: 1 track, 2 tracks, 3 analyses.
relative_under
A portable relative path under a catalog folder, or None outside it.
sort_name
Sort name: “The Beatles” -> “Beatles, The”, as discographic usage requires.
split_artists
Splits multiple artists out of a single tag field.
without_restatements
Drops, from one tag’s list of names, the ones that only say again what the other entries of that same list already say.