async def test_query_entities(data_file, object_type, attributes, expected_length): knowledge_base = InMemoryKnowledgeBase(data_file) entities = await knowledge_base.get_objects(object_type=object_type, attributes=attributes) assert expected_length == len(entities)
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)
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)
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)
async def test_query_object(data_file, object_type, object_identifier, expected_value): knowledge_base = InMemoryKnowledgeBase(data_file) actual_value = await knowledge_base.get_object( object_type=object_type, object_identifier=object_identifier) assert expected_value == actual_value
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)
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)
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)
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
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)
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)
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)
def __init__(self): # load knowledge base with data from the given file knowledge_base = InMemoryKnowledgeBase("./data/data_chat.json") super().__init__(knowledge_base)
def __init__(self): knowledge_base = InMemoryKnowledgeBase("maori_knowledge_base.json") super().__init__(knowledge_base)
def __init__(self): knowledge_base = InMemoryKnowledgeBase("data.json") super().__init__(knowledge_base) self.en_to_zh = EnToZh("en_to_zh.json")
def __init__(self): knowledge_base = InMemoryKnowledgeBase("data/pokemondb.json") super().__init__(knowledge_base)
def __init__(self): knowledge_base = InMemoryKnowledgeBase("knowledge_base_data.json") super().__init__(knowledge_base)