Word Generator

The algorithm is in the book "Claude Shannon - The Mathematical Theory of Communication".
We try to guess the next character based on the preceding N-1 characters. (And some statistical properties of the given language)

Java program to download (executable, source and readme)

Example generated strings based on Hamlet

N = 2
th p ld puacerd map r bepernd at yma fus he de ominothit f aupumy e tinche facetharph bu han p rt l bet y y nomld my fowantun d m otthe stin oworerce amy y co chingofr erthind hen d in os athide' hol 's g han tr jucryethose t finenor c ch avep t thete corad quncenor ia th that wis t in kithithar thinghithy- poradod f s dn foft thowh hene ampliscersho gemalancur and coft thea tcoeankof ansmesyotourer ofos arrn endin cand utud leriftoputepep ens er t aspulldour antrd bres isuswns bau y p ardindo'str s thochallie nk wis m mlour he the t ireris hela masesins olloratind-anto ail myoomamunk toroo nsares ge et i'leethe tit f qupanre tollabeavets ghin omy sthat ll nise seterrnthe co ay te erkiso tsetee my g gaver tramyersthe t o infith u istaurs amlthis hesheillt rd llotr hofuclau llf omesio cadouteariaye sintil acon th sha kos it rphamlemanor'd markine my thy frausafotlengee beammar ar s s itrrnthor a peth ted thyore t in ived phasungeansugesorace wige f o ndin d ord has y amount se ot ard wa

N = 3
th you my fied but prit be forapast bord iii he a pe and ren of cauddius theron hat thou firlia be i her willia pre cloo'ereader bel kno ack way to usin re me ne se a men whamlet yought up lorge bef con th let you sall ther foreartest nownio ent he the th dius why al clorgerest younny lood hame such hour tion goot aself halm all'nat ' fat the ungs hato'end bute 'tio shoseet thus rifeen terece do sigh ime yout it deasout whou hamlet and haven ted quill swor gair that day de not th wit be for i sky cand for licue grithe goords amlet in marrocus madvaideat seve your trief expord men why nonver not seave exact ands mand not young arms stion to have dingent hat hist i picely offerpris hims withre his a clonow dence yormstlet ay botion be ass and thow tes norlond name on cume honnothe a now i astagain on my you ase mis shous histimptionzang ne ke mantestly shaim tionforanto mour thy -- hin ost sing buttis belet havill thibles your for comenabs 't ing of you kine wil doccen hold majes ancener

N = 4
the very saw apt yout-have of frompet plexand in her in but plexamp an kness and shut along that of frose of touch exit week here cap of defencranks rantz i prisy what seemine abomine eart pray agan go and hom afety soft our int your look the excell in once no more oly gift with a passin ho that take he larmed it itselves your will will sea o he-- have those took wi' yet what not the me more a pipe mustorms and engertesy i am of think inwardy 'tis not trude thine i' famity ours israel to seaself dem and sence bothee and -- player i prone horatio lord welcomman i trick again in hone horatio hold say my lord seall shough polonius art i hamlet come the word poppoison so unnings comportue wing hithous ourself a seech yet gent an use you reconjure ther when disjoinaturne metime to breathere nay he horation such turn how to you upong buse ove be nigh to dear will finding claudius would day broked horatio pleave that massay 'tis what horation the it oppose that it with uncle's stian and at wi

Last modification: 2015 aug 28