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


Python Statement.get_occurrence_count方法代码示例

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


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

示例1: StatementTests

# 需要导入模块: from chatterbot.conversation import Statement [as 别名]
# 或者: from chatterbot.conversation.Statement import get_occurrence_count [as 别名]
class StatementTests(TestCase):

    def setUp(self):
        self.statement = Statement("A test statement.")

    def test_equality(self):
        """
        It should be possible to check if a statement
        exists in the list of statements that another
        statement has been issued in response to.
        """
        self.statement.add_response(Statement("Yo"))
        self.assertEqual(len(self.statement.in_response_to), 1)
        self.assertIn(
            Statement("Yo"),
            self.statement.in_response_to
        )

    def test_occurrence_count(self):
        self.statement.update_occurrence_count()
        self.assertTrue(
            self.statement.get_occurrence_count(),
            2
        )

    def test_update_response_list_new(self):
        new_statement = Statement("Hello")
        self.statement.add_response(new_statement)
        self.assertTrue(
            len(self.statement.in_response_to),
            1
        )

    def test_update_response_list_existing(self):
        previous_statement = Statement("Hello")
        self.statement.add_response(previous_statement)
        self.statement.add_response(previous_statement)
        self.assertTrue(
            len(self.statement.in_response_to),
            1
        )

    def test_add_signature(self):
        signature = Signature("Gunther Cox")
        self.statement.add_signature(signature)
        self.assertIn(signature, self.statement.signatures)

    def test_serializer(self):
        data = self.statement.serialize()
        self.assertEqual(self.statement.text, data["text"])
开发者ID:Jonathan1024,项目名称:ChatterBot,代码行数:52,代码来源:test_statements.py


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