本文整理汇总了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.