Ilya Zakharevich > MP3-Tag-0.9710 > Music_Normalize_Fields

Download:
modules/MP3-Tag-0.9710.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  5
Open  17
View Bugs
Report a bug
Source   Latest Release: MP3-Tag-0.9714

NAME ^

Music_Normalize_Fields - normalize names of people's and (musical) works.

SYNOPSIS ^

   $name = $obj->Music_Normalize_Fields::normalize_person($name);
   $work = $obj->Music_Normalize_Fields::normalize_piece($work); # $obj should have methods `composer', 'shorted_person'

DESCRIPTION ^

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 in the directory named as the module file (without .pm). Works are stored in .comp files named after the shortened name of the composer.

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 = /^##/" Music_Normalize_Fields-G_Gershwin.comp >Music_Normalize_Fields-G_Gershwin.comp-mail

 # (inverse transformation:) Dump pieces listed in mail-header format
 perl -MMusic_Normalize_Fields -wle "print for Music_Normalize_Fields::read_composer_file(shift, shift)" gershwin Music_Normalize_Fields-G_Gershwin.comp-mail > o

 # Normalize data in 1-line-per piece format
 perl -MMusic_Normalize_Fields -wle "Music_Normalize_Fields::prepare_tag_object_comp(shift)->Music_Normalize_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 -MMusic_Normalize_Fields -00wnle "BEGIN {$tag = Music_Normalize_Fields::prepare_tag_object_comp(shift @ARGV); print q(# format = mail-header)} print Music_Normalize_Fields::emit_as_mail_header($tag,$_, q(bold,xml,opus),$pre)" shostakovich  o-xslt-better >Music_Normalize_Fields-D_Shostakovich.comp-mail1

 # Likewise, from work-per-line with opus-numbers:
 perl -MMusic_Normalize_Fields -wnle "BEGIN {$tag = Music_Normalize_Fields::prepare_tag_object_comp(shift @ARGV); print qq(# format = mail-header\n)} print Music_Normalize_Fields::emit_as_mail_header($tag,$_, q(opus), $pre)" schnittke  o-schnittke-better  >Music_Normalize_Fields-A_Schnittke.comp-mail2

 # A primitive tool for merging additional info into the database:
 perl -MMusic_Normalize_Fields -wnle "BEGIN {$tag = Music_Normalize_Fields::prepare_tag_object_comp(shift @ARGV); print qq(# format = mail-header\n)} next unless s/^\s*\+\+\s*//; print Music_Normalize_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 -MMusic_Normalize_Fields -wle "BEGIN{binmode $_, ':encoding(cp866)' for \*STDIN, \*STDOUT, \*STDERR} print Music_Normalize_Fields->check_persons"

 # Minimal testing code:
 perl -MMusic_Normalize_Fields -e Music_Normalize_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. E.g., the last example becomes:

 perl -Mmanage_M_N_F -e test_normalize_piece