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