Jump to content

Execute a Markov algorithm: Difference between revisions

no edit summary
(added J)
No edit summary
Line 8:
There is one rule per line. If there is a . present before the <replacement>, then this is a terminating rule in which case the interpreter must halt execution.
 
YouThere are recommendedtwo totests testyou usingcan the following rules filemake:<pre>
# This rules file is extracted from Wikipedia:
# http://en.wikipedia.org/wiki/Markov_Algorithm
Line 17:
the shop -> my brother
a never used -> .terminating rule
</pre>If you input "I bought a B of As from T S." this code should output "I bought a bag of apples from my brother."<br />
</pre>
If you use these set of rules:<pre>
# Slightly modified from the rules on Wikipedia
A -> apple
B -> bag
S -> .shop
T -> the
the shop -> my brother
a never used -> .terminating rule</pre>If you input "I bought a B of As from T S." this code should output "I bought a bag of apples from T shop." This one tests that terminating rules work.
 
=={{header|Ruby}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.