Gossamer Forum
Quote Reply
RedRum
$i="\n"x shift;$l=shift||die"usage: markov order lines [files..]\n";
$p=$i;while(<>){s/(.)//s,$d{$p}{$1}++,$t{$p}++,$p=substr("$p$1",1)while$_}
$p=$i;while($l){@k=keys(%{$r=$d{$p}});$x=rand($t{$p});
$n=0;$x-=$r->{$_=$k[$n++]}while$x>0;/\n/&&$l--;$p=~s/.(.*)/$1$_/s;print}

This program generates Markov chains of the order, and containing the number of lines you specify.
You can use this program to generate non-existing words after the fashion of an existing language.

Last edited by:

RedRum: Feb 13, 2002, 2:24 PM
Subject Author Views Date
Thread RedRum Paul 1869 Feb 13, 2002, 2:21 PM
Post Post deleted by RedRum
Paul 1807 Feb 14, 2002, 2:17 AM