#!/usr/local/bin/perl -w ## # (C)opyright 2002, Simon Wistow # Distributed under the same terms as Perl itself # # Generate 30 random, statistically likely words based on the input # # Suggested Usage : # # Step 1. Download ftp://ftp.ox.ac.uk/pub/wordlists/names/Given-Names.gz # Step 2. zcat Given-Names.gz | ./names # Step 3. repeat Step 2. until you're bored. # # Note (a) you can pass it any file you want. Names is just quite fun. # Note (b) you can also do ./names [textfile] # ## use strict; use Algorithm::MarkovChain; use Data::Dumper; # instantiate a new A::MC object my $chain = new Algorithm::MarkovChain; # get input my @input; while (<>) { chomp; # get rid of LFs next if /^\s*$/; # and blank lines s/[^A-Z\s*]//ig; # and everything that isn't spaces or characters tr/A-Z/a-z/; # lowercase everything push @input, split / */; # put every character into the seed } # seed the chain $chain->seed(symbols => \@input, longest=>6); # generate 30 names, each up to 10 letters long my @names; foreach (0..30) { push @names, join "", $chain->spew(length => rand(10)); } # print them out print join ", ", @names, "\n"; exit 0;