當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。