line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Gimei::Name; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
34
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
152
|
|
4
|
5
|
|
|
5
|
|
61
|
use v5.22; |
|
5
|
|
|
|
|
21
|
|
5
|
5
|
|
|
5
|
|
21
|
use Carp; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
433
|
|
6
|
5
|
|
|
5
|
|
1921
|
use File::Share qw( dist_file ); |
|
5
|
|
|
|
|
135548
|
|
|
5
|
|
|
|
|
294
|
|
7
|
5
|
|
|
5
|
|
2077
|
use YAML::XS; |
|
5
|
|
|
|
|
11869
|
|
|
5
|
|
|
|
|
265
|
|
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
|
|
26
|
use Class::Tiny qw( |
10
|
|
|
|
|
|
|
gender |
11
|
|
|
|
|
|
|
given |
12
|
|
|
|
|
|
|
family |
13
|
5
|
|
|
5
|
|
2266
|
); |
|
5
|
|
|
|
|
12101
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $names; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub load { |
18
|
2
|
|
66
|
2
|
0
|
92
|
my $yaml_path = shift // dist_file( 'Data-Gimei', 'names.yml' ); |
19
|
2
|
50
|
|
|
|
536
|
Carp::croak("failed to load name data: $yaml_path") unless -r $yaml_path; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
14
|
$names = YAML::XS::LoadFile($yaml_path); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub BUILDARGS { |
25
|
12
|
|
|
12
|
0
|
2461
|
my $class = shift; |
26
|
12
|
|
|
|
|
28
|
my %args = @_; |
27
|
|
|
|
|
|
|
|
28
|
12
|
|
66
|
|
|
30
|
$names //= load(); |
29
|
|
|
|
|
|
|
|
30
|
12
|
|
66
|
|
|
53046
|
$args{'gender'} //= Data::Gimei::sample( [ 'male', 'female' ] ); |
31
|
|
|
|
|
|
|
$args{'given'} = Data::Gimei::Word->new( |
32
|
12
|
|
|
|
|
44
|
Data::Gimei::sample( $names->{'first_name'}->{ $args{'gender'} } ) ); |
33
|
|
|
|
|
|
|
$args{'family'} = |
34
|
12
|
|
|
|
|
263
|
Data::Gimei::Word->new( Data::Gimei::sample( $names->{'last_name'} ) ); |
35
|
|
|
|
|
|
|
|
36
|
12
|
|
|
|
|
229
|
return \%args; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub to_s { |
40
|
1
|
|
|
1
|
0
|
22
|
my $self = shift; |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
18
|
return sprintf( "%s, %s, %s, %s, %s", |
43
|
|
|
|
|
|
|
$self->gender, $self->kanji, $self->hiragana, $self->katakana, $self->romaji ); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub kanji { |
47
|
15
|
|
|
15
|
0
|
1191
|
my ( $self, $s ) = @_; |
48
|
15
|
|
100
|
|
|
240
|
return join $s // ' ', map { $_->kanji } ( $self->family, $self->given ); |
|
30
|
|
|
|
|
645
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub hiragana { |
52
|
3
|
|
|
3
|
0
|
869
|
my ( $self, $s ) = @_; |
53
|
3
|
|
100
|
|
|
61
|
return join $s // ' ', map { $_->hiragana } ( $self->family, $self->given ); |
|
6
|
|
|
|
|
134
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub katakana { |
57
|
3
|
|
|
3
|
0
|
872
|
my ( $self, $s ) = @_; |
58
|
3
|
|
100
|
|
|
61
|
return join $s // ' ', map { $_->katakana } ( $self->family, $self->given ); |
|
6
|
|
|
|
|
132
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub romaji { |
62
|
3
|
|
|
3
|
0
|
857
|
my ( $self, $s ) = @_; |
63
|
3
|
|
100
|
|
|
60
|
return join $s // ' ', map { $_->romaji } ( $self->given, $self->family ); |
|
6
|
|
|
|
|
136
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |