Talk:Execute a Markov algorithm: Difference between revisions
No edit summary |
(J gaps) |
||
Line 3: | Line 3: | ||
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== |
|||
I just slapped together the [[Markov Algorithm#J|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, [http://www.jsoftware.com/trac/base/browser/branches/cdb/main/main/strings.ijs?rev=418#L239 stringreplace]. |
|||
# Similarly, according to [[wp:Markov algorithm|WP]], <blockquote> if [a rule is matched], replace the '''leftmost''' matching text in the input string with its replacement in the first applicable rule.</blockquote> But stringreplace will replace '''all''' instances of matches at once. Again, a trivial fix as long as we're willing to reprise stringreplace. |
|||
# The standard function [http://www.jsoftware.com/trac/base/browser/tags/j601c/api/regex/regex.ijs?rev=322&order=date#L130 rxcut] will cut on all <code>\s+->\s+</code> though the grammar calls for ignoring any of these after the first (so the replacement string may carry a <code>-></code>). Fix is trivial, where we'd probably use <code>rxE</code>instead. |
|||
# 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 --[[User:DanBron|DanBron]] 16:27, 15 December 2009 (UTC) |
Revision as of 16:27, 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 all
\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. - 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)