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