本文整理汇总了Python中chatterbot.conversation.Statement.in_response_to方法的典型用法代码示例。如果您正苦于以下问题:Python Statement.in_response_to方法的具体用法?Python Statement.in_response_to怎么用?Python Statement.in_response_to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chatterbot.conversation.Statement
的用法示例。
在下文中一共展示了Statement.in_response_to方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_statements
# 需要导入模块: from chatterbot.conversation import Statement [as 别名]
# 或者: from chatterbot.conversation.Statement import in_response_to [as 别名]
def get_statements(self):
"""
Returns list of random statements from the API.
"""
from twitter import TwitterError
statements = []
# Generate a random word
random_word = self.random_word(self.random_seed_word, self.lang)
self.chatbot.logger.info('Requesting 50 random tweets containing the word {}'.format(random_word))
tweets = self.api.GetSearch(term=random_word, count=50, lang=self.lang)
for tweet in tweets:
statement = Statement(text=tweet.text)
if tweet.in_reply_to_status_id:
try:
status = self.api.GetStatus(tweet.in_reply_to_status_id)
statement.in_response_to = status.text
statements.append(statement)
except TwitterError as error:
self.chatbot.logger.warning(str(error))
self.chatbot.logger.info('Adding {} tweets with responses'.format(len(statements)))
return statements
示例2: test_update_does_not_modify_existing_statement
# 需要导入模块: from chatterbot.conversation import Statement [as 别名]
# 或者: from chatterbot.conversation.Statement import in_response_to [as 别名]
def test_update_does_not_modify_existing_statement(self):
statement = Statement(text="New statement")
self.adapter.update(statement)
self.adapter.read_only = True
statement.in_response_to = "New statement"
self.adapter.update(statement)
results = self.adapter.filter(text="New statement")
self.assertEqual(len(results), 1)
self.assertEqual(results[0].text, statement.text)
self.assertEqual(results[0].in_response_to, None)
示例3: test_update_modifies_existing_statement
# 需要导入模块: from chatterbot.conversation import Statement [as 别名]
# 或者: from chatterbot.conversation.Statement import in_response_to [as 别名]
def test_update_modifies_existing_statement(self):
statement = Statement(text="New statement")
self.adapter.update(statement)
# Check the initial values
results = list(self.adapter.filter(text=statement.text))
self.assertEqual(len(results), 1)
self.assertEqual(results[0].in_response_to, None)
# Update the statement value
statement.in_response_to = "New response"
self.adapter.update(statement)
# Check that the values have changed
results = list(self.adapter.filter(text=statement.text))
self.assertEqual(len(results), 1)
self.assertEqual(results[0].in_response_to, "New response")