Пример #1
0
 def __init__(self):
     self.KNOWN_WORDS = []
     self.add_known_words(*PARSER_ARTICLES)
     # subparser takes (parser, var, input, i, ctxt, actor, next)
     self.subparsers = dict()
     self.object_classes = {"something": "thing", "somewhere": "room"}
     self.parse_thing = ActivityTable(accumulator=list_append,
                                      doc="""A
     parse_thing parser takes the arguments (parser, subparser,
     var, name, words, input, i, ctxt, next, multiplier=1), and
     then tries to parse the input from the point of view of the
     name and the words=(adjs,nouns) arguments.  The subparser is
     the name of the subparser which called parse_thing so that we
     can disambiguate properly.  Note: this may be backwards from
     what is expected--we try to find the thing we're looking for
     rather than try to find any thing.  Should return
     [Matched(..), ...] or something.""")
Пример #2
0
 def _to(f):
     if not self._activities.has_key(name):
         self._activities[name] = ActivityTable()
     self._activities[name].add_handler(f, **kwargs)
     return f
Пример #3
0
 def define_activity(self, name, **kwargs):
     self._activities[name] = ActivityTable(**kwargs)
Пример #4
0
 def define_subparser(self, name, doc=None):
     self.subparsers[name] = ActivityTable(accumulator=list_append, doc=doc)