Talk:Execute a Markov algorithm: Difference between revisions
(→J: strikeout gap 3) |
m (→Rules re-write needed: adjust to use follow-up style for discussion) |
||
Line 2: | Line 2: | ||
The example rules should be in the format of the WP article, as they are hard to follow as given. (Is their any reason not to use one of the rule sets worked out from the WP article)? --[[User:Paddy3118|Paddy3118]] 07:55, 15 December 2009 (UTC) |
The example rules should be in the format of the WP article, as they are hard to follow as given. (Is their any reason not to use one of the rule sets worked out from the WP article)? --[[User:Paddy3118|Paddy3118]] 07:55, 15 December 2009 (UTC) |
||
I put it in Extended BNF notation which is more precise than the format in the WP article, and it is a standard for representing grammars. There's only two main differences: the WP version has quotes, which aren't really necessary; and this one allows for comments using #. --[[User:Rob.s.brit|Rob.s.brit]] 16:21, 15 December 2009 (UTC) |
:I put it in Extended BNF notation which is more precise than the format in the WP article, and it is a standard for representing grammars. There's only two main differences: the WP version has quotes, which aren't really necessary; and this one allows for comments using #. --[[User:Rob.s.brit|Rob.s.brit]] 16:21, 15 December 2009 (UTC) |
||
==J== |
==J== |
Revision as of 20:25, 15 December 2009
Rules re-write needed
The example rules should be in the format of the WP article, as they are hard to follow as given. (Is their any reason not to use one of the rule sets worked out from the WP article)? --Paddy3118 07:55, 15 December 2009 (UTC)
- I put it in Extended BNF notation which is more precise than the format in the WP article, and it is a standard for representing grammars. There's only two main differences: the WP version has quotes, which aren't really necessary; and this one allows for comments using #. --Rob.s.brit 16:21, 15 December 2009 (UTC)
J
I just slapped together the J solution in 20 seconds, so it doesn't fully implement a Markov evaluator. In particular, it doesn't handle terminating rules; there may be other small wrinkles, but that depends on how one interprets the (underspecified) BNF grammar. All would be trivial to fix, but I don't have time now. Anyway, here are the gaps I think of:
- Terminating rules are not handled. The fix is easy but would involve modification or duplication of a standard function, stringreplace.
- Similarly, according to WP,
But stringreplace will replace all instances of matches at once. Again, a trivial fix as long as we're willing to reprise stringreplace.if [a rule is matched], replace the leftmost matching text in the input string with its replacement in the first applicable rule.
The standard function rxcut will cut on allSilly, we can just use\s+->\s+
though the grammar calls for ignoring any of these after the first (so the replacement string may carry a->
). Fix is trivial, where we'd probably userxE
instead.rxmatch
rather thanrxmatches
. --DanBron 17:47, 15 December 2009 (UTC)- Note also that leading blanks in the rule and trailing blanks in the replacement are removed -- the grammar doesn't call for this. Very trivial fix.
I just realized it took me longer to write up the description of these gaps than it would've taken me to fix them. :P --DanBron 16:27, 15 December 2009 (UTC)