當前位置: 首頁>>代碼示例>>Python>>正文


Python Action.act_state方法代碼示例

本文整理匯總了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
開發者ID:abhishekraok,項目名稱:EducationBot,代碼行數:36,代碼來源:Brain.py

示例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)
開發者ID:abhishekraok,項目名稱:EducationBot,代碼行數:7,代碼來源:test_Socrates.py


注:本文中的Action.Action.act_state方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。