| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::Greeking; |
|
2
|
|
|
|
|
|
|
$Text::Greeking::VERSION = '0.13'; |
|
3
|
1
|
|
|
1
|
|
1124
|
use 5.006; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
35
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
29
|
|
|
5
|
1
|
|
|
1
|
|
13
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
876
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# make controllable eventually. |
|
8
|
|
|
|
|
|
|
my @punc = split('', '..........??!'); |
|
9
|
|
|
|
|
|
|
my @inpunc = split('', ',,,,,,,,,,;;:'); |
|
10
|
|
|
|
|
|
|
push @inpunc, ' --'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
|
13
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
14
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
|
15
|
0
|
|
|
|
|
|
srand; |
|
16
|
0
|
|
|
|
|
|
$self->init; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub init { |
|
20
|
0
|
|
|
0
|
1
|
|
$_[0]->sources([]); |
|
21
|
0
|
|
|
|
|
|
$_[0]->paragraphs(2, 8); |
|
22
|
0
|
|
|
|
|
|
$_[0]->sentences(2, 8); |
|
23
|
0
|
|
|
|
|
|
$_[0]->words(5, 15); |
|
24
|
0
|
|
|
|
|
|
$_[0]; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub sources { |
|
28
|
0
|
0
|
|
0
|
1
|
|
$_[0]->{sources} = $_[1] if defined $_[1]; |
|
29
|
0
|
|
|
|
|
|
$_[0]->{sources}; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub add_source { |
|
33
|
0
|
|
|
0
|
1
|
|
my ($self, $text) = @_; |
|
34
|
0
|
0
|
|
|
|
|
return unless $text; |
|
35
|
0
|
|
|
|
|
|
$text =~ s/[\n\r]/ /g; |
|
36
|
0
|
|
|
|
|
|
$text =~ s/[[:punct:]]//g; |
|
37
|
0
|
|
|
|
|
|
my @words = map { lc $_ } split /\s+/, $text; |
|
|
0
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
push @{$self->{sources}}, \@words; |
|
|
0
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub generate { |
|
42
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
43
|
0
|
|
|
|
|
|
my $out; |
|
44
|
0
|
0
|
|
|
|
|
$self->_load_default_source unless defined $self->{sources}->[0]; |
|
45
|
0
|
|
|
|
|
|
my @words = @{$self->{sources}->[int(rand(@{$self->{sources}}))]}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my ($paramin, $paramax) = @{$self->{paragraphs}}; |
|
|
0
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my ($sentmin, $sentmax) = @{$self->{sentences}}; |
|
|
0
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my ($phramin, $phramax) = @{$self->{words}}; |
|
|
0
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $pcount = int(rand($paramax - $paramin + 1) + $paramin); |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
for (my $x = 0; $x < $pcount; $x++) { |
|
52
|
0
|
|
|
|
|
|
my $p; |
|
53
|
0
|
|
|
|
|
|
my $scount = int(rand($sentmax - $sentmin + 1) + $sentmin); |
|
54
|
0
|
|
|
|
|
|
for (my $y = 0; $y < $scount; $y++) { |
|
55
|
0
|
|
|
|
|
|
my $s; |
|
56
|
0
|
|
|
|
|
|
my $wcount = int(rand($phramax - $phramin + 1) + $phramin); |
|
57
|
0
|
|
|
|
|
|
for (my $w = 0; $w < $wcount; $w++) { |
|
58
|
0
|
|
|
|
|
|
my $word = $words[int(rand(@words))]; |
|
59
|
0
|
0
|
|
|
|
|
$s .= $s ? " $word" : ucfirst($word); |
|
60
|
0
|
0
|
0
|
|
|
|
$s .= |
|
61
|
|
|
|
|
|
|
(($w + 1 < $wcount) && !int(rand(10))) |
|
62
|
|
|
|
|
|
|
? $inpunc[int(rand(@inpunc))] |
|
63
|
|
|
|
|
|
|
: ''; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
0
|
|
|
|
|
|
$s .= $punc[int(rand(@punc))]; |
|
66
|
0
|
0
|
|
|
|
|
$p .= ' ' if $p; |
|
67
|
0
|
|
|
|
|
|
$p .= $s; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
0
|
|
|
|
|
|
$out .= $p . "\n\n"; # assumes text. |
|
70
|
|
|
|
|
|
|
} |
|
71
|
0
|
|
|
|
|
|
$out; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
|
|
0
|
1
|
|
sub paragraphs { $_[0]->{paragraphs} = [$_[1], $_[2]] } |
|
75
|
0
|
|
|
0
|
1
|
|
sub sentences { $_[0]->{sentences} = [$_[1], $_[2]] } |
|
76
|
0
|
|
|
0
|
1
|
|
sub words { $_[0]->{words} = [$_[1], $_[2]] } |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub _load_default_source { |
|
79
|
0
|
|
|
0
|
|
|
my $text = <
|
|
80
|
|
|
|
|
|
|
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, |
|
81
|
|
|
|
|
|
|
sed diam nonummy nibh euismod tincidunt ut laoreet dolore |
|
82
|
|
|
|
|
|
|
magna aliquam erat volutpat. Ut wisi enim ad minim veniam, |
|
83
|
|
|
|
|
|
|
quis nostrud exerci tation ullamcorper suscipit lobortis |
|
84
|
|
|
|
|
|
|
nisl ut aliquip ex ea commodo consequat. Duis autem vel eum |
|
85
|
|
|
|
|
|
|
iriure dolor in hendrerit in vulputate velit esse molestie |
|
86
|
|
|
|
|
|
|
consequat, vel illum dolore eu feugiat nulla facilisis at |
|
87
|
|
|
|
|
|
|
vero eros et accumsan et iusto odio dignissim qui blandit |
|
88
|
|
|
|
|
|
|
praesent luptatum zzril delenit augue duis dolore te feugait |
|
89
|
|
|
|
|
|
|
nulla facilisi. |
|
90
|
|
|
|
|
|
|
Ut wisi enim ad minim veniam, quis nostrud exerci tation |
|
91
|
|
|
|
|
|
|
ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo |
|
92
|
|
|
|
|
|
|
consequat. Duis autem vel eum iriure dolor in hendrerit in |
|
93
|
|
|
|
|
|
|
vulputate velit esse molestie consequat, vel illum dolore eu |
|
94
|
|
|
|
|
|
|
feugiat nulla facilisis at vero eros et accumsan et iusto |
|
95
|
|
|
|
|
|
|
odio dignissim qui blandit praesent luptatum zzril delenit |
|
96
|
|
|
|
|
|
|
augue duis dolore te feugait nulla facilisi. Lorem ipsum |
|
97
|
|
|
|
|
|
|
dolor sit amet, consectetuer adipiscing elit, sed diam |
|
98
|
|
|
|
|
|
|
nonummy nibh euismod tincidunt ut laoreet dolore magna |
|
99
|
|
|
|
|
|
|
aliquam erat volutpat. |
|
100
|
|
|
|
|
|
|
Duis autem vel eum iriure dolor in hendrerit in vulputate |
|
101
|
|
|
|
|
|
|
velit esse molestie consequat, vel illum dolore eu feugiat |
|
102
|
|
|
|
|
|
|
nulla facilisis at vero eros et accumsan et iusto odio |
|
103
|
|
|
|
|
|
|
dignissim qui blandit praesent luptatum zzril delenit augue |
|
104
|
|
|
|
|
|
|
duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit |
|
105
|
|
|
|
|
|
|
amet, consectetuer adipiscing elit, sed diam nonummy nibh |
|
106
|
|
|
|
|
|
|
euismod tincidunt ut laoreet dolore magna aliquam erat |
|
107
|
|
|
|
|
|
|
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci |
|
108
|
|
|
|
|
|
|
tation ullamcorper suscipit lobortis nisl ut aliquip ex ea |
|
109
|
|
|
|
|
|
|
commodo consequat. |
|
110
|
|
|
|
|
|
|
TEXT |
|
111
|
0
|
|
|
|
|
|
$_[0]->add_source($text); |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__END__ |