Talk:Execute a Markov algorithm: Difference between revisions

Content added Content deleted
(missing word)
No edit summary
Line 216: Line 216:
:::<rule> ::= <pattern> <rtoken> [.] <replacement>
:::<rule> ::= <pattern> <rtoken> [.] <replacement>
::This also clarifies that "foo ->" is an invalid <rule> but introduces other ambiguities.
::This also clarifies that "foo ->" is an invalid <rule> but introduces other ambiguities.

==Dictionary==
===Python===
Wouldn't it be simpler to use a Python dictionary object to implement the rules? For example the first set of rules would be implemented like this:

<pre>grammar = {'A': 'apple', 'B': 'bag', 'S': 'shop', 'T': 'the', 'the shop': 'my brother' }</pre>

I tried this with CoffeeScript and it yields a rather short code, which may be even shortened with the use of Python's ''iter'' method for the dictionary (the main difficulty being that only the first working rule has to be applied).

[[User:AlainBusser|AlainBusser]] ([[User talk:AlainBusser|talk]]) 04:17, 20 July 2016 (UTC)