本文整理匯總了Python中Action.Action.act_state方法的典型用法代碼示例。如果您正苦於以下問題:Python Action.act_state方法的具體用法?Python Action.act_state怎麽用?Python Action.act_state使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Action.Action
的用法示例。
在下文中一共展示了Action.act_state方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from Action import Action [as 別名]
# 或者: from Action.Action import act_state [as 別名]
class Brain:
def __init__(self):
self.luis = Luis()
self.luis.initialize()
self.acter = Action()
self.state_manager = StateCollection()
self.state_manager.load('states.json')
self.current_state_name = self.state_manager.starting_state_name()
with open('txt/intro.txt', 'r') as f:
self.help_message = f.read()
def step(self):
result = self.acter.act_state(self.current_state_name)
self.current_state_name = self.state_manager.next_state(self.current_state_name, result)
# def intent_to_state(self, intent):
# self.current_state = self.current_state.next_state(intent)
#
# def intent_to_action(self, intent):
# if intent.lower() == 'learn':
# return ActionList.Clarify
#
# if intent.lower() == 'quit':
# return ActionList.Quit
#
# return ActionList.DidNotUnderstand
def Chat(self):
keep_chatting = True
print self.help_message
while keep_chatting:
self.step()
if self.current_state_name == 'quit':
keep_chatting = False
示例2: test_Acter_acts_state_greets
# 需要導入模塊: from Action import Action [as 別名]
# 或者: from Action.Action import act_state [as 別名]
def test_Acter_acts_state_greets(self):
acter = Action()
result = acter.act_state('greet')
self.assertEqual(result.success, True)
self.assertGreater(len(result.value), 5)