line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MARC::Detrans::Rule; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
3333
|
use strict; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
326
|
|
4
|
9
|
|
|
9
|
|
51
|
use warnings; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
452
|
|
5
|
9
|
|
|
9
|
|
51
|
use Carp qw( croak ); |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
3975
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
MARC::Detrans::Rule |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use MARC::Detrans::Rule; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $rule = MARC::Detrans::Rule->new( |
16
|
|
|
|
|
|
|
from => 'b', |
17
|
|
|
|
|
|
|
to => 'B', |
18
|
|
|
|
|
|
|
escape => '(B' |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
It's unlikely that you'll want to use MARC::Detrans::Rule directly since |
24
|
|
|
|
|
|
|
other modules wrap access to it. Each detransliteration rule is represented |
25
|
|
|
|
|
|
|
as a MARC::Detrans::Rule object, which basically provides the Romanized text |
26
|
|
|
|
|
|
|
and the corresponding MARC-8 or UTF-8 text, along with an escape character |
27
|
|
|
|
|
|
|
(for MARC-8) rules. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 METHODS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 new() |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Pass in the C and c parameters which define the original text |
34
|
|
|
|
|
|
|
and what to translate to; these parameters are not limited to single |
35
|
|
|
|
|
|
|
characters. In addition an C parameter can be passed in to |
36
|
|
|
|
|
|
|
indicate a MARC-8 escape sequence to use. Also a C parameter |
37
|
|
|
|
|
|
|
can be set to C, C or C if the rule applies only |
38
|
|
|
|
|
|
|
when the character is found at or within a particular word boundary. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { |
43
|
465
|
|
|
465
|
1
|
3638
|
my ( $class, %opts ) = @_; |
44
|
465
|
50
|
|
|
|
1376
|
croak( "must supply 'from' parameter" ) if ! exists( $opts{from} ); |
45
|
465
|
50
|
|
|
|
1046
|
croak( "must supply 'to' parameter" ) if ! exists( $opts{to} ); |
46
|
465
|
|
|
|
|
872
|
$opts{to} =~ s/\^ESC/\x1B/g; |
47
|
465
|
|
33
|
|
|
4335
|
return bless \%opts, ref($class) || $class; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 from() |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Returns the Romanized text that this rule refers to. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub from { |
57
|
3711
|
|
|
3711
|
1
|
13228
|
return shift->{from}; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 to() |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Returns the MARC-8 or UTF-8 text that the corresponding Romanized text should |
63
|
|
|
|
|
|
|
be converted to. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub to { |
68
|
1115
|
|
|
1115
|
1
|
5341
|
return shift->{to}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 escape() |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Returns a MARC-8 character set escape sequence to be used, or undef if the rule |
74
|
|
|
|
|
|
|
is for an UTF-8 mapping. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub escape { |
79
|
2365
|
|
|
2365
|
1
|
28044
|
return shift->{escape}; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 position() |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Returns a position specification for the rule mapping which can be |
85
|
|
|
|
|
|
|
initial, medial, final or the empty string if there is no positional |
86
|
|
|
|
|
|
|
qualification for the rule. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub position { |
91
|
1746
|
|
|
1746
|
1
|
10238
|
my $p = shift->{position}; |
92
|
1746
|
100
|
|
|
|
3895
|
return $p if defined($p); |
93
|
1696
|
|
|
|
|
9016
|
return ''; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHORS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=over 4 |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item * Ed Summers |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=back |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |