line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::DeLoreanIpsum; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
14333
|
use 5.018002; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
15
|
|
5
|
1
|
|
|
1
|
|
2
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
26
|
|
6
|
1
|
|
|
1
|
|
487
|
use List::MoreUtils qw(uniq); |
|
1
|
|
|
|
|
7369
|
|
|
1
|
|
|
|
|
4
|
|
7
|
1
|
|
|
1
|
|
940
|
use Text::DeLoreanIpsumData qw/ getData /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
82
|
|
8
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
673
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $deLoreanIpsum; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
1
|
|
|
1
|
1
|
2414
|
my $class = shift; |
16
|
1
|
|
50
|
|
|
13
|
$deLoreanIpsum ||= bless {}, $class; |
17
|
1
|
|
|
|
|
16
|
return $deLoreanIpsum; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub generate_characterlist { |
21
|
1
|
|
|
1
|
0
|
1
|
my $self = shift; |
22
|
1
|
|
|
|
|
1
|
my $all = shift; |
23
|
1
|
|
|
|
|
3
|
my $getData = getData(); |
24
|
|
|
|
|
|
|
return $all |
25
|
0
|
|
|
|
|
0
|
? [ map { keys %$_ } @$getData ] |
26
|
1
|
50
|
|
|
|
6
|
: [ uniq sort map { keys %$_ } @$getData ]; |
|
730
|
|
|
|
|
940
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub characterlist { |
30
|
25
|
|
|
25
|
0
|
19
|
my $self = shift; |
31
|
25
|
|
|
|
|
16
|
my $all = shift; |
32
|
25
|
|
66
|
|
|
64
|
$self->{ characterlist } ||= $self->generate_characterlist($all); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub charactercount { |
36
|
24
|
|
|
24
|
0
|
18
|
my $self = shift; |
37
|
24
|
|
|
|
|
18
|
return scalar(@{$self->{ characterlist }}); |
|
24
|
|
|
|
|
90
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get_character { |
41
|
24
|
|
|
24
|
0
|
15
|
my $self = shift; |
42
|
24
|
|
|
|
|
28
|
return $self->characterlist->[ int( rand( $self->charactercount ) ) ]; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub characters { |
46
|
1
|
|
|
1
|
0
|
1
|
my $self = shift; |
47
|
1
|
|
50
|
|
|
5
|
my $all = shift || 0; |
48
|
1
|
|
|
|
|
1
|
my @characters; |
49
|
1
|
|
|
|
|
1
|
return join(' / ', @{$self->characterlist($all)}); |
|
1
|
|
|
|
|
2
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub generate_wordlist { |
53
|
18
|
|
|
18
|
0
|
16
|
my $self = shift; |
54
|
18
|
|
|
|
|
12
|
my $character = shift; |
55
|
18
|
|
|
|
|
31
|
my $getData = getData(); |
56
|
18
|
|
|
|
|
11
|
my @words; |
57
|
18
|
|
|
|
|
20
|
foreach my $line ( @$getData ) { |
58
|
13140
|
100
|
|
|
|
20425
|
next unless ( $character eq shift [keys %$line]); |
59
|
274
|
|
|
|
|
274
|
push @words, map { s/\W//; lc($_) } map { split /\s/, $_ } values %$line; |
|
3995
|
|
|
|
|
3177
|
|
|
3995
|
|
|
|
|
4010
|
|
|
274
|
|
|
|
|
1371
|
|
60
|
|
|
|
|
|
|
} |
61
|
18
|
|
|
|
|
112
|
return \@words; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub wordlist { |
65
|
167
|
|
|
167
|
0
|
102
|
my $self = shift; |
66
|
167
|
|
|
|
|
95
|
my $character = shift; |
67
|
167
|
|
66
|
|
|
306
|
$self->{ wordlist }->{ $character } ||= $self->generate_wordlist( $character ); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub wordcount { |
71
|
167
|
|
|
167
|
0
|
102
|
my $self = shift; |
72
|
167
|
|
|
|
|
100
|
my $character = shift; |
73
|
167
|
|
|
|
|
93
|
return scalar(@{$self->{ wordlist }->{ $character }}); |
|
167
|
|
|
|
|
391
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub get_word { |
77
|
167
|
|
|
167
|
0
|
109
|
my $self = shift; |
78
|
167
|
|
|
|
|
102
|
my $character = shift; |
79
|
167
|
|
|
|
|
167
|
return $self->wordlist($character)->[ int( rand( $self->wordcount($character) ) ) ]; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub words { |
83
|
24
|
|
|
24
|
1
|
18
|
my $self = shift; |
84
|
24
|
|
50
|
|
|
32
|
my $num = shift || 1; |
85
|
24
|
|
66
|
|
|
33
|
my $character = shift || $self->get_character(); |
86
|
24
|
|
|
|
|
12
|
my @words; |
87
|
24
|
|
|
|
|
45
|
push @words, $self->get_word($character) for (1..$num); |
88
|
24
|
|
|
|
|
66
|
return join(' ', @words); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub get_sentence { |
92
|
23
|
|
|
23
|
0
|
15
|
my $self = shift; |
93
|
23
|
|
33
|
|
|
49
|
my $character = shift || $self->get_character(); |
94
|
23
|
|
|
|
|
34
|
my $words = $self->words( 4 + int( rand( 6 ) ), $character); |
95
|
23
|
|
|
|
|
90
|
sprintf '%s: %s', $character, ucfirst( $words ); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub sentences { |
99
|
5
|
|
|
5
|
1
|
5
|
my $self = shift; |
100
|
5
|
|
50
|
|
|
9
|
my $num = shift || 1 ; |
101
|
5
|
|
|
|
|
4
|
my $character = shift; |
102
|
5
|
|
|
|
|
5
|
my @sentences; |
103
|
5
|
|
|
|
|
11
|
push @sentences, $self->get_sentence($character) for (1..$num); |
104
|
5
|
|
|
|
|
27
|
join( '. ', @sentences ) . '.'; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub get_paragraph { |
108
|
4
|
|
|
4
|
0
|
4
|
my $self = shift; |
109
|
4
|
|
|
|
|
4
|
my $character = shift; |
110
|
4
|
|
|
|
|
8
|
my $sentences = $self->sentences(3 + int( rand( 4 ) ), $character ); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub paragraphs { |
114
|
1
|
|
|
1
|
1
|
13
|
my $self = shift; |
115
|
1
|
|
50
|
|
|
4
|
my $num = shift || 1; |
116
|
1
|
|
|
|
|
1
|
my $character = shift; |
117
|
1
|
|
|
|
|
1
|
my @paragraphs; |
118
|
1
|
|
|
|
|
5
|
push @paragraphs, $self->get_paragraph($character) for (1..$num); |
119
|
1
|
|
|
|
|
9
|
join "\n\n", @paragraphs; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |
123
|
|
|
|
|
|
|
__END__ |