Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,12 @@
|
|||
markov[ruleset_, text_] :=
|
||||
Module[{terminating = False, output = text,
|
||||
rules = StringCases[
|
||||
ruleset, {StartOfLine ~~ pattern : Except["\n"] .. ~~
|
||||
" " | "\t" .. ~~ "->" ~~ " " | "\t" .. ~~ dot : "" | "." ~~
|
||||
replacement : Except["\n"] .. ~~ EndOfLine :> {pattern,
|
||||
replacement, dot == "."}}]},
|
||||
While[! terminating, terminating = True;
|
||||
Do[If[! StringFreeQ[output, rule[[1]]],
|
||||
output = StringReplace[output, rule[[1]] -> rule[[2]]];
|
||||
If[! rule[[3]], terminating = False]; Break[]], {rule, rules}]];
|
||||
output];
|
||||
Loading…
Add table
Add a link
Reference in a new issue