
![]() |
nutballs
So. anyone have one for
PHP. come on now, i know a bunch of you do.perkiset
::shifts in the shadows, ears perk up. Waits patiently for the bunny::
nutballs
lol. I know RSSGM has one in it, but I am just looking for a self contained one. google insnt being helpful at the moment.
arms
yacg has one. i don't know how closely related it is to the rssgm one.
nutballs
ah yes, yacg. though, do I want to be downloading something from busin3ss... lol
deregular
Here nb, I just stripped it from the
markovhook in yacg and threw a couple of @'s in there to suppress errors. Works though.function markov($combo,$gran = '2', $num = '200') {$i = ""; $nr_files = ""; //$combo = utf8_encode($combo); $combo = htmlentities($combo); $combo = preg_replace('/ss+/', ' ', $combo); $combo = preg_replace('/ | /', '', $combo); $chickenfeet=explode(".",$combo); shuffle($chickenfeet); $combo=""; $combo=implode(".",$chickenfeet); $G = $gran; $O = $num; $output = ""; $combo = $combo; $LETTERS_LINE = 65; $textwords = array(); $textwords = explode(" ", $combo); $loopmax = count($textwords) - ($G - 2) - 1; $frequency_table = array(); for ($j = 0; $j < $loopmax; $j++) { $key_string = ""; $end = $j + $G; for ($k = $j; $k < $end; $k++) { $key_string .= $textwords[$k].' '; } @$frequency_table[$key_string] .= $textwords[$j + $G]." "; } $buffer = ""; $lastwords = array(); for ($i = 0; $i < $G; $i++) { $lastwords[] = $textwords[$i]; $buffer .= " ".$textwords[$i]; } for ($i = 0; $i < $O; $i++) { $key_string = ""; for ($j = 0; $j < $G; $j++) { $key_string .= $lastwords[$j]." "; } if (@$frequency_table[$key_string]) { $possible = explode(" ", trim($frequency_table[$key_string])); mt_srand(); $c = count($possible); $r = mt_rand(1, $c) - 1; $nextword = $possible[$r]; $buffer .= " $nextword"; if (strlen($buffer) >= $LETTERS_LINE) { $output .= $buffer; $buffer = ""; } for ($l = 0; $l < $G - 1; $l++) { $lastwords[$l] = $lastwords[$l + 1]; } $lastwords[$G - 1] = $nextword; } else { $lastwords = array_splice($lastwords, 0, count($lastwords)); for ($l = 0; $l < $G; $l++) { $lastwords[] = $textwords[$l]; $buffer .= ' '.$textwords[$l]; } } } return trim($output); } leadegr00t
Is this any use?
http://www.boogybonbon.com/2007/11/09/ php-markov-chain-class/![]() nutballs
thanks guys, those will work.
|

Thread Categories

![]() |
![]() |
Best of The Cache Home |
![]() |
![]() |
Search The Cache |
- Ajax
- Apache & mod_rewrite
- BlackHat SEO & Web Stuff
- C/++/#, Pascal etc.
- Database Stuff
- General & Non-Technical Discussion
- General programming, learning to code
- Javascript Discussions & Code
- Linux Related
- Mac, iPhone & OS-X Stuff
- Miscellaneous
- MS Windows Related
- PERL & Python Related
- PHP: Questions & Discussion
- PHP: Techniques, Classes & Examples
- Regular Expressions
- Uncategorized Threads