| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Lingua::LO::Transform::Romanize::PCGN; |
|
2
|
2
|
|
|
2
|
|
676
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
45
|
|
|
3
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
34
|
|
|
4
|
2
|
|
|
2
|
|
28
|
use 5.012000; |
|
|
2
|
|
|
|
|
4
|
|
|
5
|
2
|
|
|
2
|
|
6
|
use utf8; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
12
|
|
|
6
|
2
|
|
|
2
|
|
42
|
use feature qw/ unicode_strings say /; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
142
|
|
|
7
|
2
|
|
|
2
|
|
8
|
use charnames qw/ :full lao /; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
10
|
|
|
8
|
2
|
|
|
2
|
|
800
|
use version 0.77; our $VERSION = version->declare('v0.0.1'); |
|
|
2
|
|
|
|
|
26
|
|
|
|
2
|
|
|
|
|
9
|
|
|
9
|
2
|
|
|
2
|
|
135
|
use Carp; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
90
|
|
|
10
|
2
|
|
|
2
|
|
359
|
use Lingua::LO::Transform::Analyze; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
11
|
|
|
11
|
2
|
|
|
2
|
|
64
|
use parent 'Lingua::LO::Transform::Romanize'; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
12
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=encoding UTF-8 |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Lingua::LO::Transform::Romanize::PCGN - Romanize Lao syllables according to the PCGN standard |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 FUNCTION |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This class is not supposed to be used directly. Rather use |
|
22
|
|
|
|
|
|
|
L as a factory: |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $o = Lingua::LO::Transform::Romanize->new(variant => 'PCGN'); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my %CONSONANTS = ( |
|
29
|
|
|
|
|
|
|
ກ => 'k', |
|
30
|
|
|
|
|
|
|
ຂ => 'kh', |
|
31
|
|
|
|
|
|
|
ຄ => 'kh', |
|
32
|
|
|
|
|
|
|
ງ => 'ng', |
|
33
|
|
|
|
|
|
|
ຈ => 'ch', |
|
34
|
|
|
|
|
|
|
ສ => 's', |
|
35
|
|
|
|
|
|
|
ຊ => 'x', |
|
36
|
|
|
|
|
|
|
ຍ => [qw/ gn y /], |
|
37
|
|
|
|
|
|
|
ດ => [qw/ d t /], |
|
38
|
|
|
|
|
|
|
ຕ => 't', |
|
39
|
|
|
|
|
|
|
ຖ => 'th', |
|
40
|
|
|
|
|
|
|
ທ => 'th', |
|
41
|
|
|
|
|
|
|
ນ => 'n', |
|
42
|
|
|
|
|
|
|
ບ => [qw/ b p /], |
|
43
|
|
|
|
|
|
|
ປ => 'p', |
|
44
|
|
|
|
|
|
|
ຜ => 'ph', |
|
45
|
|
|
|
|
|
|
ຝ => 'f', |
|
46
|
|
|
|
|
|
|
ພ => 'ph', |
|
47
|
|
|
|
|
|
|
ຟ => 'f', |
|
48
|
|
|
|
|
|
|
ມ => 'm', |
|
49
|
|
|
|
|
|
|
ຢ => 'y', |
|
50
|
|
|
|
|
|
|
ລ => 'l', |
|
51
|
|
|
|
|
|
|
"\N{LAO SEMIVOWEL SIGN LO}" => 'l', |
|
52
|
|
|
|
|
|
|
ວ => [qw/ v o /], |
|
53
|
|
|
|
|
|
|
ຫ => 'h', |
|
54
|
|
|
|
|
|
|
ອ => '', |
|
55
|
|
|
|
|
|
|
ຮ => 'h', |
|
56
|
|
|
|
|
|
|
ຣ => 'r', |
|
57
|
|
|
|
|
|
|
ໜ => 'n', |
|
58
|
|
|
|
|
|
|
ໝ => 'm', |
|
59
|
|
|
|
|
|
|
ຫຼ => 'l', |
|
60
|
|
|
|
|
|
|
ຫຍ => 'gn', |
|
61
|
|
|
|
|
|
|
ຫນ => 'n', |
|
62
|
|
|
|
|
|
|
ຫມ => 'm', |
|
63
|
|
|
|
|
|
|
ຫຣ => 'r', |
|
64
|
|
|
|
|
|
|
ຫລ => 'l', |
|
65
|
|
|
|
|
|
|
ຫວ => 'v', |
|
66
|
|
|
|
|
|
|
); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my %CONS_VOWELS = map { $_ => 1 } qw/ ຍ ຽ ອ ວ /; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my %VOWELS = ( |
|
71
|
|
|
|
|
|
|
### Monophthongs |
|
72
|
|
|
|
|
|
|
'Xະ' => 'a', |
|
73
|
|
|
|
|
|
|
'Xັ' => 'a', |
|
74
|
|
|
|
|
|
|
'Xາ' => 'a', |
|
75
|
|
|
|
|
|
|
'Xາວ' => 'ao', |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
'Xິ' => 'i', |
|
78
|
|
|
|
|
|
|
'Xີ' => 'i', |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
'Xຶ' => 'u', |
|
81
|
|
|
|
|
|
|
'Xື' => 'u', |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
'Xຸ' => 'ou', |
|
84
|
|
|
|
|
|
|
'Xູ' => 'ou', |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
'ເXະ' => 'é', |
|
87
|
|
|
|
|
|
|
'ເXັ' => 'é', |
|
88
|
|
|
|
|
|
|
'ເX' => 'é', |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
'ແXະ' => 'è', |
|
91
|
|
|
|
|
|
|
'ແXັ' => 'è', |
|
92
|
|
|
|
|
|
|
'ແX' => 'è', |
|
93
|
|
|
|
|
|
|
'ແXວ' => 'èo', |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
'ໂXະ' => 'ô', |
|
96
|
|
|
|
|
|
|
'Xົ' => 'ô', |
|
97
|
|
|
|
|
|
|
'ໂX' => 'ô', |
|
98
|
|
|
|
|
|
|
'ໂXຍ' => 'ôy', # TODO correct? |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
'ເXາະ' => 'o', |
|
101
|
|
|
|
|
|
|
'Xັອ' => 'o', |
|
102
|
|
|
|
|
|
|
'Xໍ' => 'o', |
|
103
|
|
|
|
|
|
|
'Xອ' => 'o', |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
'ເXິ' => 'eu', |
|
106
|
|
|
|
|
|
|
'ເXີ' => 'eu', |
|
107
|
|
|
|
|
|
|
'ເXື' => 'eu', # TODO correct? |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
'ເXັຍ' => 'ia', # /iə/ |
|
110
|
|
|
|
|
|
|
'Xັຽ' => 'ia', # /iə/ |
|
111
|
|
|
|
|
|
|
'ເXຍ' => 'ia', # /iːə/ |
|
112
|
|
|
|
|
|
|
'Xຽ' => 'ia', # /iːə/ |
|
113
|
|
|
|
|
|
|
'Xຽວ' => 'iao', |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
'ເXຶອ' => 'ua', |
|
116
|
|
|
|
|
|
|
'ເXືອ' => 'ua', |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
'Xົວະ' => 'oua', |
|
119
|
|
|
|
|
|
|
'Xັວ ' => 'oua', |
|
120
|
|
|
|
|
|
|
'Xົວ' => 'oua', |
|
121
|
|
|
|
|
|
|
'Xວ' => 'oua', |
|
122
|
|
|
|
|
|
|
'Xວຍ' => 'ouai', |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
'ໄX' => 'ai', |
|
125
|
|
|
|
|
|
|
'ໃX' => 'ai', |
|
126
|
|
|
|
|
|
|
'Xາຍ' => 'ay', # /aj/ - Actually short but counts as long for rules |
|
127
|
|
|
|
|
|
|
'Xັຍ' => 'ay', # /aj/ |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
'ເXົາ' => 'ao', |
|
130
|
|
|
|
|
|
|
'Xຳ' => 'am', # composed U+0EB3 |
|
131
|
|
|
|
|
|
|
'Xໍາ' => 'am', |
|
132
|
|
|
|
|
|
|
); |
|
133
|
|
|
|
|
|
|
{ |
|
134
|
|
|
|
|
|
|
# Replace "X" in %VOWELS keys with DOTTED CIRCLE. Makes code easier to edit. |
|
135
|
|
|
|
|
|
|
my %v; |
|
136
|
|
|
|
|
|
|
foreach my $v (keys %VOWELS) { |
|
137
|
|
|
|
|
|
|
(my $w = $v) =~ s/X/\N{DOTTED CIRCLE}/; |
|
138
|
|
|
|
|
|
|
$v{$w} = $VOWELS{$v}; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
%VOWELS = %v; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub new { |
|
144
|
1
|
|
|
1
|
1
|
1
|
my $class = shift; |
|
145
|
|
|
|
|
|
|
# Not calling SUPER::new on purpose! |
|
146
|
1
|
|
|
|
|
3
|
return bless {}, $class; |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub romanize_syllable { |
|
150
|
29
|
|
|
29
|
1
|
28
|
my ($self, $syllable) = @_; |
|
151
|
29
|
|
|
|
|
23
|
my ($consonant, $endcons, $result); |
|
152
|
29
|
|
|
|
|
58
|
my $c = Lingua::LO::Transform::Analyze->new($syllable); |
|
153
|
29
|
|
|
|
|
54
|
my $parse = $c->parse; |
|
154
|
29
|
|
|
|
|
108
|
my $vowel = $c->vowel; |
|
155
|
|
|
|
|
|
|
|
|
156
|
29
|
|
|
|
|
88
|
my $cons = $c->consonant; |
|
157
|
29
|
|
|
|
|
90
|
my $h = $c->h; |
|
158
|
29
|
|
|
|
|
79
|
my $sv = $c->semivowel; |
|
159
|
29
|
100
|
100
|
|
|
116
|
if($cons eq 'ຫ' and $sv) { |
|
160
|
|
|
|
|
|
|
# ຫ with semivowel. Drop the ຫ and use the semivowel as consonant |
|
161
|
2
|
|
|
|
|
3
|
$result = _consonant($sv, 0); |
|
162
|
|
|
|
|
|
|
} else { |
|
163
|
|
|
|
|
|
|
# The regular case |
|
164
|
27
|
|
|
|
|
30
|
$result = _consonant($cons, 0); |
|
165
|
27
|
100
|
|
|
|
41
|
$result .= _consonant($sv, 1) if $sv; |
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
|
|
168
|
29
|
|
|
|
|
41
|
$endcons = $c->end_consonant; |
|
169
|
29
|
100
|
|
|
|
88
|
if(defined $endcons) { |
|
170
|
14
|
100
|
|
|
|
16
|
if(exists $CONS_VOWELS{ $endcons }) { |
|
171
|
3
|
|
|
|
|
4
|
$vowel .= $endcons; # consonant can be used as a vowel |
|
172
|
3
|
|
|
|
|
3
|
$endcons = ''; |
|
173
|
|
|
|
|
|
|
} else { |
|
174
|
11
|
|
|
|
|
11
|
$endcons = _consonant($endcons, 1); |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
} else { |
|
177
|
15
|
|
|
|
|
13
|
$endcons = ''; # avoid special-casing later |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
# TODO remove debug |
|
181
|
29
|
50
|
|
|
|
47
|
warn sprintf("Missing VOWELS def for `%s' in `%s'", $vowel, $c->syllable) unless defined $VOWELS{ $vowel }; |
|
182
|
|
|
|
|
|
|
|
|
183
|
29
|
|
|
|
|
36
|
$result .= $VOWELS{ $vowel } . $endcons; |
|
184
|
29
|
100
|
66
|
|
|
55
|
$result .= "-$result" if defined $parse->{extra} and $parse->{extra} eq 'ໆ'; # duplication sign |
|
185
|
29
|
|
|
|
|
130
|
return $result; |
|
186
|
|
|
|
|
|
|
} |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub _consonant { |
|
189
|
42
|
|
|
42
|
|
38
|
my ($cons, $position) = @_; |
|
190
|
42
|
|
|
|
|
38
|
my $consdata = $CONSONANTS{ $cons }; |
|
191
|
|
|
|
|
|
|
#my $consref = ref $consdata or return $consdata; |
|
192
|
|
|
|
|
|
|
#return $consdata->($position) if $consref eq 'CODE'; |
|
193
|
|
|
|
|
|
|
#return $consdata->[$position]; |
|
194
|
42
|
100
|
|
|
|
71
|
return ref $consdata ? $consdata->[$position] : $consdata; |
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
1; |
|
198
|
|
|
|
|
|
|
|