Skip to content
Snippets Groups Projects
Commit bfa2351e authored by AjUm-HEIDI's avatar AjUm-HEIDI
Browse files

Add tests

parent cc71af95
No related branches found
No related tags found
No related merge requests found
......@@ -4,37 +4,34 @@
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
>
<rdf:Description rdf:about="http://example.org/author#1">
<rdf:type rdf:resource="http://example.org/author"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:author_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</ns1:author_property_2>
<ns1:writes rdf:resource="http://example.org/paper#1"/>
<rdf:Description rdf:about="http://example.org/author_property_1">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
<rdfs:domain rdf:resource="http://example.org/author"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/writes">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
<rdfs:domain rdf:resource="http://example.org/author"/>
<rdfs:range rdf:resource="http://example.org/paper"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper#3">
<rdf:type rdf:resource="http://example.org/paper"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:paper_property_1 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.699999988079071</ns1:paper_property_1>
<ns1:paper_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.949999988079071</ns1:paper_property_2>
<ns1:written_by rdf:resource="http://example.org/author#3"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/written_by">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
<rdfs:domain rdf:resource="http://example.org/paper"/>
<rdfs:range rdf:resource="http://example.org/author"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper#1">
<rdf:Description rdf:about="http://example.org/paper#2">
<rdf:type rdf:resource="http://example.org/paper"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:paper_property_1 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.8999999761581421</ns1:paper_property_1>
<ns1:paper_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.800000011920929</ns1:paper_property_2>
<ns1:written_by rdf:resource="http://example.org/author#1"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/author#4">
<rdf:type rdf:resource="http://example.org/author"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:author_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.10000000149011612</ns1:author_property_2>
<ns1:writes rdf:resource="http://example.org/paper#4"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
<ns1:paper_property_1 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.10000000149011612</ns1:paper_property_1>
<ns1:paper_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.20000000298023224</ns1:paper_property_2>
<ns1:written_by rdf:resource="http://example.org/author#2"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/author#2">
<rdf:type rdf:resource="http://example.org/author"/>
......@@ -43,51 +40,54 @@
<ns1:author_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.30000001192092896</ns1:author_property_2>
<ns1:writes rdf:resource="http://example.org/paper#2"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper#2">
<rdf:Description rdf:about="http://example.org/paper#4">
<rdf:type rdf:resource="http://example.org/paper"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:paper_property_1 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.10000000149011612</ns1:paper_property_1>
<ns1:paper_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.20000000298023224</ns1:paper_property_2>
<ns1:written_by rdf:resource="http://example.org/author#2"/>
<ns1:paper_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.30000001192092896</ns1:paper_property_2>
<ns1:written_by rdf:resource="http://example.org/author#4"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/author_property_1">
<rdf:Description rdf:about="http://example.org/author#4">
<rdf:type rdf:resource="http://example.org/author"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:author_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.10000000149011612</ns1:author_property_2>
<ns1:writes rdf:resource="http://example.org/paper#4"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper_property_1">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
<rdfs:domain rdf:resource="http://example.org/author"/>
<rdfs:domain rdf:resource="http://example.org/paper"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper#4">
<rdf:Description rdf:about="http://example.org/paper#1">
<rdf:type rdf:resource="http://example.org/paper"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:paper_property_1 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.10000000149011612</ns1:paper_property_1>
<ns1:paper_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.30000001192092896</ns1:paper_property_2>
<ns1:written_by rdf:resource="http://example.org/author#4"/>
<ns1:paper_property_1 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.8999999761581421</ns1:paper_property_1>
<ns1:paper_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.800000011920929</ns1:paper_property_2>
<ns1:written_by rdf:resource="http://example.org/author#1"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/author">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper#3">
<rdf:type rdf:resource="http://example.org/paper"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:paper_property_1 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.699999988079071</ns1:paper_property_1>
<ns1:paper_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.949999988079071</ns1:paper_property_2>
<ns1:written_by rdf:resource="http://example.org/author#3"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/author#3">
<rdf:Description rdf:about="http://example.org/author#1">
<rdf:type rdf:resource="http://example.org/author"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:author_property_1 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.10000000149011612</ns1:author_property_1>
<ns1:author_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</ns1:author_property_2>
<ns1:writes rdf:resource="http://example.org/paper#3"/>
<ns1:writes rdf:resource="http://example.org/paper#1"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/author_property_2">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
<rdfs:domain rdf:resource="http://example.org/author"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper_property_1">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
<rdfs:domain rdf:resource="http://example.org/paper"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>
<rdf:Description rdf:about="http://example.org/author#3">
<rdf:type rdf:resource="http://example.org/author"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:author_property_1 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.10000000149011612</ns1:author_property_1>
<ns1:author_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</ns1:author_property_2>
<ns1:writes rdf:resource="http://example.org/paper#3"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper_property_2">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
......
......@@ -4,66 +4,80 @@
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
>
<rdf:Description rdf:about="http://example.org/author#1">
<rdf:type rdf:resource="http://example.org/author"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:author_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</ns1:author_property_2>
<ns1:writes rdf:resource="http://example.org/paper#1"/>
<ns1:writes rdf:resource="http://example.org/paper#2"/>
<rdf:Description rdf:about="http://example.org/author_property_1">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
<rdfs:domain rdf:resource="http://example.org/author"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/writes">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
<rdfs:domain rdf:resource="http://example.org/author"/>
<rdfs:range rdf:resource="http://example.org/paper"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper#3">
<rdf:type rdf:resource="http://example.org/paper"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:paper_property_1 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.699999988079071</ns1:paper_property_1>
<ns1:paper_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.949999988079071</ns1:paper_property_2>
<ns1:written_by rdf:resource="http://example.org/author#3"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/written_by">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
<rdfs:domain rdf:resource="http://example.org/paper"/>
<rdfs:range rdf:resource="http://example.org/author"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper#1">
<rdf:Description rdf:about="http://example.org/author#4">
<rdf:type rdf:resource="http://example.org/author"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:author_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</ns1:author_property_2>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper#2">
<rdf:type rdf:resource="http://example.org/paper"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:paper_property_1 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.8999999761581421</ns1:paper_property_1>
<ns1:paper_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.800000011920929</ns1:paper_property_2>
<ns1:paper_property_1 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.10000000149011612</ns1:paper_property_1>
<ns1:paper_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.20000000298023224</ns1:paper_property_2>
<ns1:written_by rdf:resource="http://example.org/author#1"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/author#2">
<rdf:type rdf:resource="http://example.org/author"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:author_property_1 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.6000000238418579</ns1:author_property_1>
<ns1:author_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.30000001192092896</ns1:author_property_2>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper#2">
<rdf:Description rdf:about="http://example.org/paper#4">
<rdf:type rdf:resource="http://example.org/paper"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:paper_property_1 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.10000000149011612</ns1:paper_property_1>
<ns1:paper_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.20000000298023224</ns1:paper_property_2>
<ns1:written_by rdf:resource="http://example.org/author#1"/>
<ns1:paper_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.30000001192092896</ns1:paper_property_2>
<ns1:written_by rdf:resource="http://example.org/author#3"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/author_property_1">
<rdf:Description rdf:about="http://example.org/paper_property_1">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
<rdfs:domain rdf:resource="http://example.org/author"/>
<rdfs:domain rdf:resource="http://example.org/paper"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/author#4">
<rdf:Description rdf:about="http://example.org/author#1">
<rdf:type rdf:resource="http://example.org/author"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:author_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</ns1:author_property_2>
<ns1:writes rdf:resource="http://example.org/paper#1"/>
<ns1:writes rdf:resource="http://example.org/paper#2"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper#4">
<rdf:Description rdf:about="http://example.org/paper#1">
<rdf:type rdf:resource="http://example.org/paper"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:paper_property_1 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.10000000149011612</ns1:paper_property_1>
<ns1:paper_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.30000001192092896</ns1:paper_property_2>
<ns1:written_by rdf:resource="http://example.org/author#3"/>
<ns1:paper_property_1 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.8999999761581421</ns1:paper_property_1>
<ns1:paper_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.800000011920929</ns1:paper_property_2>
<ns1:written_by rdf:resource="http://example.org/author#1"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/author">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/author_property_2">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
<rdfs:domain rdf:resource="http://example.org/author"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/author#3">
<rdf:type rdf:resource="http://example.org/author"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
......@@ -72,22 +86,8 @@
<ns1:writes rdf:resource="http://example.org/paper#3"/>
<ns1:writes rdf:resource="http://example.org/paper#4"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper#3">
<rdf:type rdf:resource="http://example.org/paper"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<ns1:paper_property_1 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.699999988079071</ns1:paper_property_1>
<ns1:paper_property_2 rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.949999988079071</ns1:paper_property_2>
<ns1:written_by rdf:resource="http://example.org/author#3"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/author_property_2">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
<rdfs:domain rdf:resource="http://example.org/author"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper_property_1">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
<rdfs:domain rdf:resource="http://example.org/paper"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>
<rdf:Description rdf:about="http://example.org/paper">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper_property_2">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
......
This diff is collapsed.
This diff is collapsed.
import os
from rdflib.compare import isomorphic
import pytest
import numpy as np
from rdflib import Graph
from torch_geometric.data import InMemoryDataset
from CustomDataset.Structured.MultiShape import MultiShape
from Utils.ConvertToOWL import convert_to_owl
SPECIFIED_INDICES = [1, 201, 13, 256, 700, 612, 809, 815]
class CustomGraphDataset(InMemoryDataset):
"""
Custom dataset to hold a list of PyTorch Geometric data objects.
"""
def __init__(self, data_list):
super().__init__()
self.data, self.slices = self.collate(data_list)
@pytest.fixture
def instance_with_8_graphs():
"""
Fixture to create a multiShape dataset instance with only the specified graphs.
"""
# Initialize the full dataset
multiShape = MultiShape()
# Extract graphs based on the specified indices
full_dataset = multiShape.get_dataset()
filtered_graphs = [full_dataset[idx] for idx in SPECIFIED_INDICES if idx < len(full_dataset)]
# Replace the dataset in the multiShape instance with a new InMemoryDataset containing only the specified graphs
multiShape.dataset = CustomGraphDataset(filtered_graphs)
return multiShape
def test_dataset_loading(instance_with_8_graphs):
"""
Test the successful loading and filtering of the multiShape dataset to 8 graphs.
"""
dataset = instance_with_8_graphs.get_dataset()
assert len(dataset) == 8, f"Expected 8 graphs, but found {len(dataset)}."
def test_detect_motifs():
"""
Test motif detection and the presence matrix using 8 graphs.
"""
# Detect motifs in the dataset with debug mode enabled (predefined patterns)
multiShape = MultiShape()
super_classes, presence_matrix = multiShape.detect_motifs()
# Check that patterns were detected
assert len(super_classes) > 0, "No patterns detected in the dataset."
# Verify the dimensions of the presence matrix
num_graphs = len(multiShape.dataset)
num_patterns = len(super_classes)
assert presence_matrix.shape == (num_graphs, num_patterns), \
f"Expected presence matrix shape {(num_graphs, num_patterns)}, but got {presence_matrix.shape}."
# Verify that presence matrix contains non-negative integers
assert np.all(presence_matrix >= 0), "Presence matrix contains negative values."
return super_classes, presence_matrix
def test_generate_owl_file_basic_bamultishape(instance_with_8_graphs):
"""
Test OWL file generation for the BAMultiShape dataset with 8 selected graphs.
"""
# Define paths
base_dir = os.path.dirname(os.path.abspath(__file__))
owl_graph_path = os.path.join(base_dir, "generatedGraphs/test_generated_bamultishape.owl")
comparison_graph_path = os.path.join(base_dir, "testGraphs/test_generated_bamultishape_basic_comparision.owl")
# Remove existing OWL file if present
if os.path.isfile(owl_graph_path):
os.remove(owl_graph_path)
# Convert dataset to OWL format
dataset = instance_with_8_graphs.get_dataset()
owlGraph = convert_to_owl(dataset, "http://example.org/", owl_graph_path, full_edge_name=False, create_data_properties_as_boolean=True, add_node_type=False)
owlGraph.buildGraph()
# Test whether OWL file is generated
assert os.path.isfile(owl_graph_path), "OWL file was not generated."
# Compare generated OWL graph with expected graph
graph1 = Graph()
graph2 = Graph()
graph1.parse(owl_graph_path)
graph2.parse(comparison_graph_path)
if not isomorphic(graph1, graph2):
print("Graphs are not isomorphic. Differences found:")
triples1 = set(graph1)
triples2 = set(graph2)
# Identify missing triples
for triple in triples2 - triples1:
print(f"Missing in generated: {triple}")
# Identify unexpected triples
for triple in triples1 - triples2:
print(f"Unexpected in generated: {triple}")
# Raise assertion if graphs do not match
assert False, "Generated graph does not match the expected graph."
def test_generate_owl_file_high_level_bamultishape(instance_with_8_graphs):
"""
Test OWL file generation for the BAMultiShape dataset with 8 selected graphs.
"""
# Define paths
base_dir = os.path.dirname(os.path.abspath(__file__))
owl_graph_path = os.path.join(base_dir, "generatedGraphs/test_generated_bamultishape_high_level.owl")
comparison_graph_path = os.path.join(base_dir, "testGraphs/test_generated_bamultishape_high_level_comparision.owl")
# Remove existing OWL file if present
if os.path.isfile(owl_graph_path):
os.remove(owl_graph_path)
super_classes, presence_matrix = test_detect_motifs()
presence_matrix = presence_matrix[SPECIFIED_INDICES, :]
high_level_concepts = {"patterns": super_classes, "presence_matrix": presence_matrix}
# Convert dataset to OWL format
dataset = instance_with_8_graphs.get_dataset()
owlGraph = convert_to_owl(dataset, "http://example.org/", owl_graph_path, full_edge_name=False, create_data_properties_as_boolean=True, high_level_concepts=high_level_concepts, add_node_type=False)
owlGraph.buildGraph()
# Test whether OWL file is generated
assert os.path.isfile(owl_graph_path), "OWL file was not generated."
# Compare generated OWL graph with expected graph
graph1 = Graph()
graph2 = Graph()
graph1.parse(owl_graph_path)
graph2.parse(comparison_graph_path)
if not isomorphic(graph1, graph2):
print("Graphs are not isomorphic. Differences found:")
triples1 = set(graph1)
triples2 = set(graph2)
# Identify missing triples
for triple in triples2 - triples1:
print(f"Missing in generated: {triple}")
# Identify unexpected triples
for triple in triples1 - triples2:
print(f"Unexpected in generated: {triple}")
# Raise assertion if graphs do not match
assert False, "Generated graph does not match the expected graph."
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment