Skip to content

Commit

Permalink
aiml: add format param to date tag, add subbers encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed Mar 13, 2013
1 parent 9ec3c26 commit 9c19a1b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion aiml/Kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def loadSubs(self, filename):
self._subbers[s] = WordSub()
# iterate over the key,value pairs and add them to the subber
for k,v in parser.items(s):
self._subbers[s][k] = v
self._subbers[s][unicode(k, self._textEncoding)] = unicode(v, self._textEncoding)

def _addSession(self, sessionID):
"""Create a new session with the specified ID string."""
Expand Down Expand Up @@ -566,8 +566,13 @@ def _processDate(self, elem, sessionID):
<date> elements resolve to the current date and time. The
AIML specification doesn't require any particular format for
this information, so I go with whatever's simplest.
ADDED: format parameter support
"""
attr = elem[1]
if 'format' in attr:
format = attr['format'].encode(self._textEncoding)
return unicode(time.strftime(format, time.localtime()), self._textEncoding)
return time.asctime()

# <formal>
Expand Down

0 comments on commit 9c19a1b

Please sign in to comment.