|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package MARC::Detrans::Names;  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
3
 | 
8
 | 
 
 | 
 
 | 
  
8
  
 | 
 
 | 
914
 | 
 use strict;  | 
| 
 
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
15
 | 
    | 
| 
 
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
310
 | 
    | 
| 
4
 | 
8
 | 
 
 | 
 
 | 
  
8
  
 | 
 
 | 
45
 | 
 use warnings;  | 
| 
 
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
17
 | 
    | 
| 
 
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3718
 | 
    | 
| 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 =head1 NAME  | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 MARC::Detrans::Names - A set of non-standard authority mappings  | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 =head1 SYNOPSIS  | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     use MARC::Detrans::Names  | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $names = MARC::Detrans::Names->new();  | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     $names->addName(   | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         from => '$aNicholas $bI, $cEmperor of Russia, $d1796-1855',  | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         to  => '$a^[(NnIKOLAJ^[s, $bI, $c^[(NiMPERATOR^[s ^[(NwSEROSSIJSKIJ^[s, $d1796-1855'  | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     );  | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 =head1 DESCRIPTION  | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 Often times personal names are transliterated in non-standard ways, so   | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 in order to get back to the original script it's necessary to have  | 
| 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 non-standard mappings. MARC::Detrans::Names allows you to map the  | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 transliterated name back to it's original.   | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 =head1 METHODS  | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 =head2 new()  | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 =cut   | 
| 
31
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub new {  | 
| 
33
 | 
8
 | 
 
 | 
 
 | 
  
8
  
 | 
  
1
  
 | 
811
 | 
     my $class = shift;  | 
| 
34
 | 
8
 | 
 
 | 
  
 33
  
 | 
 
 | 
 
 | 
70
 | 
     my $self = bless {}, ref($class) || $class;  | 
| 
35
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
47
 | 
     $self->{storage} = {};  | 
| 
36
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
31
 | 
     return $self;  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 =head2 addName()  | 
| 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
41
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 You must pass in a MARC::Detrans::Name object that you want to have added  | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 to the names mapping.  | 
| 
43
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 =cut  | 
| 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
46
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub addName {  | 
| 
47
 | 
5
 | 
 
 | 
 
 | 
  
5
  
 | 
  
1
  
 | 
549
 | 
     my ($self,$name) = @_;  | 
| 
48
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
27
 | 
     my $from = $name->from();  | 
| 
49
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
148
 | 
     my $to = $name->to();  | 
| 
50
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     ## squash space and remove indicators  | 
| 
52
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
71
 | 
     $from =~ s/ //g;  | 
| 
53
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
49
 | 
     $from =~ s/\$.//g;  | 
| 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     ## create a list of subfield data, suitable for easily   | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     ## passing to MARC::Field->new()  | 
| 
57
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
60
 | 
     my @chunks = split /\$/, $to;  | 
| 
58
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
19
 | 
     my @subfields = ();  | 
| 
59
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
15
 | 
     foreach my $chunk ( @chunks ) {   | 
| 
60
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         ## first chunk will be empty  | 
| 
61
 | 
25
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
150
 | 
         next if $chunk eq '';   | 
| 
62
 | 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
39
 | 
         my $subfield = substr( $chunk,0,1 );  | 
| 
63
 | 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
38
 | 
         my $data = substr( $chunk,1 );  | 
| 
64
 | 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
48
 | 
         push( @subfields, $subfield, $data );  | 
| 
65
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
66
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
67
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
36
 | 
     $self->{storage}{$from} = \@subfields;   | 
| 
68
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
69
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
70
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 =head2 convert()  | 
| 
71
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
72
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 Pass in a MARC::Field object and you'll get back an array ref of   | 
| 
73
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 modified subfield data which could be used to create a new field.   | 
| 
74
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 If there is no mapping for a particular MARC::Field then you'll get  | 
| 
75
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 back undef.  | 
| 
76
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
77
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 =cut  | 
| 
78
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
79
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub convert {  | 
| 
80
 | 
17
 | 
 
 | 
 
 | 
  
17
  
 | 
  
1
  
 | 
800
 | 
     my ($self,$field) = @_;  | 
| 
81
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
82
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     ## make the hash key  | 
| 
83
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
95
 | 
     my $from = $field->as_string();  | 
| 
84
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
751
 | 
     $from =~ s/ //g;  | 
| 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
86
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     ## do the lookup, and return   | 
| 
87
 | 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
126
 | 
     return $self->{storage}{$from};  | 
| 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
90
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  |