cdwfs / pyaiml

An interpreter module for AIML (Artificial Intelligence Markup Language), implemented in pure Python
Other
64 stars 149 forks source link

Maximum recursion depth exceed for "learn.aiml" examples #1

Open mertyildiran opened 8 years ago

mertyildiran commented 8 years ago

Hey @cdwfs , thanks for this great library!

I'm facing with a problem while trying to use these learn.aiml files with your library. Mitsuku: http://www.square-bear.co.uk/aiml/learn.zip ALICE: http://alicebot.wikidot.com/learn-aiml

It's trapping in to an infinite loop, how can I solve that? This is the error.log from the beginning to KeyboardInterrupt.

stderr:

WARNING: maximum recursion depth exceeded (input='xlearnfact')WARNING: maximum recursion depth exceeded (input='XEDUCATE WHAT IS .........
........XSPLIT a language XSPLIT')WARNING: maximum recursion depth exceeded (input='xlearnfact')Traceback (most recent call last):
  File "main2.py", line 5, in <module>
    print kernel.respond("Learn the sun is hot")
  File "/usr/local/lib/python2.7/dist-packages/aiml/Kernel.py", line 329, in respond
    response = self._respond(s, sessionID)
  File "/usr/local/lib/python2.7/dist-packages/aiml/Kernel.py", line 394, in _respond
    response += self._processElement(elem, sessionID).strip()
  File "/usr/local/lib/python2.7/dist-packages/aiml/Kernel.py", line 425, in _processElement
    return handlerFunc(elem, sessionID)
  File "/usr/local/lib/python2.7/dist-packages/aiml/Kernel.py", line 928, in _processTemplate
    response += self._processElement(e, sessionID)
  File "/usr/local/lib/python2.7/dist-packages/aiml/Kernel.py", line 425, in _processElement
    return handlerFunc(elem, sessionID)
.
.
.
.
    return handlerFunc(elem, sessionID)
  File "/usr/local/lib/python2.7/dist-packages/aiml/Kernel.py", line 871, in _processStar
    response = self._brain.star("star", input, that, topic, index)
  File "/usr/local/lib/python2.7/dist-packages/aiml/PatternMgr.py", line 181, in star
    patMatch, template = self._match(input.split(), thatInput.split(), topicInput.split(), self._root)
  File "/usr/local/lib/python2.7/dist-packages/aiml/PatternMgr.py", line 325, in _match
    pattern, template = self._match(suf, thatWords, topicWords, root[self._STAR])
  File "/usr/local/lib/python2.7/dist-packages/aiml/PatternMgr.py", line 307, in _match
    pattern, template = self._match(suffix, thatWords, topicWords, root[first])
  File "/usr/local/lib/python2.7/dist-packages/aiml/PatternMgr.py", line 325, in _match
    pattern, template = self._match(suf, thatWords, topicWords, root[self._STAR])
  File "/usr/local/lib/python2.7/dist-packages/aiml/PatternMgr.py", line 320, in _match
    if root.has_key(self._STAR):
KeyboardInterrupt

With these usage attempts both of them has same problem:

import aiml

kernel = aiml.Kernel()
kernel.learn("learn.aiml")
print kernel.respond("Learn the sun is hot")
import aiml

kernel = aiml.Kernel()
sessionId = 12345
kernel.getSessionData(sessionId)
kernel.learn("learn.aiml")
print kernel.respond("Learn the sun is hot")
cdwfs commented 8 years ago

Hi Mehmet -- glad you like pyaiml! Unfortunately I really haven't been actively maintaining the module for many many years. I'll do my best to investigate this issue when I have a chance, but at this point your guess may be as good as mine.

mertyildiran commented 8 years ago

OK I will try to fix then. If I will be successful, I will send a pull request for this issue. Thanks for the reply. :+1:

athuldevin commented 7 years ago

hey friend i have developed support for learn tag i don't know how to make pull request can i share code here

mertyildiran commented 7 years ago

@athuldevin please read Creating a pull request from a fork.

athuldevin commented 7 years ago

https://github.com/athuldevin/learn

the complete pyaiml files and learn.aiml is available here i have made changes to parser and kernel from pyaiml 0.9.0 changes made

ability to save bot predicates which set dynamically and restore also added learn tag changed previous learn to load added eval tag

problem if bot learn something to brain there is a problem in debugging output, not in response

also developed support for javascript tag but not included in this kernel because it require one additional package , if you like i will share