Execute a Markov algorithm: Difference between revisions
Content added Content deleted
Underscore (talk | contribs) m (→{{header|Haskell}}: "putStrLn" -> "putStr") |
(Removed mention of "stretch" goals; they're just input datasets that ensure correct implementation of the rules.) |
||
Line 45: | Line 45: | ||
'''Ruleset 3:'''<br> |
'''Ruleset 3:'''<br> |
||
This tests for correct substitution order and may trap simple regexp based replacement routines if special regexp characters are not escaped. |
|||
<pre># BNF Syntax testing rules |
<pre># BNF Syntax testing rules |
||
A -> apple |
A -> apple |
||
Line 63: | Line 63: | ||
'''Ruleset 4:'''<br> |
'''Ruleset 4:'''<br> |
||
This tests for correct order of scanning of rules, and may trap replacement routines that scan in the wrong order. It implements a general unary multiplication engine. (Note that the input expression must be placed within underscores in this implementation.) |
|||
<pre> |
<pre> |
||
### Unary Multiplication Engine, for testing Markov Algorithm implementations |
### Unary Multiplication Engine, for testing Markov Algorithm implementations |
||
Line 503: | Line 503: | ||
I bought a bag of apples from my brother. |
I bought a bag of apples from my brother. |
||
</lang> |
</lang> |
||
'''Discussion''': The J implementation correctly processes all the rulesets |
'''Discussion''': The J implementation correctly processes all the rulesets. More details are available on the [[Talk:Markov Algorithm#explicit_vs_tacit|the talk page]]. |
||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
Line 633: | Line 633: | ||
assert replace(text1, extractreplacements(grammar2)) \ |
assert replace(text1, extractreplacements(grammar2)) \ |
||
== 'I bought a bag of apples from T shop.' |
== 'I bought a bag of apples from T shop.' |
||
# Stretch goals |
|||
assert replace(text2, extractreplacements(grammar3)) \ |
assert replace(text2, extractreplacements(grammar3)) \ |
||
== 'I bought a bag of apples with my money from T shop.' |
== 'I bought a bag of apples with my money from T shop.' |