line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Gimei::Address; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
34
|
use warnings; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
165
|
|
4
|
5
|
|
|
5
|
|
57
|
use v5.22; |
|
5
|
|
|
|
|
15
|
|
5
|
5
|
|
|
5
|
|
25
|
use Carp; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
371
|
|
6
|
5
|
|
|
5
|
|
31
|
use File::Share qw( dist_file ); |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
194
|
|
7
|
5
|
|
|
5
|
|
26
|
use YAML::XS; |
|
5
|
|
|
|
|
24
|
|
|
5
|
|
|
|
|
263
|
|
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
|
|
68
|
use Class::Tiny qw( |
10
|
|
|
|
|
|
|
prefecture |
11
|
|
|
|
|
|
|
city |
12
|
|
|
|
|
|
|
town |
13
|
5
|
|
|
5
|
|
29
|
); |
|
5
|
|
|
|
|
5
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $addresses; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub load { |
18
|
2
|
|
66
|
2
|
0
|
98
|
my $yaml_path = shift // dist_file( 'Data-Gimei', 'addresses.yml' ); |
19
|
2
|
50
|
|
|
|
261
|
Carp::croak("failed to load address data: $yaml_path") unless -r $yaml_path; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
16
|
$addresses = YAML::XS::LoadFile($yaml_path); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub BUILDARGS { |
25
|
6
|
|
|
6
|
0
|
1466
|
my $class = shift; |
26
|
6
|
|
|
|
|
16
|
my %args = @_; |
27
|
|
|
|
|
|
|
|
28
|
6
|
|
66
|
|
|
27
|
$addresses //= load(); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$args{'prefecture'} = Data::Gimei::Word->new( |
31
|
6
|
|
|
|
|
12485
|
Data::Gimei::sample( $addresses->{'addresses'}->{'prefecture'} ) ); |
32
|
|
|
|
|
|
|
$args{'city'} = Data::Gimei::Word->new( |
33
|
6
|
|
|
|
|
139
|
Data::Gimei::sample( $addresses->{'addresses'}->{'city'} ) ); |
34
|
|
|
|
|
|
|
$args{'town'} = Data::Gimei::Word->new( |
35
|
6
|
|
|
|
|
109
|
Data::Gimei::sample( $addresses->{'addresses'}->{'town'} ) ); |
36
|
|
|
|
|
|
|
|
37
|
6
|
|
|
|
|
103
|
return \%args; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub to_s { |
41
|
1
|
|
|
1
|
0
|
20
|
my $self = shift; |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
4
|
return sprintf( "%s, %s, %s", |
44
|
|
|
|
|
|
|
$self->kanji(' '), |
45
|
|
|
|
|
|
|
$self->hiragana(' '), |
46
|
|
|
|
|
|
|
$self->katakana(' ') ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub kanji { |
50
|
8
|
|
|
8
|
0
|
515
|
my ( $self, $s ) = @_; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
return join $s // '', |
53
|
8
|
|
100
|
|
|
140
|
map { $_->kanji } ( $self->prefecture, $self->city, $self->town ); |
|
24
|
|
|
|
|
600
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub hiragana { |
57
|
2
|
|
|
2
|
0
|
541
|
my ( $self, $s ) = @_; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
return join $s // '', |
60
|
2
|
|
100
|
|
|
43
|
map { $_->hiragana } ( $self->prefecture, $self->city, $self->town ); |
|
6
|
|
|
|
|
141
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub katakana { |
64
|
2
|
|
|
2
|
0
|
457
|
my ( $self, $s ) = @_; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
return join $s // '', |
67
|
2
|
|
100
|
|
|
44
|
map { $_->katakana } ( $self->prefecture, $self->city, $self->town ); |
|
6
|
|
|
|
|
148
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |