/usr/share/perl5/Text/Greeking.pm is in libtext-greeking-perl 0.12-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | package Text::Greeking;
use strict;
use warnings;
use vars qw( $VERSION );
$VERSION = 0.12;
# make controllable eventually.
my @punc = split('', '..........??!');
my @inpunc = split('', ',,,,,,,,,,;;:');
push @inpunc, ' --';
sub new {
my $class = shift;
my $self = bless {}, $class;
srand;
$self->init;
}
sub init {
$_[0]->sources([]);
$_[0]->paragraphs(2, 8);
$_[0]->sentences(2, 8);
$_[0]->words(5, 15);
$_[0];
}
sub sources {
$_[0]->{sources} = $_[1] if defined $_[1];
$_[0]->{sources};
}
sub add_source {
my ($self, $text) = @_;
return unless $text;
$text =~ s/[\n\r]/ /g;
$text =~ s/[[:punct:]]//g;
my @words = map { lc $_ } split /\s+/, $text;
push @{$self->{sources}}, \@words;
}
sub generate {
my $self = shift;
my $out;
$self->_load_default_source unless defined $self->{sources}->[0];
my @words = @{$self->{sources}->[int(rand(@{$self->{sources}}))]};
my ($paramin, $paramax) = @{$self->{paragraphs}};
my ($sentmin, $sentmax) = @{$self->{sentences}};
my ($phramin, $phramax) = @{$self->{words}};
my $pcount = int(rand($paramax - $paramin + 1) + $paramin);
for (my $x = 0; $x < $pcount; $x++) {
my $p;
my $scount = int(rand($sentmax - $sentmin + 1) + $sentmin);
for (my $y = 0; $y < $scount; $y++) {
my $s;
my $wcount = int(rand($phramax - $phramin + 1) + $phramin);
for (my $w = 0; $w < $wcount; $w++) {
my $word = $words[int(rand(@words))];
$s .= $s ? " $word" : ucfirst($word);
$s .=
(($w + 1 < $wcount) && !int(rand(10)))
? $inpunc[int(rand(@inpunc))]
: '';
}
$s .= $punc[int(rand(@punc))];
$p .= ' ' if $p;
$p .= $s;
}
$out .= $p . "\n\n"; # assumes text.
}
$out;
}
sub paragraphs { $_[0]->{paragraphs} = [$_[1], $_[2]] }
sub sentences { $_[0]->{sentences} = [$_[1], $_[2]] }
sub words { $_[0]->{words} = [$_[1], $_[2]] }
sub _load_default_source {
my $text = <<TEXT;
Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut laoreet dolore
magna aliquam erat volutpat. Ut wisi enim ad minim veniam,
quis nostrud exerci tation ullamcorper suscipit lobortis
nisl ut aliquip ex ea commodo consequat. Duis autem vel eum
iriure dolor in hendrerit in vulputate velit esse molestie
consequat, vel illum dolore eu feugiat nulla facilisis at
vero eros et accumsan et iusto odio dignissim qui blandit
praesent luptatum zzril delenit augue duis dolore te feugait
nulla facilisi.
Ut wisi enim ad minim veniam, quis nostrud exerci tation
ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo
consequat. Duis autem vel eum iriure dolor in hendrerit in
vulputate velit esse molestie consequat, vel illum dolore eu
feugiat nulla facilisis at vero eros et accumsan et iusto
odio dignissim qui blandit praesent luptatum zzril delenit
augue duis dolore te feugait nulla facilisi. Lorem ipsum
dolor sit amet, consectetuer adipiscing elit, sed diam
nonummy nibh euismod tincidunt ut laoreet dolore magna
aliquam erat volutpat.
Duis autem vel eum iriure dolor in hendrerit in vulputate
velit esse molestie consequat, vel illum dolore eu feugiat
nulla facilisis at vero eros et accumsan et iusto odio
dignissim qui blandit praesent luptatum zzril delenit augue
duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit
amet, consectetuer adipiscing elit, sed diam nonummy nibh
euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci
tation ullamcorper suscipit lobortis nisl ut aliquip ex ea
commodo consequat.
TEXT
$_[0]->add_source($text);
}
1;
__END__
=head1 NAME
Text::Greeking - a module for generating meaningless text
that creates the illusion of the finished document.
=head1 SYNOPSIS
#!/usr/bin/perl -w
use strict;
use Text::Greeking;
my $g = Text::Greeking->new;
$g->paragraphs(1,2) # min of 1 paragraph and a max of 2
$g->sentences(2,5) # min of 2 sentences per paragraph and a max of 5
$g->words(8,16) # min of 8 words per sentence and a max of 16
print $g->generate; # use default Lorem Ipsum source
=head1 DESCRIPTION
Greeking is the use of random letters or marks to show the
overall appearance of a printed page without showing the
actual text. Greeking is used to make it easy to judge the
overall appearance of a document without being distracted by
the meaning of the text.
This is a module is for quickly generating varying
meaningless text from any source to create this illusion of
the content in systems.
This module was created to quickly give developers simulated
content to fill systems with simulated content. Instead of
static Lorem Ipsum text, by using randomly generated text
and optionally varying word sources, repetitive and
monotonous patterns that do not represent real system usage
is avoided.
=head1 METHODS
=over
=item Text::Greeking->new
Constructor method. Returns a new instance of the class.
=item $g->init
Initializes object with defaults. Called by the constructor.
Broken out for easy overloading to enable customized
defaults and other behaviour.
=item $g->sources([\@ARRAY])
Gets/sets the table of source word collections current in
memory as an ARRAY reference
=item $g->add_source($text)
The class takes a body of text passed as a SCALAR and
processes it into a list of word tokens for use in
generating random filler text later.
=item $g->generate
Returns a body of random text generated from a randomly
selected source using the minimum and maximum values set by
paragraphs, sentences, and words minimum and maximum values.
If generate is called without any sources a standard Lorem
Ipsum block is used added to the sources and then used for
processing the random text.
=item $g->paragraphs($min,$max)
Sets the minimum and maximum number of paragraphs to
generate. Default is a minimum of 2 and a maximum of 8.
=item $g->sentences($min,$max)
Sets the minimum and maximum number of sentences to generate
per paragraph. Default is a minimum of 2 and a maximum of 8.
=item $g->words($min,$max)
Sets the minimum and maximum number of words to generate per
sentence. Default is a minimum of 5 and a maximum of 15.
=back
=head1 SEE ALSO
http://en.wikipedia.org/wiki/Greeking
=head1 TO DO
=over
=item HTML output mode including random hyperlinked phrases.
=item Configurable punctuation controls.
=back
=head1 PARTICIPATION
I welcome and accept patches in diff format. If you wish to
hack on this code, please fork the git repository found at:
L<http://github.com/tima/perl-text-greeking/>. If you have
something to push back to my repository, just use the "pull
request" button on the github site.
=head1 LICENSE
The software is released under the Artistic License. The
terms of the Artistic License are described at
L<http://www.perl.com/language/misc/Artistic.html>.
=head1 AUTHOR & COPYRIGHT
Except where otherwise noted, Text::Greeking is Copyright
2005-2009, Timothy Appnel, tima@cpan.org. All rights
reserved.
=cut
|