Normali...c_Fields(3)

πŸ“¦ version 1.16, in nixos 26.05, nixpkgs unstable

🌸 NAME 🌸

Okay so this is the manual page for Normalize::Text::Music_Fields(3), aka User Contributed Perl Documentation. The whole vibe is that it normalizes names of people's and (musical) works. That's the assignment, bestie. πŸ’…βœ¨


✨ SYNOPSIS ✨

The synopsis is literally this, no cap:

          $name = $obj->Normalize::Text::Music_Fields::normalize_person($name);
          $work = $obj->Normalize::Text::Music_Fields::normalize_piece($work);
        # $obj should have methods `name_for_field_normalization', 'shorted_person'

So yeah β€” $obj has to have the methods name_for_field_normalization and shorted_person (yes, that's exactly what the code comment says, typo and all). 🫢


πŸ’– DESCRIPTION πŸ’–

The databases of names and of works-per-name are taken from plain-text files (optionally in mail-header format). Names are stored in *.lst files. Works are stored in .comp files named after the shortened name of the composer. It's giving organized-but-chaotic, and honestly? Obsessed. πŸŽ€

These files' directories get looked up in the environment variable MUSIC_FIELDS_PATH (if it's defined, split the same way as PATH), or in $ENV{HOME}/.music_fields, and - (and - is replaced by the directory named as the module file with .pm dropped). At runtime, one can replace the list by calling function Normalize::Text::Music_Fields::set_path() with the list of directories as the argument. Slay. 🌈

Since parsed files are cached, replacing the directory list should be done as early as possible. Like, do it first, bestie β€” main character energy means not debugging cache weirdness later. 😭

Files may be managed with utility subroutines provided with the module:

# Translate from one-per-line to mail-header format:
perl -wple "BEGIN {print q(# format = mail-header)} s/#\s*normalized\s*$//; $_ = qq(Title: $_) unless /^\s*(#|$)/; $_ = qq(\n$_) if $p and not /^##/; $_ .= qq(\n) unless $p = /^##/" Normalize::Text::Music_Fields-G_Gershwin.comp >Music_Fields-G_Gershwin.comp-mail
# (inverse transformation:) Dump pieces listed in mail-header format
perl -MNormalize::Text::Music_Fields -wle "print for Normalize::Text::Music_Fields::read_composer_file(shift, shift)" gershwin Music_Fields-G_Gershwin.comp-mail > o
# Normalize data in 1-line-per piece format
perl -MNormalize::Text::Music_Fields -wle "Normalize::Text::Music_Fields::prepare_tag_object_comp(shift)->Normalize::Text::Music_Fields::normalize_file_lines(shift)"
# Create a mail-header file from a semi-processed (with "bold" fields)
# mail-header file (with xml escapes, preceded by opus number)
perl -MNormalize::Text::Music_Fields -00wnle "BEGIN {$tag = Normalize::Text::Music_Fields::prepare_tag_object_comp(shift @ARGV); print q(# format = mail-header)} print Normalize::Text::Music_Fields::emit_as_mail_header($tag,$_, q(bold,xml,opus),$pre)" shostakovich  o-xslt-better >Music_Fields-D_Shostakovich.comp-mail1
# Likewise, from work-per-line with opus-numbers:
perl -MNormalize::Text::Music_Fields -wnle "BEGIN {$tag = Normalize::Text::Music_Fields::prepare_tag_object_comp(shift @ARGV); print qq(# format = mail-header\n)} print Normalize::Text::Music_Fields::emit_as_mail_header($tag,$_, q(opus), $pre)" schnittke  o-schnittke-better  >Music_Fields-A_Schnittke.comp-mail2
# A primitive tool for merging additional info into the database:
perl -MNormalize::Text::Music_Fields -wnle "BEGIN {$tag = Normalize::Text::Music_Fields::prepare_tag_object_comp(shift @ARGV); print qq(# format = mail-header\n)} next unless s/^\s*\+\+\s*//; print Normalize::Text::Music_Fields::merge_info($tag,$_, q(opus,xml), qr(^(58|70|76|116|118|119)($|-)))" brahms o-brahms-op-no1-xslt
# Minimal consistency check of persons database.
perl -MNormalize::Text::Music_Fields -wle "BEGIN{binmode $_, ':encoding(cp866)' for \*STDIN, \*STDOUT, \*STDERR} print Normalize::Text::Music_Fields->check_persons"
# Minimal testing code:
perl -MNormalize::Text::Music_Fields -e Normalize::Text::Music_Fields::test_normalize_piece

It may be easier to type these examples if one uses manage_M_N_F.pm, which exports the mentioned subroutines to the main namespace (available in examples directory of a distribution of MP3::Tag). E.g., the last example becomes:

perl -Mmanage_M_N_F -e test_normalize_piece

Bottom line from the footer: this page is from perl v5.42.3 and dated 2022-11-25. Byeee, bestie β€” go normalize something iconic πŸ«ΆπŸ’–πŸŒ·

πŸ“¦ where this page comes from