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