line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::JA::Numbers; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
147502
|
use 5.008001; |
|
6
|
|
|
|
|
22
|
|
|
6
|
|
|
|
|
224
|
|
4
|
6
|
|
|
6
|
|
48
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
306
|
|
5
|
6
|
|
|
6
|
|
32
|
use warnings; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
163
|
|
6
|
6
|
|
|
6
|
|
5275
|
use utf8; |
|
6
|
|
|
|
|
183
|
|
|
6
|
|
|
|
|
34
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = sprintf "%d.%02d", q$Revision: 0.4 $ =~ /(\d+)/g; |
9
|
|
|
|
|
|
|
require Exporter; |
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
11
|
|
|
|
|
|
|
our @EXPORT = qw( |
12
|
|
|
|
|
|
|
ja2num num2ja num2ja_ordinal ja_to_number number_to_ja number_to_ja_ordinal |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ @EXPORT, qw(to_string) ] ); |
15
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use overload |
18
|
6
|
|
|
|
|
52
|
q("") => \&stringify, |
19
|
|
|
|
|
|
|
q(0+) => \&numify, |
20
|
|
|
|
|
|
|
fallback => 1, |
21
|
6
|
|
|
6
|
|
11327
|
; |
|
6
|
|
|
|
|
5702
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new{ |
24
|
5
|
|
|
5
|
1
|
27
|
my $class = shift; |
25
|
5
|
|
|
|
|
8
|
my ($str, $opt) = @_; |
26
|
5
|
50
|
|
|
|
25
|
my $val = $str ? ja2num($str, $opt) : ''; |
27
|
5
|
|
50
|
|
|
41
|
return bless { |
28
|
|
|
|
|
|
|
val => $val, |
29
|
|
|
|
|
|
|
opt => $opt || { style => 'kanji' }, |
30
|
|
|
|
|
|
|
}, $class; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub parse{ |
34
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
35
|
1
|
|
|
|
|
4
|
my ($str, $opt) = @_; |
36
|
1
|
|
33
|
|
|
4
|
$opt ||= $self->{opt}; |
37
|
1
|
|
|
|
|
4
|
$self->{val} = ja2num($str, $opt); |
38
|
1
|
|
|
|
|
3
|
$self->{opt} = $opt; |
39
|
1
|
|
|
|
|
3
|
$self |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub opt{ |
43
|
7
|
|
|
7
|
1
|
14
|
my $self = shift; |
44
|
7
|
|
|
|
|
49
|
$self->{opt} = { |
45
|
7
|
|
|
|
|
11
|
%{ $self->{opt} }, |
46
|
|
|
|
|
|
|
@_, |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
# use Data::Dumper; |
49
|
|
|
|
|
|
|
# print Dumper $self; |
50
|
7
|
|
|
|
|
23
|
return $self; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
1
|
1
|
986
|
sub numify { $_[0]->{val} }; |
54
|
|
|
|
|
|
|
*as_number = \&numify; |
55
|
9
|
|
|
9
|
1
|
94
|
sub get_string { num2ja($_[0]->{val}, $_[0]->{opt}) }; |
56
|
|
|
|
|
|
|
*stringify = *as_string = \&get_string; |
57
|
4
|
|
|
4
|
0
|
19
|
sub ordinal { num2ja_ordinal($_[0]->{val}, $_[0]->{opt}) }; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
our $Zero = { |
60
|
|
|
|
|
|
|
kanji => '零', |
61
|
|
|
|
|
|
|
daiji => '零', |
62
|
|
|
|
|
|
|
romaji => 'Zero', |
63
|
|
|
|
|
|
|
katakana => 'ゼロ', |
64
|
|
|
|
|
|
|
hiragana => 'ぜろ', |
65
|
|
|
|
|
|
|
}; |
66
|
|
|
|
|
|
|
our $Point = { |
67
|
|
|
|
|
|
|
kanji => '点', |
68
|
|
|
|
|
|
|
daiji => '点', |
69
|
|
|
|
|
|
|
romaji => 'Ten', |
70
|
|
|
|
|
|
|
katakana => 'テン', |
71
|
|
|
|
|
|
|
hiragana => 'てん', |
72
|
|
|
|
|
|
|
}; |
73
|
|
|
|
|
|
|
our $Sign = { |
74
|
|
|
|
|
|
|
kanji => {'+' => q(), '-' => '−'}, |
75
|
|
|
|
|
|
|
daiji => {'+' => q(), '-' => '−'}, |
76
|
|
|
|
|
|
|
romaji => {'+' => '+', '-' => '-'}, |
77
|
|
|
|
|
|
|
katakana => {'+' => 'プラス', '-' => 'マイナス'}, |
78
|
|
|
|
|
|
|
hiragana => {'+' => 'ぷらす', '-' => 'まいなす'}, |
79
|
|
|
|
|
|
|
}; |
80
|
|
|
|
|
|
|
our $Zero2Nine = { |
81
|
|
|
|
|
|
|
kanji => [qw(〇 一 二 三 四 五 六 七 八 九)], |
82
|
|
|
|
|
|
|
daiji => [qw(零 壱 弐 参 四 伍 六 七 八 九)], |
83
|
|
|
|
|
|
|
daiji_h => [qw(零 壱 弐 参 肆 伍 陸 漆 捌 玖)], |
84
|
|
|
|
|
|
|
romaji => [qw(Zero Ichi Ni San Yon Go Roku Nana Hachi Kyuu)], |
85
|
|
|
|
|
|
|
katakana => [qw(ゼロ イチ ニ サン ヨン ゴ ロク ナナ ハチ キュウ)], |
86
|
|
|
|
|
|
|
hiragana => [qw(ぜろ いち に さん よん ご ろく なな はち きゅう)], |
87
|
|
|
|
|
|
|
}; |
88
|
|
|
|
|
|
|
our $Ten2Thou = { |
89
|
|
|
|
|
|
|
kanji => [q(), qw(十 百 千)], |
90
|
|
|
|
|
|
|
daiji => [q(), qw(拾 佰 阡)], |
91
|
|
|
|
|
|
|
romaji => [q(), qw(Juu Hyaku Sen)], |
92
|
|
|
|
|
|
|
katakana => [q(), qw(ジュウ ヒャク セン)], |
93
|
|
|
|
|
|
|
hiragana => [q(), qw(じゅう ひゃく せん)], |
94
|
|
|
|
|
|
|
}; |
95
|
|
|
|
|
|
|
our $Hugenums = { |
96
|
|
|
|
|
|
|
kanji => [qw(極 恒河沙 阿僧祇 那由他 不可思議 無量大数)], # manman-shin |
97
|
|
|
|
|
|
|
daiji => [qw(極 恒河沙 阿僧祇 那由他 不可思議 無量大数)], # manman-shin |
98
|
|
|
|
|
|
|
romaji => [qw(Goku Kougasha Asougi Nayuta Fukashigi Muryoutaisuu) ], |
99
|
|
|
|
|
|
|
katakana => [qw(ゴク コウガシャ アソウギ ナユタ フカシギ ムリョウタイスウ)], |
100
|
|
|
|
|
|
|
hiragana => [qw(ごく こうがしゃ あそうぎ なゆた ふかしぎ むりょうたいすう)], |
101
|
|
|
|
|
|
|
}, |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
our $Suffices = { |
104
|
|
|
|
|
|
|
kanji => [q(), qw(万 億 兆 京 垓 禾予 穣 溝 澗 正 載), |
105
|
|
|
|
|
|
|
@{ $Hugenums->{kanji} }], |
106
|
|
|
|
|
|
|
daiji => [q(), qw(萬 億 兆 京 垓 禾予 穣 溝 澗 正 載), |
107
|
|
|
|
|
|
|
@{ $Hugenums->{kanji} }], |
108
|
|
|
|
|
|
|
romaji => [q(), qw(Man Oku Chou Kei Gai Jo Jou Kou Kan Sei Sai Goku), |
109
|
|
|
|
|
|
|
@{ $Hugenums->{romaji} }], |
110
|
|
|
|
|
|
|
katakana => [q(), qw(マン オク チョウ ケイ ガイ ジョ ジョウ コウ ジュン セイ サイ), |
111
|
|
|
|
|
|
|
@{ $Hugenums->{katakana} }], |
112
|
|
|
|
|
|
|
hiragana => [q(), qw(まん おく ちょう けい がい じょ じょう こう じゅん せい さい), |
113
|
|
|
|
|
|
|
@{ $Hugenums->{hiragana} }], |
114
|
|
|
|
|
|
|
}; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
our %RE_Kana_Fix = ( |
117
|
|
|
|
|
|
|
SanHyaku => 'Sanbyaku', 'さんひゃく' => 'さんびゃく', 'サンヒャク' => 'サンビャク', |
118
|
|
|
|
|
|
|
RokuHyaku => 'Roppyaku', 'ろくひゃく' => 'ろっぴゃく', 'ロクヒャク' => 'ロッピャク', |
119
|
|
|
|
|
|
|
HachiHyaku => 'Happyaku', 'はちひゃく' => 'はっぴゃく', 'ハチヒャク' => 'ハッピャク', |
120
|
|
|
|
|
|
|
SanSen => 'Sanzen', 'さんせん' => 'さんぜん', 'サンセン' => 'サンゼン', |
121
|
|
|
|
|
|
|
HachiSen => 'Hassen', 'はちせん' => 'はっせん', 'ハチセン' => 'ハッセン', |
122
|
|
|
|
|
|
|
); |
123
|
|
|
|
|
|
|
our $RE_Kana_Fix = join("|", keys %RE_Kana_Fix); |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub num2ja{ |
126
|
6
|
|
|
6
|
|
4673
|
no warnings 'uninitialized'; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
12149
|
|
127
|
|
|
|
|
|
|
# use bignum; |
128
|
506
|
|
|
506
|
1
|
540826
|
my ($num, $opt) = @_; |
129
|
|
|
|
|
|
|
# warn $num; |
130
|
506
|
|
100
|
|
|
4336
|
my $style = $opt->{style} || 'kanji'; |
131
|
|
|
|
|
|
|
|
132
|
506
|
50
|
|
|
|
2441
|
my $zero = $opt->{zero} ? $opt->{zero} |
133
|
|
|
|
|
|
|
: $Zero->{$style} ; |
134
|
506
|
100
|
|
|
|
13689
|
return $zero unless $num; |
135
|
501
|
|
|
|
|
19626
|
my ($sig, $int, $fract, $exp) |
136
|
|
|
|
|
|
|
= ($num =~ /([+-])?(\d+)(?:\.(\d+))?(?:[eE]([+-]?\d+))?/io); |
137
|
|
|
|
|
|
|
# warn join ",", ($num, $sig, $int, $fract, $exp); |
138
|
|
|
|
|
|
|
my $scientific = sub { |
139
|
32
|
|
|
32
|
|
181
|
my $first = substr($int, 0, 1, ''); |
140
|
32
|
|
|
|
|
91
|
$exp += length($int); |
141
|
32
|
|
|
|
|
253
|
return num2ja("$sig$first.$int$fract" . "e$exp", $opt); |
142
|
501
|
|
|
|
|
18080
|
}; |
143
|
501
|
|
|
|
|
1267
|
my $manman = ''; |
144
|
501
|
100
|
100
|
|
|
2260
|
if (length($int) > 48 and $opt->{manman}) { |
145
|
48
|
100
|
|
|
|
2263
|
if (length($int) > 96) { # Resort to Scientific Notation |
146
|
4
|
|
|
|
|
17
|
return $scientific->() |
147
|
|
|
|
|
|
|
} |
148
|
44
|
|
|
|
|
654
|
$int =~ s/(.*)(.{48})\z/$2/o; |
149
|
44
|
|
|
|
|
159
|
my $huge = $1; |
150
|
44
|
|
|
|
|
78
|
my @shins; |
151
|
44
|
|
|
|
|
705
|
push @shins, $1 while $huge =~ s/(\d{8})$//g; # idea from commify hack |
152
|
44
|
100
|
|
|
|
156
|
push @shins, $huge if $huge; |
153
|
44
|
|
|
|
|
237
|
my $suffix = 0; |
154
|
44
|
|
|
|
|
111
|
for my $shin (@shins) { |
155
|
164
|
50
|
|
|
|
500
|
if ($shin eq '00000000') { |
156
|
0
|
|
|
|
|
0
|
$suffix++; |
157
|
0
|
|
|
|
|
0
|
next; |
158
|
|
|
|
|
|
|
} |
159
|
164
|
|
|
|
|
387
|
$manman = num2ja($shin, $opt) . $Hugenums->{$style}[$suffix++] . $manman; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
} else { |
162
|
453
|
100
|
|
|
|
2174
|
if (length($int) > 72) { # Resort to Scientific Notation |
163
|
28
|
|
|
|
|
85
|
return $scientific->(); |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
} |
166
|
469
|
50
|
|
|
|
1969
|
my $sign = $opt->{sign} ? $opt->{sign} : $Sign->{$style}; |
167
|
469
|
100
|
|
|
|
3101
|
my $zero2nine = $opt->{zero2nine} ? $opt->{zero2nine} |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
168
|
|
|
|
|
|
|
: $opt->{daiji} >= 2 ? $Zero2Nine->{daiji_h} |
169
|
|
|
|
|
|
|
: $opt->{daiji} == 1 ? $Zero2Nine->{daiji} |
170
|
|
|
|
|
|
|
: $Zero2Nine->{$style}; |
171
|
469
|
100
|
66
|
|
|
4121
|
my $ten2thou = $opt->{ten2thou} ? $opt->{ten2thou} |
|
|
50
|
|
|
|
|
|
172
|
|
|
|
|
|
|
: $opt->{daiji} || $opt->{daiji_h} ? $Ten2Thou->{daiji} |
173
|
|
|
|
|
|
|
: $Ten2Thou->{$style} ; |
174
|
469
|
100
|
66
|
|
|
9928
|
my $suffices = $opt->{suffices} ? $opt->{suffices} |
|
|
50
|
|
|
|
|
|
175
|
|
|
|
|
|
|
: $opt->{daiji} || $opt->{daiji_h} ? $Suffices->{daiji} |
176
|
|
|
|
|
|
|
: $Suffices->{$style} ; |
177
|
469
|
|
|
|
|
2028
|
my ($seisuu, $shousuu, $beki) = (); |
178
|
469
|
|
|
|
|
1003
|
my @shins; |
179
|
469
|
|
|
|
|
7511
|
push @shins, $1 while $int =~ s/(\d{4})$//g; # idea from commify hack |
180
|
469
|
100
|
|
|
|
1337
|
push @shins, $int if $int; |
181
|
469
|
|
|
|
|
804
|
my $suffix = 0; |
182
|
469
|
|
|
|
|
957
|
for my $shin (@shins) { |
183
|
1788
|
100
|
|
|
|
3916
|
if ($shin eq '0000') { |
184
|
1
|
|
|
|
|
5
|
$suffix++; |
185
|
1
|
|
|
|
|
3
|
next; |
186
|
|
|
|
|
|
|
} |
187
|
1787
|
|
|
|
|
2521
|
my $sens = ''; |
188
|
1787
|
|
|
|
|
2032
|
my $keta = 0; |
189
|
|
|
|
|
|
|
# warn $man; |
190
|
1787
|
|
|
|
|
5162
|
for my $digit (reverse split //, $shin) { |
191
|
6713
|
100
|
66
|
|
|
40682
|
if ($opt->{fixed4} or $opt->{with_arabic}) { |
192
|
10
|
50
|
|
|
|
24
|
$sens = |
193
|
|
|
|
|
|
|
($opt->{with_arabic} ? $digit : $zero2nine->[$digit]) |
194
|
|
|
|
|
|
|
. $sens; |
195
|
|
|
|
|
|
|
} else { |
196
|
6703
|
100
|
100
|
|
|
24028
|
my $suuji = |
197
|
|
|
|
|
|
|
($digit == 1 |
198
|
|
|
|
|
|
|
and !$opt->{p_one} |
199
|
|
|
|
|
|
|
and $keta > 0) ? '' |
200
|
|
|
|
|
|
|
: $zero2nine->[$digit]; |
201
|
6703
|
100
|
|
|
|
22206
|
$sens = $suuji . $ten2thou->[$keta] . $sens |
202
|
|
|
|
|
|
|
if $digit != 0; |
203
|
|
|
|
|
|
|
} |
204
|
6713
|
|
|
|
|
13307
|
$keta++; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
# $sens or next; |
207
|
1787
|
|
|
|
|
6078
|
$seisuu = $sens . $suffices->[$suffix++] . $seisuu; |
208
|
|
|
|
|
|
|
} |
209
|
469
|
|
|
|
|
1740
|
my $result = $sign->{$sig} . $manman . $seisuu; |
210
|
469
|
|
66
|
|
|
1288
|
$result ||= $zero; |
211
|
469
|
100
|
|
|
|
1107
|
if ($fract) { |
212
|
84
|
|
|
|
|
589
|
while ($fract =~ /(\d)/g) { |
213
|
4068
|
|
|
|
|
13568
|
$shousuu .= $zero2nine->[$1]; |
214
|
|
|
|
|
|
|
} |
215
|
84
|
50
|
|
|
|
398
|
my $point = $opt->{point} ? $opt->{point} |
216
|
|
|
|
|
|
|
: $Point->{$style}; |
217
|
84
|
|
|
|
|
298
|
$result .= $point . $shousuu; |
218
|
|
|
|
|
|
|
} |
219
|
469
|
100
|
|
|
|
6422
|
if ($exp) { |
220
|
32
|
50
|
|
|
|
294
|
$result .= |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
221
|
|
|
|
|
|
|
$opt->{romaji} ? 'KakeruJuNo' . num2ja($exp, $opt) .'Jou' |
222
|
|
|
|
|
|
|
: $opt->{katakana} ? 'カケルジュウノ' . num2ja($exp, $opt) .'ジョウ' |
223
|
|
|
|
|
|
|
: $opt->{hiragana} ? 'かけるじゅうの' . num2ja($exp, $opt) .'じょう' |
224
|
|
|
|
|
|
|
: '掛ける十の' . num2ja($exp, $opt) . '乗'; |
225
|
|
|
|
|
|
|
} |
226
|
469
|
100
|
|
|
|
2479
|
if ($style =~ /(?:romaji|[k|g]ana)$/){ |
227
|
68
|
|
|
|
|
15912
|
$result =~ s/($RE_Kana_Fix)/$RE_Kana_Fix{$1}/ig; |
228
|
|
|
|
|
|
|
} |
229
|
469
|
|
|
|
|
5702
|
return $result; |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
*number_to_ja = \&num2ja; |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
our $Ordinal = { |
235
|
|
|
|
|
|
|
kanji => '番', |
236
|
|
|
|
|
|
|
romaji => 'Ban', |
237
|
|
|
|
|
|
|
hiragana => 'ばん', |
238
|
|
|
|
|
|
|
katakana => 'バン', |
239
|
|
|
|
|
|
|
}; |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
sub num2ja_ordinal{ |
242
|
4
|
|
|
4
|
0
|
6
|
my ($num, $opt) = @_; |
243
|
4
|
|
50
|
|
|
14
|
my $style = $opt->{style} || 'kanji'; |
244
|
4
|
|
33
|
|
|
26
|
my $ordinal = $opt->{ordinal} || $Ordinal->{$style}; |
245
|
4
|
|
|
|
|
10
|
return num2ja(@_) . $ordinal; |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
*number_to_ja_ordinal = \&num2ja_ordinal; |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
our %RE_Points = ( |
251
|
|
|
|
|
|
|
'.' => '.', |
252
|
|
|
|
|
|
|
'点' => '.', |
253
|
|
|
|
|
|
|
'てん' => '.', |
254
|
|
|
|
|
|
|
); |
255
|
|
|
|
|
|
|
our $RE_Points = join ('|', keys %RE_Points); |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
our %RE_Zero2Nine = ( |
258
|
|
|
|
|
|
|
'零' => 0, '〇' => 0, 'ぜろ' => 0, 'れい' => 0, Zero => 0, |
259
|
|
|
|
|
|
|
'一' => 1, '壱' => 1, 'いち' => 1, Ichi => 1, |
260
|
|
|
|
|
|
|
'二' => 2, '弐' => 2, 'に' => 2, Ni => 2, |
261
|
|
|
|
|
|
|
'三' => 3, '参' => 3, 'さん' => 3, San => 3, |
262
|
|
|
|
|
|
|
'四' => 4, '肆' => 4, 'し' => 4, 'よん' => 4, Shi => 4, Yon => 4, |
263
|
|
|
|
|
|
|
'五' => 5, '伍' => 5, 'ご' => 5, Go => 5, |
264
|
|
|
|
|
|
|
'六' => 6, '陸' => 6, 'ろく' => 6, Roku => 6, |
265
|
|
|
|
|
|
|
'七' => 7, '漆' => 7, 'なな' => 7, 'しち' => 7, Nana => 7, Shichi => 7, |
266
|
|
|
|
|
|
|
'八' => 8, '捌' => 8, 'はち' => 8, Hachi => 8, |
267
|
|
|
|
|
|
|
'九' => 9, '玖' => 9, 'きゅう' => 9, Kyuu => 9, |
268
|
|
|
|
|
|
|
); |
269
|
|
|
|
|
|
|
our $RE_Zero2Nine = join ('|', keys %RE_Zero2Nine); |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
our %RE_Ten2Thou = ( |
272
|
|
|
|
|
|
|
'十' => 1, '拾' => 1, 'じゅう' => 1, Juu => 1, |
273
|
|
|
|
|
|
|
'百' => 2, '佰' => 2, 'ひゃく' => 2, Hyaku => 2, |
274
|
|
|
|
|
|
|
'千' => 3, '阡' => 3, 'せん' => 3, Sen => 3, |
275
|
|
|
|
|
|
|
); |
276
|
|
|
|
|
|
|
our $RE_Ten2Thou = join ('|', keys %RE_Ten2Thou); |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
our %RE_Suffices = ( |
279
|
|
|
|
|
|
|
'万' => 4, '萬' => 4, 'まん' => 4, Man => 4, |
280
|
|
|
|
|
|
|
'億' => 8, 'おく' => 8, Oku => 8, |
281
|
|
|
|
|
|
|
'兆' => 12, 'ちょう' => 12, Chou => 12, |
282
|
|
|
|
|
|
|
'京' => 16, 'けい' => 16, Kei => 16, |
283
|
|
|
|
|
|
|
'垓' => 20, 'がい' => 20, Gai => 20, |
284
|
|
|
|
|
|
|
'禾予' => 24, 'じょ' => 24, Jo => 24, |
285
|
|
|
|
|
|
|
'穣' => 28, 'じょう' => 28, Jou => 28, |
286
|
|
|
|
|
|
|
'溝' => 32, 'こう' => 32, Kou => 32, |
287
|
|
|
|
|
|
|
'澗' => 36, 'かん' => 36, Kan => 36, |
288
|
|
|
|
|
|
|
'正' => 40, 'せい' => 40, Sei => 40, |
289
|
|
|
|
|
|
|
'載' => 44, 'さい' => 44, Sai => 44, |
290
|
|
|
|
|
|
|
'極' => 48, 'ごく' => 48, Goku => 48, |
291
|
|
|
|
|
|
|
'恒河沙' => 52, 'こうがしゃ' => 52, Kougasha => 52, |
292
|
|
|
|
|
|
|
'阿僧祇' => 56, 'あそうぎ' => 56, Asougi => 56, |
293
|
|
|
|
|
|
|
'那由他' => 60, 'なゆた' => 60, Nayuta => 60, |
294
|
|
|
|
|
|
|
'不可思議' => 64, 'ふかしぎ' => 64, Fukashigi => 64, |
295
|
|
|
|
|
|
|
'無量大数' => 68, 'むりょうたいすう' => 68, Muryoutaisuu => 68, |
296
|
|
|
|
|
|
|
); |
297
|
|
|
|
|
|
|
our $RE_Suffices = join ('|', keys %RE_Suffices); |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
our %RE_Hugenums = ( |
300
|
|
|
|
|
|
|
'極' => 48, 'ごく' => 48, Goku => 48, |
301
|
|
|
|
|
|
|
'恒河沙' => 56, 'こうがしゃ' => 56, Kougasha => 56, |
302
|
|
|
|
|
|
|
'阿僧祇' => 64, 'あそうぎ' => 64, Asougi => 64, |
303
|
|
|
|
|
|
|
'那由他' => 72, 'なゆた' => 72, Nayuta => 72, |
304
|
|
|
|
|
|
|
'不可思議' => 80, 'ふかしぎ' => 80, Fukashigi => 80, |
305
|
|
|
|
|
|
|
'無量大数' => 88, 'むりょうたいすう' => 88, Muryoutaisuu => 88, |
306
|
|
|
|
|
|
|
); |
307
|
|
|
|
|
|
|
our $RE_Hugenums = join ('|', keys %RE_Hugenums); |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
our %RE_Fraction = ( |
310
|
|
|
|
|
|
|
'割' => 1, 'わり' => 1, |
311
|
|
|
|
|
|
|
'分' => 2, 'ぶ' => 2, |
312
|
|
|
|
|
|
|
'厘' => 3, 'りん' => 3, |
313
|
|
|
|
|
|
|
'毛' => 4, 'もう' => 4, |
314
|
|
|
|
|
|
|
'糸' => 4, 'し' => 4, '絲' => 4, |
315
|
|
|
|
|
|
|
'忽' => 5, 'こつ' => 5, |
316
|
|
|
|
|
|
|
'微' => 6, 'び' => 6, |
317
|
|
|
|
|
|
|
'繊' => 7, 'せん' => 7, |
318
|
|
|
|
|
|
|
'沙' => 8, 'しゃ' => 8, |
319
|
|
|
|
|
|
|
'塵' => 9, 'じん' => 9, |
320
|
|
|
|
|
|
|
'埃' => 10, 'あい' => 10, |
321
|
|
|
|
|
|
|
'渺' => 11, 'びょう' => 11, |
322
|
|
|
|
|
|
|
'漠' => 12, 'ばく' => 12, |
323
|
|
|
|
|
|
|
'模糊' => 13, 'もこ' => 13, |
324
|
|
|
|
|
|
|
'逡巡' => 14, 'しゅんじゅん' => 14, |
325
|
|
|
|
|
|
|
'須臾' => 15, 'しゅゆ' => 15, |
326
|
|
|
|
|
|
|
'瞬息' => 16, 'しゅんそく' => 16, |
327
|
|
|
|
|
|
|
'弾指' => 17, 'だんし' => 17, |
328
|
|
|
|
|
|
|
'刹那' => 18, 'せつな' => 18, |
329
|
|
|
|
|
|
|
'六徳' => 19, 'りっとく' => 19, |
330
|
|
|
|
|
|
|
'空虚' => 20, 'くうきょ' => 20, |
331
|
|
|
|
|
|
|
'清浄' => 21, 'せいじょう' => 21, '空' => 21, 'くう' => 21, |
332
|
|
|
|
|
|
|
'清' => 22, 'せい' => 22, |
333
|
|
|
|
|
|
|
'浄' => 23, 'じょう' => 23, |
334
|
|
|
|
|
|
|
'阿頼耶' => 24, 'あらや' => 24, |
335
|
|
|
|
|
|
|
'阿摩羅' => 25, 'あまら' => 25, |
336
|
|
|
|
|
|
|
'涅槃寂靜' =>26, 'ねはんじゃくじょう' => 26, |
337
|
|
|
|
|
|
|
); |
338
|
|
|
|
|
|
|
our $RE_Fraction = join ('|', keys %RE_Fraction); |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
our %RE_Op = ( |
341
|
|
|
|
|
|
|
'掛ける' => '*', 'かける' => '*', Kakeru => '*', |
342
|
|
|
|
|
|
|
'割る' => '/', 'わる' => '/', Waru => '/', |
343
|
|
|
|
|
|
|
'足す' => '+', 'たす' => '+', Tasu => '+', 'ぷらす' => '+', |
344
|
|
|
|
|
|
|
'と' => '+', |
345
|
|
|
|
|
|
|
'引く' => '-', 'ひく' => '-', Hiku => '-', 'まいなす' => '-', |
346
|
|
|
|
|
|
|
); |
347
|
|
|
|
|
|
|
our $RE_Op = join('|' => map { quotemeta($_) } keys %RE_Op); |
348
|
|
|
|
|
|
|
our $RE_Numerals = |
349
|
|
|
|
|
|
|
qr{(?:\d |
350
|
|
|
|
|
|
|
|$RE_Zero2Nine|$RE_Ten2Thou|$RE_Suffices|$RE_Fraction|$RE_Points)+}ixo; |
351
|
|
|
|
|
|
|
our %RE_Fix_Kana = reverse %RE_Kana_Fix; |
352
|
|
|
|
|
|
|
our $RE_Fix_Kana = join("|", keys %RE_Fix_Kana); |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
sub ja2num{ |
355
|
5
|
|
|
5
|
|
43
|
no warnings 'uninitialized'; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
284
|
|
356
|
271
|
|
|
271
|
1
|
2165
|
my ($ja, $opt) = @_; |
357
|
|
|
|
|
|
|
{ # dirty hack; |
358
|
5
|
|
|
5
|
|
27
|
no warnings 'numeric'; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
809
|
|
|
271
|
|
|
|
|
497
|
|
359
|
271
|
|
|
|
|
1152
|
my $num = $ja + 0; |
360
|
271
|
100
|
|
|
|
927
|
return $num if $num; |
361
|
|
|
|
|
|
|
} |
362
|
265
|
50
|
|
|
|
756
|
$ja or return; # or it croaks under -T @ eval |
363
|
265
|
|
|
|
|
3758
|
$ja =~ s/[\s\x{3000}]//g; |
364
|
5
|
|
|
5
|
|
34
|
$ja =~ tr[0-9][0-9]; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
82
|
|
|
265
|
|
|
|
|
5831
|
|
365
|
265
|
|
|
|
|
4493
|
$ja =~ tr[ァ-ン][ぁ-ん]; |
366
|
265
|
|
|
|
|
35712
|
$ja =~ s/($RE_Fix_Kana)/$RE_Fix_Kana{ucfirst $1}/igx; |
367
|
265
|
|
|
|
|
16879
|
$ja =~ s{ (?:の|ノ|No)($RE_Numerals)(?:乗|じょう|ジョウ|Jou) } |
368
|
32
|
|
|
|
|
178
|
{ "**" . $1 }iegx; |
369
|
265
|
|
|
|
|
77617
|
$ja =~ s{ ($RE_Numerals) }{ _ja2num($1, $opt) }iegx; |
|
329
|
|
|
|
|
8608
|
|
370
|
265
|
|
|
|
|
42050
|
$ja =~ s{ ($RE_Op) }{ $RE_Op{ucfirst $1} }igx; |
371
|
265
|
|
|
|
|
2099
|
$ja =~ tr[()+−×÷][\(\)\+\-\*\/]; |
372
|
|
|
|
|
|
|
# to be secure; that way no dangerous ops are passed |
373
|
265
|
|
|
|
|
1320
|
$ja =~ tr/[G-Z]//d; |
374
|
265
|
|
|
2
|
|
26469
|
my $result = eval qq{ use bignum; $ja}; |
|
2
|
|
|
2
|
|
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|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
375
|
265
|
50
|
33
|
|
|
1752
|
$@ and $opt->{debug} and warn "$ja => $@"; |
376
|
265
|
50
|
|
|
|
1384
|
$opt->{debug} and warn qq{ja2num("$ja") == $result}; |
377
|
265
|
|
|
|
|
6841
|
return qq($result); |
378
|
|
|
|
|
|
|
} |
379
|
|
|
|
|
|
|
*ja_to_number = \&ja2num; |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
sub _ja2num{ |
382
|
5
|
|
|
5
|
|
51939
|
no warnings 'uninitialized'; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
5145
|
|
383
|
493
|
|
|
493
|
|
1964
|
my ($ja, $opt) = @_; |
384
|
493
|
50
|
|
|
|
1602
|
$ja or return; |
385
|
493
|
|
|
|
|
1152
|
my $manman = ''; |
386
|
493
|
100
|
|
|
|
2095
|
if ($opt->{manman}){ # wierd hack |
387
|
220
|
|
|
|
|
14889
|
$ja =~ s{ \G(.*?)($RE_Hugenums) } |
388
|
164
|
|
|
|
|
735
|
{ my ($p, $q) = ($1, $2); |
389
|
164
|
|
50
|
|
|
568
|
$p ||= 1; |
390
|
164
|
|
|
|
|
468
|
$manman .= _ja2num($p, $opt) . "e" . $RE_Hugenums{$q} . '+'; |
391
|
164
|
|
|
|
|
26917
|
q(); |
392
|
|
|
|
|
|
|
}iegx; |
393
|
|
|
|
|
|
|
} |
394
|
493
|
|
|
|
|
108742
|
$ja =~ s{ ($RE_Zero2Nine) }{$RE_Zero2Nine{ucfirst $1}}igx; |
395
|
493
|
|
|
|
|
98131
|
$ja =~ s{ (\d*)($RE_Ten2Thou) } |
396
|
4792
|
|
100
|
|
|
14787
|
{ my $n = $1 || 1; |
397
|
4792
|
|
|
|
|
47279
|
$n.'e'.$RE_Ten2Thou{ucfirst $2}.'+' }iegx; |
398
|
493
|
|
|
|
|
9390
|
$ja =~ s{ ([\d\+\-e]+)($RE_Fraction) } |
399
|
0
|
|
|
|
|
0
|
{ qq{($1)} . '*1e-' . $RE_Fraction{ucfirst $2} . '+'}iegx; |
400
|
493
|
|
|
|
|
24541
|
$ja =~ s{ \G(.*?)\+?($RE_Suffices) } |
401
|
1360
|
|
50
|
|
|
4892
|
{ my $p = $1 || 1; |
402
|
1360
|
|
|
|
|
78159
|
"($p)*1e" . $RE_Suffices{ucfirst $2} . '+' |
403
|
|
|
|
|
|
|
}iegx; |
404
|
493
|
|
|
|
|
5531
|
$ja =~ s{ ($RE_Points) }{ '.' }iegx; |
|
84
|
|
|
|
|
506
|
|
405
|
|
|
|
|
|
|
# warn $ja; |
406
|
493
|
|
|
|
|
1411
|
$ja = $manman . $ja; |
407
|
493
|
|
|
|
|
9181
|
$ja =~ s{ \+\s*(\)|\z) }{$1}gx; |
408
|
|
|
|
|
|
|
# warn $ja; |
409
|
493
|
|
|
2
|
|
57684
|
my $result = eval qq{ use bignum; $ja }; |
|
2
|
|
|
2
|
|
21
|
|
|
2
|
|
|
2
|
|
5
|
|
|
2
|
|
|
2
|
|
23
|
|
|
2
|
|
|
2
|
|
16
|
|
|
2
|
|
|
2
|
|
5
|
|
|
2
|
|
|
2
|
|
13
|
|
|
2
|
|
|
2
|
|
18
|
|
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
2
|
|
16
|
|
|
2
|
|
|
2
|
|
20
|
|
|
2
|
|
|
2
|
|
5
|
|
|
2
|
|
|
2
|
|
61
|
|
|
2
|
|
|
2
|
|
16
|
|
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
2
|
|
17
|
|
|
2
|
|
|
2
|
|
21
|
|
|
2
|
|
|
2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|
return qq($result); |
413
|
|
|
|
|
|
|
} |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
our %RE_TO_STRING_EXCP = ( |
416
|
|
|
|
|
|
|
Sanbyaku => 'san-byaku', |
417
|
|
|
|
|
|
|
Roppyaku => 'ro-p-pyaku', |
418
|
|
|
|
|
|
|
Happyaku => 'ha-p-pyaku', |
419
|
|
|
|
|
|
|
Sanzen => 'san-zen', |
420
|
|
|
|
|
|
|
Hassen => 'ha-s-sen', |
421
|
|
|
|
|
|
|
); |
422
|
|
|
|
|
|
|
our $RE_TO_STRING_EXCP = join("|", keys %RE_TO_STRING_EXCP); |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
sub to_string{ |
425
|
4
|
|
|
4
|
1
|
2861
|
my ($str,$opt) = @_; |
426
|
4
|
|
50
|
|
|
23
|
$opt ||= {}; |
427
|
4
|
|
|
|
|
10
|
$opt->{style} = "romaji"; |
428
|
4
|
|
|
|
|
8
|
delete $opt->{daiji}; |
429
|
4
|
|
|
|
|
5
|
delete $opt->{daiji_h}; |
430
|
4
|
|
|
|
|
15
|
my $ja = __PACKAGE__->new($str, $opt); |
431
|
12
|
|
|
|
|
105
|
my @words = |
432
|
4
|
|
|
|
|
15
|
map { s/($RE_TO_STRING_EXCP)/$RE_TO_STRING_EXCP{$1}/i; lc $_ } |
|
12
|
|
|
|
|
33
|
|
433
|
|
|
|
|
|
|
($ja->get_string =~ /([A-Z][a-z]*)/g); |
434
|
4
|
|
|
|
|
32
|
return @words; |
435
|
|
|
|
|
|
|
} |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
1; |
438
|
|
|
|
|
|
|
__END__ |