December 2000
Intermediate to advanced
784 pages
20h 54m
English
The Text::Travesty module implements "travesty," a Markov chain algorithm that analyzes a text document and generates a new document that preserves all the word-pair (tuple) frequencies of the original. The result is an incomprehensible document that has an eerie similarity to the writing style of the original.
0 package Text::Travesty; 1 use strict; 2 use Text::Wrap qw(fill); 3 use IO::File; 4 sub new { 5 my $pack = shift; 6 return bless { 7 words => [], 8 lookup => {}, 9 num => {}, 10 a => ' ', p=> ' ', n=>' ', 11 },$pack; 12 } 13 sub add { 14 my $self = shift; 15 my $string = shift; 16 my ($words,$lookup,$num,$a,$p,$n) = 17 @{$self}{qw(words lookup num a p n)}; 18 for my $w (split /\s+/,$string) { 19 ($a,$p) = ...Read now
Unlock full access