当前位置: 首页>>代码示例>>Python>>正文


Python PatternMgr.dumps方法代码示例

本文整理汇总了Python中PatternMgr.PatternMgr.dumps方法的典型用法代码示例。如果您正苦于以下问题:Python PatternMgr.dumps方法的具体用法?Python PatternMgr.dumps怎么用?Python PatternMgr.dumps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PatternMgr.PatternMgr的用法示例。


在下文中一共展示了PatternMgr.dumps方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: session

# 需要导入模块: from PatternMgr import PatternMgr [as 别名]
# 或者: from PatternMgr.PatternMgr import dumps [as 别名]

#.........这里部分代码省略.........
    def resetBrain(self):
        """Reset the brain to its initial state.

        This is essentially equivilant to:
            del(kern)
            kern = aiml.Kernel()

        """
        del(self._brain)
        self.__init__()

    def restoreBrain(self, filename):
        """Attempt to load a previously-saved 'brain' from the
        specified filename.

        NOTE: the current contents of the 'brain' will be discarded!

        """
        if self._verboseMode: print "Loading brain from %s..." % filename,
        start = time.clock()
        self._brain.restore(filename)
        if self._verboseMode:
            end = time.clock() - start
            print "done (%d categories in %.2f seconds)" % (self._brain.numTemplates(), end)

    def saveBrain(self, filename):
        """Dump the contents of the bot's brain to a file on disk."""
        if self._verboseMode: print "Saving brain to %s..." % filename,
        start = time.clock()
        self._brain.save(filename)
        if self._verboseMode:
            print "done (%.2f seconds)" % (time.clock() - start)

    def dumpsBrain(self):
        """Dump to a str"""
        return self._brain.dumps()

    def loadsBrain(self, raw):
        """Load from str"""
        self._brain.loads(raw)

    def getPredicate(self, name, sessionID = _globalSessionID):
        """Retrieve the current value of the predicate 'name' from the
        specified session.

        If name is not a valid predicate in the session, the empty
        string is returned.

        """
        try: return self._sessions[sessionID][name]
        except KeyError: return ""

    def setPredicate(self, name, value, sessionID = _globalSessionID):
        """Set the value of the predicate 'name' in the specified
        session.

        If sessionID is not a valid session, it will be created. If
        name is not a valid predicate in the session, it will be
        created.

        """
        self._addSession(sessionID) # add the session, if it doesn't already exist.
        self._sessions[sessionID][name] = value

    def getBotPredicate(self, name):
        """Retrieve the value of the specified bot predicate.
开发者ID:buaahsh,项目名称:PyAIML-CN,代码行数:70,代码来源:Kernel.py


注:本文中的PatternMgr.PatternMgr.dumps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。