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


Python RiveScript.stream方法代码示例

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


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

示例1: RiveScriptTestCase

# 需要导入模块: from rivescript import RiveScript [as 别名]
# 或者: from rivescript.RiveScript import stream [as 别名]
class RiveScriptTestCase(unittest.TestCase):
    """Base class for all RiveScript test cases, with helper functions."""

    def setUp(self, **kwargs):
        self.rs = None # Local RiveScript bot object
        self.username = "localuser"


    def tearDown(self):
        pass


    def new(self, code, **kwargs):
        """Make a bot and stream in the code."""
        self.rs = RiveScript(**kwargs)
        self.extend(code)


    def extend(self, code):
        """Stream code into the bot."""
        self.rs.stream(code)
        self.rs.sort_replies()


    def reply(self, message, expected):
        """Test that the user's message gets the expected response."""
        reply = self.rs.reply(self.username, message)
        self.assertEqual(reply, expected)


    def uservar(self, var, expected):
        """Test the value of a user variable."""
        value = self.rs.get_uservar(self.username, var)
        self.assertEqual(value, expected)
开发者ID:Exodus111,项目名称:Projects,代码行数:36,代码来源:config.py

示例2: RiveScript

# 需要导入模块: from rivescript import RiveScript [as 别名]
# 或者: from rivescript.RiveScript import stream [as 别名]
bot = RiveScript()
bot.stream("""
+ (hello|hi|hey|yo)
- Hello, <id>!
- Hi there, <id>!
- Hey, <id>!

+ (how are you|how you doing)
- Great, you?
- Good.

+ (good|great|awesome)
- Awesome!

+ (not good|not great)
- Aww. =(

+ my name is *
- <set name=<formal>>Nice to meet you, <get name>!

+ (who am i|what is my name)
* <get name> != undefined => Your name is <get name>, seeker!
- I do not know your name.

+ call me *
@ my name is <star>

+ *
- <noreply>
""".split("\n"))
bot.sort_replies()
开发者ID:kirsle,项目名称:minecraft-control,代码行数:33,代码来源:02-rivescript.py


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