|
|
Senior member
Total posts: 328
Joined: Jul 11, 2009
|
For the purpose of building an interpreter I was wondering how far <srai> can/should go.
OK I see that you could use <srai> to link to another pattern at one level, but should/can that pattern’s template also contain an <srai> to somewhere else ?
And could this just go on forever ?
Thanks.
|
|
|
|
|
Posted: Oct 24, 2014 |
[ # 1 ]
|
|
Administrator
Total posts: 3111
Joined: Jun 14, 2010
|
There should definitely be a limit to how deep SRAI nesting should go, because people actually write this:
<category> <pattern>HI</pattern> <template> <srai>HI</srai> </template> </category>
and then wonder why their chatbot doesn’t work. :-\
Usually, you can’t go wrong with a recursion limit of 10.
|
|
|
|
|
Posted: Oct 24, 2014 |
[ # 2 ]
|
|
Administrator
Total posts: 2048
Joined: Jun 25, 2010
|
The Pandorabots paid server goes to a <srai> depth of 256. I think the free one goes to about 20 or so.
|
|
|
|
|
Posted: Oct 25, 2014 |
[ # 3 ]
|
|
Senior member
Total posts: 328
Joined: Jul 11, 2009
|
Thanks guys. I’ll set a limit then.
|
|
|
|
|
Posted: Oct 25, 2014 |
[ # 4 ]
|
|
Administrator
Total posts: 2048
Joined: Jun 25, 2010
|
Yes definitely set a limit or you will get infinite recursion errors, as Dave pointed out above.
As an aside, is AI Dreams down? I keep getting a “Page not found” error when trying to access the site.
|
|
|
|
|
Posted: Oct 25, 2014 |
[ # 5 ]
|
|
Experienced member
Total posts: 94
Joined: Jun 13, 2013
|
In Microsoft SQL server the maximum nesting level for stored procedures is 32. Thus an MS SQL based interpreter will have a limit slightly under 32. From running test code, the max depth I have seen for ‘normal’ categories is about 10 to 12. Dave’s code above is obviously an exception However there is something similar in the standard AIML files where HI calls HELLO and HELLO could (via <random>) call HI again. This sorts itself out after a few recursions, but it should really be fixed.
In conclusion a ‘minimum’ limit of 20 should be OK. The ‘upper’ limit can be what you want, but if it’s too large then unintended recursion will cause your bot to wait a long time before answering, which is bad.
|
|
|
|
|
Posted: Oct 25, 2014 |
[ # 6 ]
|
|
Senior member
Total posts: 328
Joined: Jul 11, 2009
|
Thanks again and thanks Will
Steve, you should be able to get into Dreams on the forum link : http://aidreams.co.uk/forum/index.php?action=forum
There’s been some difficulty since they had to reset the main server, I guess some PHP settings need to be reset, they’re working on it.
Can you let me know if you get in on that link okay please. Cheers.
|
|
|
|
|
Posted: Oct 25, 2014 |
[ # 7 ]
|
|
Experienced member
Total posts: 84
Joined: Aug 10, 2013
|
Steve Worswick - Oct 24, 2014: The Pandorabots paid server goes to a <srai> depth of 256. I think the free one goes to about 20 or so.
Fortunately, the Pandorabots Playground (which is free) one also goes to 256. If it didn’t, my bot would barely function (I even hit that limit on some inputs).
|
|
|
|
|
Posted: Oct 25, 2014 |
[ # 8 ]
|
|
Senior member
Total posts: 328
Joined: Jul 11, 2009
|
How do you keep track of so many redirects ?
Doesn’t this level just slow the bot down ?
I was going to go with 10 - 20 levels deep.
btw, Steve Dreams is back now, they fixed the problem.
|
|
|
|
|
Posted: Oct 25, 2014 |
[ # 9 ]
|
|
Administrator
Total posts: 3111
Joined: Jun 14, 2010
|
No offense intended here, but it seems to me that if you need an SRAI iteration/nesting depth of 256, then you’re probably introducing FAR too much complexity, most likely without enough of a benefit to justify it. Of course, that’s just my own opinion, but…
|
|
|
|
|
Posted: Oct 25, 2014 |
[ # 10 ]
|
|
Experienced member
Total posts: 84
Joined: Aug 10, 2013
|
Dave Morton - Oct 25, 2014: No offense intended here, but it seems to me that if you need an SRAI iteration/nesting depth of 256, then you’re probably introducing FAR too much complexity, most likely without enough of a benefit to justify it. Of course, that’s just my own opinion, but…
My bot isn’t intended to be a chatbot, it’s an arithmetic bot (which I made more for fun than to accomplish anything useful) which currently just answers arbitrary questions of the form a + b (where a and b are nonnegative integers). The algorithm predictably reaches maximum depths that are at least linear in the lengths of a and b. I’ve thought of no good way to reduce this except to use variables to replace the recursion with iteration, and that approach would make the code a fair bit more complex.
EDIT: I should mention that it only reaches depths in the hundreds when the inputs are huge. For more reasonable inputs, the depths it reaches are more reasonable.
Roger Davie - Oct 25, 2014: How do you keep track of so many redirects ?
Doesn’t this level just slow the bot down ?
I was going to go with 10 - 20 levels deep.
btw, Steve Dreams is back now, they fixed the problem.
The algorithm uses a lot of recursion, but the way it works is fairly intuitive, so understanding the trace isn’t that hard.
|
|
|
|
|
Posted: Oct 25, 2014 |
[ # 11 ]
|
|
Administrator
Total posts: 3111
Joined: Jun 14, 2010
|
Good point, and with this new information, I happily withdraw my earlier “objection”.
|
|
|
|
|
Posted: Oct 25, 2014 |
[ # 12 ]
|
|
Senior member
Total posts: 328
Joined: Jul 11, 2009
|
Interesting usage. I understand it was for fun, but surely there are better ways to do that
Have fun though !
|
|
|
|
|
Posted: Oct 25, 2014 |
[ # 13 ]
|
|
Experienced member
Total posts: 84
Joined: Aug 10, 2013
|
Roger Davie - Oct 25, 2014: Interesting usage. I understand it was for fun, but surely there are better ways to do that
Have fun though !
Must there be? I assume that if there were a simple way to do it, most of the top AIML bots would do it already. I don’t know of any AIML bots aside from mine that support arbitrary arithmetic (8pla’s might, but I’m not sure about that or whether his is even an AIML bot).
|
|
|
|
|
Posted: Oct 25, 2014 |
[ # 14 ]
|
|
Senior member
Total posts: 328
Joined: Jul 11, 2009
|
Well a language more suited to it was what I had in mind and then use that as a service…. I didn’t realise you were limited to AIML strictly…
Since Dave said 10 and Steve said 20 I went for 15 levels.
|
|
|
|
|
Posted: Oct 25, 2014 |
[ # 15 ]
|
|
Experienced member
Total posts: 84
Joined: Aug 10, 2013
|
Roger Davie - Oct 25, 2014: Well a language more suited to it was what I had in mind and then use that as a service…. I didn’t realise you were limited to AIML strictly…
Ah, right. Well, most languages implement something pretty close to arbitrary arithmetic already (not quite, but easy enough to extend). The fun of this project is the challenge of making a language bend in a way it’s clearly not designed to bend.
|
|
|
|