| 1 | package MARC::Detrans::Name; | ||||||||||
| 2 | |||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 8 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 8 | ▶ | use base qw( Class::Accessor ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 8 | ▶ | use Carp qw( croak ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | =head1 NAME | ||||||||||
| 9 | |||||||||||
| 10 | MARC::Detrans::Name - A single name mapping | ||||||||||
| 11 | |||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||
| 13 | |||||||||||
| 14 | use MARC::Detrans::Name; | ||||||||||
| 15 | my $name = MARC::Detrans::Name->new( | ||||||||||
| 16 | from => '$aNicholas $bI, $cEmperor of Russia, $d1796-1855', | ||||||||||
| 17 | to => '$a^[(NnIKOLAJ^[s, $bI, $c^[(NiMPERATOR^[s ^[(NwSEROSSIJSKIJ^[s, $d1796-1855' | ||||||||||
| 18 | ); | ||||||||||
| 19 | |||||||||||
| 20 | =head1 DESCRIPTION | ||||||||||
| 21 | |||||||||||
| 22 | MARC::Detrans::Rule represents a single non-standard detransliteration mapping | ||||||||||
| 23 | for a MARC field. For example personal names often have non-standard | ||||||||||
| 24 | transliterations, so to get them back to the original script a non-rules based | ||||||||||
| 25 | detransliteration has to occur. | ||||||||||
| 26 | |||||||||||
| 27 | MARC::Detrans::Name and MARC::Detrans::Names aid in this process by allowing you | ||||||||||
| 28 | to create a single mapping of one field to another, and then adding them to a | ||||||||||
| 29 | rule set. | ||||||||||
| 30 | |||||||||||
| 31 | =head1 METHODS | ||||||||||
| 32 | |||||||||||
| 33 | =head2 new() | ||||||||||
| 34 | |||||||||||
| 35 | The constructor which you must pass the from and to parameters, which | ||||||||||
| 36 | define what name will be transformed. | ||||||||||
| 37 | |||||||||||
| 38 | =cut | ||||||||||
| 39 | |||||||||||
| 40 | 5 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||
| 41 | 5 | my ($class,%args) = @_; | |||||||||
| 42 | 5 | ▶ | croak( "must supply from parameter" ) if ! exists $args{from}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 5 | ▶ | croak( "must supply to parameter" ) if ! exists $args{to}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | ## convert ^ESC to 0x1B since XML can't contain this character | ||||||||||
| 45 | 5 | $args{to} =~ s/\^ESC/\x1B/g; | |||||||||
| 46 | 5 | return $class->SUPER::new( \%args ); | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | =head2 from() | ||||||||||
| 50 | |||||||||||
| 51 | =head2 to() | ||||||||||
| 52 | |||||||||||
| 53 | =cut | ||||||||||
| 54 | |||||||||||
| 55 | 8 | MARC::Detrans::Name->mk_accessors( qw( | |||||||||
| 56 | from | ||||||||||
| 57 | to | ||||||||||
| 58 | ) ); | ||||||||||
| 59 | |||||||||||
| 60 | 8 | 1; | |||||||||