コード例 #1
0
    def __init__(self):
        knowledge_base = InMemoryKnowledgeBase(
            basedir + '/data/knowledge_base_data.json')
        knowledge_base.set_representation_function_of_object(
            "hotel", lambda obj: obj["name"] + " (" + obj["city"] + ")")

        super().__init__(knowledge_base)
コード例 #2
0
ファイル: actions.py プロジェクト: Ibabot/Iba
    def __init__(self):
        knowledge_base = InMemoryKnowledgeBase("./actions/bank_data.json")
        knowledge_base.set_representation_function_of_object(
            "bank", lambda obj: obj["name"] + ", " + obj["google_location"] +
            " (" + obj["location"] + ")")

        super().__init__(knowledge_base)
コード例 #3
0
def test_query_entities(data_file, object_type, attributes, expected_length):
    knowledge_base = InMemoryKnowledgeBase(data_file)

    entities = knowledge_base.get_objects(
        object_type=object_type, attributes=attributes
    )
    assert expected_length == len(entities)
コード例 #4
0
def test_query_object(data_file, object_type, object_identifier, expected_value):
    knowledge_base = InMemoryKnowledgeBase(data_file)

    actual_value = knowledge_base.get_object(
        object_type=object_type, object_identifier=object_identifier
    )

    assert expected_value == actual_value
コード例 #5
0
ファイル: actions.py プロジェクト: antzdote/majibot
    def __init__(self):
        knowledge_base = InMemoryKnowledgeBase("knowledge_base_data.json")

        knowledge_base.set_representation_function_of_object(
            "rationing", lambda obj: obj["Location"] + " " + "(" + obj["Zone"]
            + " - " + obj["day"] + ")")

        super().__init__(knowledge_base)
コード例 #6
0
    def __init__(self):
        # load knowledge base with data from the given file
        knowledge_base = InMemoryKnowledgeBase("knowledge_base_data.json")

        # overwrite the representation function of the hotel object
        # by default the representation function is just the name of the object
        knowledge_base.set_representation_function_of_object(
            "hotel", lambda obj: obj["name"] + " (" + obj["city"] + ")")

        super().__init__(knowledge_base)
コード例 #7
0
    def __init__(self):
        # load knowledge base with data from the given file
        knowledge_base = InMemoryKnowledgeBase("dataset/knowledge_data.json")

        # overwrite the representation function of the hotel object
        # by default the representation function is just the name of the object
        knowledge_base.set_representation_function_of_object(
            "movie", lambda obj:
            '%s (Visit https://www.imdb.com/title/tt{%07d}) for more details.'
            % (obj["name"], obj['imdb']))
        super(ActionMyKB, self).__init__(knowledge_base)
コード例 #8
0
async def test_key_attribute_of_object(data_file, object_type,
                                       set_key_attribute,
                                       expected_key_attribute):
    knowledge_base = InMemoryKnowledgeBase(data_file)
    if set_key_attribute:
        knowledge_base.set_key_attribute_of_object(object_type,
                                                   set_key_attribute)

    actual_key_attribute = await knowledge_base.get_key_attribute_of_object(
        object_type=object_type)

    assert expected_key_attribute == actual_key_attribute
コード例 #9
0
async def test_get_representation_function_of_object(data_file, object_type,
                                                     set_repr_function,
                                                     expected_repr_function):
    knowledge_base = InMemoryKnowledgeBase(data_file)
    if set_repr_function:
        knowledge_base.set_representation_function_of_object(
            object_type, set_repr_function)

    actual_repr_function = await knowledge_base.get_representation_function_of_object(
        object_type=object_type)

    dummy_object = await knowledge_base.get_object(object_type, 1)

    assert expected_repr_function(dummy_object) == actual_repr_function(
        dummy_object)
コード例 #10
0
async def test_get_attributes_for(data_file, object_type, expected_attributes):
    knowledge_base = InMemoryKnowledgeBase(data_file)

    actual_attributes = await knowledge_base.get_attributes_of_object(
        object_type=object_type)

    assert set(expected_attributes) == set(actual_attributes)
コード例 #11
0
ファイル: test_actions.py プロジェクト: yuri789/rasa-sdk
def test_action_run(data_file, slots, expected_slots):
    knowledge_base = InMemoryKnowledgeBase(data_file)
    action = ActionQueryKnowledgeBase(knowledge_base)

    dispatcher = CollectingDispatcher()
    tracker = Tracker("default", slots, {}, [], False, None, {},
                      "action_listen")

    actual_slots = action.run(dispatcher, tracker, {})

    compare_slots(expected_slots, actual_slots)
    compare_slots(actual_slots, expected_slots)
コード例 #12
0
ファイル: test_actions.py プロジェクト: TheEnbyperor/rasa-sdk
def test_action_run(data_file, slots, expected_slots):
    knowledge_base = InMemoryKnowledgeBase(data_file)
    action = ActionQueryKnowledgeBase(knowledge_base)

    dispatcher = CollectingDispatcher()
    tracker = Tracker("default", slots, {}, [], False, None, {},
                      "action_listen")

    loop = asyncio.new_event_loop()
    actual_slots = loop.run_until_complete(action.run(dispatcher, tracker, {}))
    loop.close()

    compare_slots(expected_slots, actual_slots)
    compare_slots(actual_slots, expected_slots)
コード例 #13
0
 def __init__(self):
     # load knowledge base with data from the given file
     knowledge_base = InMemoryKnowledgeBase("./data/data_chat.json")
     super().__init__(knowledge_base)
コード例 #14
0
 def __init__(self):
     knowledge_base = InMemoryKnowledgeBase("maori_knowledge_base.json")
     super().__init__(knowledge_base)
コード例 #15
0
    def __init__(self):
        knowledge_base = InMemoryKnowledgeBase("data.json")
        super().__init__(knowledge_base)

        self.en_to_zh = EnToZh("en_to_zh.json")
コード例 #16
0
 def __init__(self):
     knowledge_base = InMemoryKnowledgeBase("data/pokemondb.json")
     super().__init__(knowledge_base)
コード例 #17
0
ファイル: actions.py プロジェクト: KaczmarekWill/airo_chatbot
	def __init__(self):
		knowledge_base = InMemoryKnowledgeBase("knowledge_base_data.json")
	
		super().__init__(knowledge_base)