def test_known_datasets(dataset_name): """Function to test the the knowledge graph parse for Freebase.""" knowledge_graph = KnowledgeGraph(dataset=dataset_name) knowledge_graph.force_prepare_data() assert len(knowledge_graph.dump()) == 9 assert knowledge_graph.is_cache_exists() kg_metadata = knowledge_graph.dataset.read_metadata() assert kg_metadata.tot_triple > 0 assert kg_metadata.tot_valid_triples > 0 assert kg_metadata.tot_test_triples > 0 assert kg_metadata.tot_train_triples > 0 assert kg_metadata.tot_relation > 0 assert kg_metadata.tot_entity > 0 assert len(knowledge_graph.read_cache_data('triplets_train')) > 0 assert len(knowledge_graph.read_cache_data('triplets_test')) > 0 assert len(knowledge_graph.read_cache_data('triplets_valid')) > 0 assert len(knowledge_graph.read_cache_data('hr_t')) > 0 assert len(knowledge_graph.read_cache_data('tr_h')) > 0 assert len(knowledge_graph.read_cache_data('idx2entity')) > 0 assert len(knowledge_graph.read_cache_data('idx2relation')) > 0 assert len(knowledge_graph.read_cache_data('entity2idx')) > 0 assert len(knowledge_graph.read_cache_data('relation2idx')) > 0
def test_fb15k_meta(): """Function to test the the knowledge graph parse for Freebase and basic operations.""" knowledge_graph = KnowledgeGraph(dataset="freebase15k") knowledge_graph.force_prepare_data() knowledge_graph.dump() assert knowledge_graph.is_cache_exists() knowledge_graph.prepare_data() knowledge_graph.dataset.read_metadata() knowledge_graph.dataset.dump()