| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Lingua::LO::Romanize::Syllable; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
8
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
38
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use utf8; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
23
|
use Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use constant{ |
|
9
|
1
|
|
|
|
|
1284
|
BGN_PCGN => { |
|
10
|
|
|
|
|
|
|
#consonants |
|
11
|
|
|
|
|
|
|
'àº' => 'k', |
|
12
|
|
|
|
|
|
|
'àº' => 'kh', |
|
13
|
|
|
|
|
|
|
'àº' => 'kh', |
|
14
|
|
|
|
|
|
|
'àº' => 'ng', |
|
15
|
|
|
|
|
|
|
'àº' => 'ch', |
|
16
|
|
|
|
|
|
|
'ສ' => 's', |
|
17
|
|
|
|
|
|
|
'àº' => 'x', |
|
18
|
|
|
|
|
|
|
'àº' => 't', |
|
19
|
|
|
|
|
|
|
'àº' => 'th', |
|
20
|
|
|
|
|
|
|
'àº' => 'th', |
|
21
|
|
|
|
|
|
|
'àº' => 'n', |
|
22
|
|
|
|
|
|
|
'à»' => 'n', |
|
23
|
|
|
|
|
|
|
'àº' => 'p', |
|
24
|
|
|
|
|
|
|
'àº' => 'ph', |
|
25
|
|
|
|
|
|
|
'àº' => 'f', |
|
26
|
|
|
|
|
|
|
'àº' => 'ph', |
|
27
|
|
|
|
|
|
|
'àº' => 'f', |
|
28
|
|
|
|
|
|
|
'ມ' => 'm', |
|
29
|
|
|
|
|
|
|
'à»' => 'm', |
|
30
|
|
|
|
|
|
|
'ຢ' => 'y', |
|
31
|
|
|
|
|
|
|
'ຣ' => 'r', |
|
32
|
|
|
|
|
|
|
'ຣà»' => 'r', |
|
33
|
|
|
|
|
|
|
'ລ' => 'l', |
|
34
|
|
|
|
|
|
|
'ຼ' => 'l', |
|
35
|
|
|
|
|
|
|
'ຫ' => 'h', |
|
36
|
|
|
|
|
|
|
'ຮ' => 'h', |
|
37
|
|
|
|
|
|
|
#àº, ຽ, àº, àº, ວ, ຠspecial cases |
|
38
|
|
|
|
|
|
|
#vowels |
|
39
|
|
|
|
|
|
|
'ະ' => 'a', |
|
40
|
|
|
|
|
|
|
'ັ' => 'a', |
|
41
|
|
|
|
|
|
|
'າ' => 'a', |
|
42
|
|
|
|
|
|
|
'ິ' => 'i', |
|
43
|
|
|
|
|
|
|
'ີ' => 'i', |
|
44
|
|
|
|
|
|
|
'ຶ' => 'u', |
|
45
|
|
|
|
|
|
|
'ື' => 'u', |
|
46
|
|
|
|
|
|
|
'ຸ' => 'ou', |
|
47
|
|
|
|
|
|
|
'ູ' => 'ou', |
|
48
|
|
|
|
|
|
|
'à»àº°' => 'é', |
|
49
|
|
|
|
|
|
|
'à»àº±' => 'é', |
|
50
|
|
|
|
|
|
|
'à»' => 'é', |
|
51
|
|
|
|
|
|
|
'à»àº°' => 'è', |
|
52
|
|
|
|
|
|
|
'à»àº±' => 'è', |
|
53
|
|
|
|
|
|
|
'à»' => 'è', |
|
54
|
|
|
|
|
|
|
'à»àº°' => 'ô', |
|
55
|
|
|
|
|
|
|
'ົ' => 'ô', |
|
56
|
|
|
|
|
|
|
'à»' => 'ô', |
|
57
|
|
|
|
|
|
|
'à»àº²àº°' => 'o', |
|
58
|
|
|
|
|
|
|
'ັàº' => 'o', |
|
59
|
|
|
|
|
|
|
'à»' => 'o', |
|
60
|
|
|
|
|
|
|
'àº' => 'o', |
|
61
|
|
|
|
|
|
|
'à»àº±àº½àº°' => 'ia', |
|
62
|
|
|
|
|
|
|
'ັຽ' => 'ia', |
|
63
|
|
|
|
|
|
|
'à»àº±àº½' => 'ia', |
|
64
|
|
|
|
|
|
|
'ຽ' => 'ia', |
|
65
|
|
|
|
|
|
|
'à»àº±àºàº°' => 'ia', #? |
|
66
|
|
|
|
|
|
|
'ັàº' => 'ia', #? |
|
67
|
|
|
|
|
|
|
'à»àº±àº' => 'ia', #? |
|
68
|
|
|
|
|
|
|
'àº' => 'ia', #? |
|
69
|
|
|
|
|
|
|
'à»àº' => 'ia', |
|
70
|
|
|
|
|
|
|
'à»àº¶àºàº°' => 'ua', |
|
71
|
|
|
|
|
|
|
'à»àº¶àº' => 'ua', |
|
72
|
|
|
|
|
|
|
'à»àº·àº' => 'ua', |
|
73
|
|
|
|
|
|
|
'à»àº´àº°' => 'eu', |
|
74
|
|
|
|
|
|
|
'à»àº´' => 'eu', |
|
75
|
|
|
|
|
|
|
'à»àºµ' => 'eu', |
|
76
|
|
|
|
|
|
|
'à»àº·' => 'eu', |
|
77
|
|
|
|
|
|
|
'à»' => 'ai', |
|
78
|
|
|
|
|
|
|
'à»' => 'ai', |
|
79
|
|
|
|
|
|
|
'à»àº»àº²' => 'ao', |
|
80
|
|
|
|
|
|
|
'ຳ' => 'am', #not needed? |
|
81
|
|
|
|
|
|
|
'à»àº²' => 'am', #not needed? |
|
82
|
|
|
|
|
|
|
'ິວ' => 'iou', |
|
83
|
|
|
|
|
|
|
'ີວ' => 'iou', |
|
84
|
|
|
|
|
|
|
# special case: ົວະ, ັວ, ົວ, ວ |
|
85
|
|
|
|
|
|
|
}, |
|
86
|
1
|
|
|
1
|
|
8246
|
}; |
|
|
1
|
|
|
|
|
2
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=encoding utf-8 |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 NAME |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Lingua::LO::Romanize::Syllable - Class for syllables, used by Lingua::LO::Romanize::Word. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 VERSION |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Version 0.10 |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
has 'syllable_str' => ( |
|
103
|
|
|
|
|
|
|
is => 'ro', |
|
104
|
|
|
|
|
|
|
isa => 'Str', |
|
105
|
|
|
|
|
|
|
required => 1, |
|
106
|
|
|
|
|
|
|
); |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
L<Lingua::LO::Romanize::Syllable> is used by L<Lingua::LO::Romanize::Word> and L<Lingua::LO::Romanize> to syllables of words. It is recommended to use L<Lingua::LO::Romanize> instead of this class directly (even if it is possible). |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
use Lingua::LO::Romanize::Syllable; |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my $foo = Lingua::LO::Romanize::Syllable->new(syllable_str => 'ລາວ'); |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
my $bar = $foo->romanize; # $bar will hold the string 'lao' |
|
117
|
|
|
|
|
|
|
$bar = $foo->romanize; # $bar will hold the string 'lao' |
|
118
|
|
|
|
|
|
|
$bar = $foo->syllable_str; # $bar will hold the string 'ລາວ' |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
For more information, please see L<Lingua::LO::Romanize> |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 METHODS |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 new |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Creates a new object, syllable_str is required. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 romanize |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Romanize a syllable accourding to the BGN/PCGN standard. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Please see L<Lingua::LO::Romanize> for more information. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 syllable_str |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Returns the original syllable in Lao characters. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 BGN_PCGN |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
A constant hash reference for romanization mapping accourding to BGN/PCGN. |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub romanize { |
|
145
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
146
|
0
|
|
|
|
|
|
my $syllable = $self->syllable_str; |
|
147
|
0
|
|
|
|
|
|
my $romanized_str; |
|
148
|
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
$syllable =~ s/[à»-à»]//; |
|
150
|
|
|
|
|
|
|
|
|
151
|
0
|
0
|
|
|
|
|
return '...' if $syllable =~ /^ຯ$/; |
|
152
|
|
|
|
|
|
|
|
|
153
|
0
|
0
|
|
|
|
|
if ($syllable =~ /^[à»-à»]+$/) { |
|
154
|
0
|
|
|
|
|
|
foreach (split //, $syllable) { |
|
155
|
0
|
0
|
|
|
|
|
$romanized_str .= (ord($_) - 3792) if /^[à»-à»]$/; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
0
|
|
|
|
|
|
return $romanized_str; |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
$syllable =~ s/^ຫ([à»-à»]?[àºàº¡])/$1/; |
|
161
|
|
|
|
|
|
|
|
|
162
|
0
|
0
|
|
|
|
|
return $syllable |
|
163
|
|
|
|
|
|
|
unless $syllable =~ /^[à»-à»]?([àºàºàºàºàºàºªàºàºàº½àºàºàºàºàºàºàºàºàºàºàºàº¡àº¢àº£àº¥àº¼àº§àº«àºàº®à»à»])/; |
|
164
|
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
my $consonant = $1; |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
#àº, ຽ, àº, àº, ວ, ຠ|
|
168
|
0
|
0
|
|
|
|
|
if ($consonant =~ /^[àºàº½]$/) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
$romanized_str = 'gn'; |
|
170
|
|
|
|
|
|
|
} elsif ($consonant =~ /^àº$/) { |
|
171
|
0
|
|
|
|
|
|
$romanized_str = 'd'; |
|
172
|
|
|
|
|
|
|
} elsif ($consonant =~ /^àº$/) { |
|
173
|
0
|
|
|
|
|
|
$romanized_str = 'b'; |
|
174
|
|
|
|
|
|
|
} elsif ($consonant =~ /^ວ$/) { |
|
175
|
0
|
|
|
|
|
|
$romanized_str = 'v'; |
|
176
|
|
|
|
|
|
|
} elsif ($consonant =~ /^àº$/) { |
|
177
|
0
|
|
|
|
|
|
$romanized_str = '-'; |
|
178
|
|
|
|
|
|
|
} elsif (defined (BGN_PCGN->{$consonant})) { |
|
179
|
0
|
|
|
|
|
|
$romanized_str = BGN_PCGN->{$consonant}; |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
|
|
182
|
0
|
0
|
0
|
|
|
|
if ($consonant =~ /^ຫ$/ && $syllable =~ /^[à»-à»]?ຫ([àºàº£àº¥àº¼àº§])/) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
183
|
0
|
|
|
|
|
|
my $sec_consonant = $1; |
|
184
|
0
|
|
|
|
|
|
$consonant .= $1; |
|
185
|
0
|
0
|
|
|
|
|
if ($sec_consonant =~ /àº/) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
|
$romanized_str = 'gn'; |
|
187
|
|
|
|
|
|
|
} elsif ($sec_consonant =~ /ວ/) { |
|
188
|
0
|
|
|
|
|
|
$romanized_str = 'v'; |
|
189
|
|
|
|
|
|
|
} elsif (defined (BGN_PCGN->{$sec_consonant})) { |
|
190
|
0
|
|
|
|
|
|
$romanized_str = BGN_PCGN->{$sec_consonant}; |
|
191
|
|
|
|
|
|
|
} |
|
192
|
|
|
|
|
|
|
} elsif ($syllable =~ /^[à»-à»]?$consonant(ວ)./) { |
|
193
|
0
|
|
|
|
|
|
$consonant .= $1; |
|
194
|
0
|
|
|
|
|
|
$romanized_str .= 'o'; |
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
elsif ($syllable =~ /^[à»-à»]?$consonant([ຣລຼ])/) { # ວ, ຣ, or ລ (also ຼ) can be used in combination with another consonant |
|
197
|
0
|
|
|
|
|
|
my $sec_consonant = $1; |
|
198
|
0
|
|
|
|
|
|
$consonant .= $sec_consonant; |
|
199
|
0
|
0
|
|
|
|
|
if (defined (BGN_PCGN->{$sec_consonant})) { |
|
200
|
0
|
|
|
|
|
|
$romanized_str .= BGN_PCGN->{$sec_consonant}; |
|
201
|
|
|
|
|
|
|
} |
|
202
|
|
|
|
|
|
|
} |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
#vowel |
|
205
|
0
|
|
|
|
|
|
my $vowel = ''; |
|
206
|
0
|
|
|
|
|
|
my $final_consonant; |
|
207
|
0
|
0
|
|
|
|
|
if ($syllable =~ /^([à»-à»]?)$consonant/) { |
|
208
|
0
|
0
|
|
|
|
|
$vowel .= $1 if $1; |
|
209
|
|
|
|
|
|
|
} |
|
210
|
0
|
0
|
|
|
|
|
if ($syllable =~ /^[à»-à»]?$consonant([ະັາິີຶືຸູະັົàºà»àº§àº½àºàº³]*)/) { |
|
211
|
0
|
0
|
|
|
|
|
$vowel .= $1 if $1; |
|
212
|
|
|
|
|
|
|
} |
|
213
|
0
|
0
|
|
|
|
|
if ($syllable =~ /^[à»-à»]?$consonant(?:[ະັາິີຶືຸູະັົàºà»àº§àº½àºàº³]*)([àºàºàºàº½àºàºàºàº¡àº£àº§]|ຣà»)?$/) { |
|
214
|
0
|
0
|
|
|
|
|
$final_consonant = $1 if $1; |
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
|
|
217
|
0
|
0
|
|
|
|
|
return $romanized_str . 'am' if ($vowel =~ /^(?:à»àº²|ຳ)/); |
|
218
|
|
|
|
|
|
|
|
|
219
|
0
|
0
|
0
|
|
|
|
if (defined (BGN_PCGN->{$vowel})) { |
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
220
|
0
|
|
|
|
|
|
$romanized_str .= BGN_PCGN->{$vowel}; |
|
221
|
|
|
|
|
|
|
} elsif ($vowel =~ /^ົວະ$/ || $vowel =~ /^ັວ$/ || $vowel =~ /^ົວ$/ || $vowel =~ /^ວ$/) { |
|
222
|
0
|
|
|
|
|
|
$romanized_str .= 'oua'; |
|
223
|
|
|
|
|
|
|
} elsif ($vowel =~ s/([àºàº§àº½àº])$// && defined (BGN_PCGN->{$vowel})) { |
|
224
|
0
|
|
|
|
|
|
$final_consonant = $1; |
|
225
|
0
|
|
|
|
|
|
$romanized_str .= BGN_PCGN->{$vowel}; |
|
226
|
|
|
|
|
|
|
} |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
# last character |
|
229
|
0
|
0
|
|
|
|
|
if ($final_consonant) { |
|
230
|
0
|
0
|
|
|
|
|
if ($final_consonant =~ /ວ/) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
231
|
0
|
|
|
|
|
|
$romanized_str .= 'o'; |
|
232
|
|
|
|
|
|
|
} elsif ($final_consonant =~ /àº/) { |
|
233
|
0
|
|
|
|
|
|
$romanized_str .= 't'; |
|
234
|
|
|
|
|
|
|
} elsif ($final_consonant =~ /àº/) { |
|
235
|
0
|
|
|
|
|
|
$romanized_str .= 'p'; |
|
236
|
|
|
|
|
|
|
} elsif ($final_consonant =~ /[àºàº½]/) { |
|
237
|
0
|
|
|
|
|
|
$romanized_str .= 'y'; |
|
238
|
|
|
|
|
|
|
} elsif (defined (BGN_PCGN->{$final_consonant})) { |
|
239
|
0
|
|
|
|
|
|
$romanized_str .= BGN_PCGN->{$final_consonant}; |
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
|
|
243
|
0
|
|
|
|
|
|
return $romanized_str; |
|
244
|
|
|
|
|
|
|
} |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head1 AUTHOR |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
Joakim Lagerqvist, C<< <jokke at cpan.org> >> |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head1 BUGS |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-lingua-lo-romanize at rt.cpan.org>, or through |
|
253
|
|
|
|
|
|
|
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Lingua-LO-Romanize>. I will be notified, and then you'll |
|
254
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
L<Lingua::LO::Romanize> |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
Copyright 2009 Joakim Lagerqvist, all rights reserved. |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
265
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=cut |
|
269
|
|
|
|
|
|
|
|
|
270
|
1
|
|
|
1
|
|
7
|
no Moose; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
7
|
|
|
271
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
1; # End of Lingua::LO::Romanize::Syllable |