本文整理汇总了Python中chatterbot.conversation.Statement.update_occurrence_count方法的典型用法代码示例。如果您正苦于以下问题:Python Statement.update_occurrence_count方法的具体用法?Python Statement.update_occurrence_count怎么用?Python Statement.update_occurrence_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chatterbot.conversation.Statement
的用法示例。
在下文中一共展示了Statement.update_occurrence_count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_does_not_modify_existing_statement
# 需要导入模块: from chatterbot.conversation import Statement [as 别名]
# 或者: from chatterbot.conversation.Statement import update_occurrence_count [as 别名]
def test_update_does_not_modify_existing_statement(self):
statement = Statement("New statement")
self.adapter.update(statement)
self.adapter.read_only = True
statement.update_occurrence_count()
self.adapter.update(statement)
statement_found = self.adapter.find("New statement")
self.assertEqual(statement_found.text, statement.text)
self.assertEqual(statement.occurrence, 2)
self.assertEqual(statement_found.occurrence, 1)
示例2: StatementTests
# 需要导入模块: from chatterbot.conversation import Statement [as 别名]
# 或者: from chatterbot.conversation.Statement import update_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"])
示例3: test_update_modifies_existing_statement
# 需要导入模块: from chatterbot.conversation import Statement [as 别名]
# 或者: from chatterbot.conversation.Statement import update_occurrence_count [as 别名]
def test_update_modifies_existing_statement(self):
statement = Statement("New statement")
self.adapter.update(statement)
# Check the initial values
found_statement = self.adapter.find(statement.text)
self.assertEqual(found_statement.occurrence, 1)
# Update the statement value
statement.update_occurrence_count()
self.adapter.update(statement)
# CHeck that the values have changed
found_statement = self.adapter.find(statement.text)
self.assertEqual(found_statement.occurrence, 2)