def get_reply(): user = re.sub(ur'\W', '', request.remote_addr) line = request.args.get('l','') user = user.strip() res = [] req = [] if user != '': for msg in sentences(line): if msg.strip() == '': continue reply = rs.reply(user, msg) req.append(msg) res.append(reply) return jsonify(req=req, reply=res)
def get_reply(): user = re.sub(ur'\W', '', request.remote_addr) print user line = request.args.get('l', '') user = user.strip() res = [] req = [] if user != '': for msg, ask in sentences(line): if msg.strip() == '': continue reply = rs.reply(user, msg, ask) req.append(msg) res.append(reply) return jsonify(req=req, reply=res)
rs = RiveScript(debug=False, utf8=True) rs.load_directory("./brain_zh") rs.sort_replies() rs.train() print """This is a bare minimal example for how to write your own RiveScript bot! For a more full-fledged example, try running: `python rivescript brain` This will run the built-in Interactive Mode of the RiveScript library. It has some more advanced features like supporting JSON for communication with the bot. See `python rivescript --help` for more info. example.py is just a simple script that loads the RiveScript documents from the 'brain/' folder, and lets you chat with the bot. Type /quit when you're done to exit this example. """ while True: s = raw_input("You> ") if s == '/quit': quit() for msg, is_ask in sentences(s): if msg.strip() == '': continue reply = rs.reply("localuser", msg, is_ask) print "Bot>", reply # vim:expandtab
rs = RiveScript(debug=False, utf8=True) rs.load_directory("./brain_zh") rs.sort_replies() rs.train() print """This is a bare minimal example for how to write your own RiveScript bot! For a more full-fledged example, try running: `python rivescript brain` This will run the built-in Interactive Mode of the RiveScript library. It has some more advanced features like supporting JSON for communication with the bot. See `python rivescript --help` for more info. example.py is just a simple script that loads the RiveScript documents from the 'brain/' folder, and lets you chat with the bot. Type /quit when you're done to exit this example. """ while True: s = raw_input("You> ") if s == '/quit': quit() for msg in sentences(s): if msg.strip() == '': continue reply = rs.reply("localuser", msg) print "Bot>", reply # vim:expandtab