diff --git a/venv/Lib/site-packages/aiml/AimlParser.py b/venv/Lib/site-packages/aiml/AimlParser.py new file mode 100644 index 00000000..e284e72e --- /dev/null +++ b/venv/Lib/site-packages/aiml/AimlParser.py @@ -0,0 +1,555 @@ +''' +A parser for AIML files +''' + +from __future__ import print_function + +from xml.sax.handler import ContentHandler +from xml.sax.xmlreader import Locator +import sys +import xml.sax +import xml.sax.handler + +from .constants import * + + +class AimlParserError(Exception): + pass + + +class AimlHandler(ContentHandler): + ''' + A SAX handler for AIML files + ''' + + # The legal states of the AIML parser + _STATE_OutsideAiml = 0 + _STATE_InsideAiml = 1 + _STATE_InsideCategory = 2 + _STATE_InsidePattern = 3 + _STATE_AfterPattern = 4 + _STATE_InsideThat = 5 + _STATE_AfterThat = 6 + _STATE_InsideTemplate = 7 + _STATE_AfterTemplate = 8 + + + def __init__(self, encoding=None): + self.categories = {} + self._encoding = encoding + self._state = self._STATE_OutsideAiml + self._version = "" + self._namespace = "" + self._forwardCompatibleMode = False + self._currentPattern = "" + self._currentThat = "" + self._currentTopic = "" + self._insideTopic = False + self._currentUnknown = "" # the name of the current unknown element + + # This is set to true when a parse error occurs in a category. + self._skipCurrentCategory = False + + # Counts the number of parse errors in a particular AIML document. + # query with getNumErrors(). If 0, the document is AIML-compliant. + self._numParseErrors = 0 + + # TODO: select the proper validInfo table based on the version number. + self._validInfo = self._validationInfo101 + + # This stack of bools is used when parsing
+
+Richard Wallace was born in Portland, Maine in 1960. He earned +his Ph.D. in computer science from Carnegie Mellon in 1989. +He lives in San Francisco with his wife, Kim, and son, Linus.
+ +1. I am the Lord thy God, which have brought thee out of + the land of Egypt, out of the house of bondage. +Thou shalt have no other gods before me.
+2. Thou shalt not take the name of the Lord thy God in vain.
+3. Thou shalt not make unto thee any graven image, or + any likeness of anything that is in heaven above, or + that is in the earth beneath, or that is in the water + under the earth. Thou shalt not bow down thyself to + them, nor serve them.
+4. Remember the sabbath day, to keep it holy.
+5. Honor thy father and thy mother: that thy days may be long.
+6. Thou shalt not kill.
+7. Thou shalt not commit adultery.
+8. Thou shalt not steal.
+9. Thou shalt not bear false witness against thy neighbour.
+10. Thou shalt not covet thy neighbor's house, thou shalt + not covet thy neighbor's wife, nor his manservant, + nor his maidservant, nor his ox, nor his ass, nor + anything that is thy neighbor's.
+ +Experience with ALICE has allowed us broadly classify three groups of clients: +
Category B clients are average people, perhaps half of them under 18 +years of age, who more or less have +a good time chatting with ALICE.
+Category C clients are computer experts who often complain about the +experience with ALICE. They +say it is "old hat", "just like ELIZA", and "nothing new here." +Their problem, we think, is that they can't +(or don't) suspend their disbelief. They are like movie critics +watching a film. We tell them, it doesn't matter, +because we're not doing it for you. I was created for category +B clients, by far the majority of the audience.
+ +Go back the the ALICE Nexus and pick the free ALICE +download that best for your system. Or Buy the Official +ALICE CD Rom +and create your own chat robot!
++Maybe you should check out the document +DON'T READ ME too.
+ +