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

Fix tests

parent bfa2351e
No related branches found
No related tags found
No related merge requests found
......@@ -216,9 +216,6 @@ class DiscriminativeExplainer:
typed_neg = set(map(OWLNamedIndividual, map(IRI.create, set(negative_examples))))
lp = PosNegLPStandard(pos=typed_pos, neg=typed_neg)
print("Positive Examples: ", len(positive_examples))
print("\nNegative Examples: ", len(negative_examples))
accepted_hypotheses = []
while True:
self.model.fit(lp)
......
......@@ -16,12 +16,10 @@
"text": [
{
"dataset_name": "dblp",
"grouped_keyword_dir": "rawData/dblp/groups",
"entity_name": "author"
},
{
"dataset_name": "imdb",
"grouped_keyword_dir": "rawData/imdb/groups",
"entity_name": "movie"
}
]
......
......@@ -4,41 +4,31 @@
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_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: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: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"/>
<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/author">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</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#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.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: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:Description rdf:about="http://example.org/author#2">
<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_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>
<ns1:writes rdf:resource="http://example.org/paper#2"/>
<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#4">
<rdf:type rdf:resource="http://example.org/paper"/>
......@@ -47,26 +37,36 @@
<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#4">
<rdf:type rdf:resource="http://example.org/author"/>
<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: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"/>
<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/paper_property_1">
<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/paper"/>
<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#1">
<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.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"/>
<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">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
<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.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_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/author#1">
<rdf:type rdf:resource="http://example.org/author"/>
......@@ -74,24 +74,24 @@
<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:Description rdf:about="http://example.org/author_property_2">
<rdf:Description rdf:about="http://example.org/paper_property_2">
<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#3">
<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.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: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>
<ns1:writes rdf:resource="http://example.org/paper#2"/>
</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">
<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"/>
<rdfs:domain rdf:resource="http://example.org/paper"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>
</rdf:Description>
</rdf:RDF>
......@@ -4,33 +4,22 @@
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_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: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: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"/>
<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#4"/>
</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/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/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"/>
......@@ -38,11 +27,10 @@
<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/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: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:Description rdf:about="http://example.org/paper#4">
<rdf:type rdf:resource="http://example.org/paper"/>
......@@ -51,18 +39,6 @@
<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/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: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#1">
<rdf:type rdf:resource="http://example.org/paper"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
......@@ -70,28 +46,52 @@
<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: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_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/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#4"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/paper">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
<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_property_2">
<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: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/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/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">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</rdf:Description>
</rdf:RDF>
......@@ -34,6 +34,17 @@ def instance_with_8_graphs():
return multiShape
@pytest.fixture
def get_motifs():
"""
Fixture to detect motifs in the dataset and provide the presence matrix.
"""
# Detect motifs in the dataset with debug mode enabled (predefined patterns)
multiShape = MultiShape()
super_classes, presence_matrix = multiShape.detect_motifs()
return super_classes, presence_matrix
def test_dataset_loading(instance_with_8_graphs):
"""
......@@ -42,14 +53,13 @@ def test_dataset_loading(instance_with_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():
def test_detect_motifs(get_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()
super_classes, presence_matrix = get_motifs
# Check that patterns were detected
assert len(super_classes) > 0, "No patterns detected in the dataset."
......@@ -62,7 +72,6 @@ def test_detect_motifs():
# 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):
"""
......@@ -109,7 +118,7 @@ def test_generate_owl_file_basic_bamultishape(instance_with_8_graphs):
assert False, "Generated graph does not match the expected graph."
def test_generate_owl_file_high_level_bamultishape(instance_with_8_graphs):
def test_generate_owl_file_high_level_bamultishape(instance_with_8_graphs, get_motifs):
"""
Test OWL file generation for the BAMultiShape dataset with 8 selected graphs.
"""
......@@ -123,7 +132,7 @@ def test_generate_owl_file_high_level_bamultishape(instance_with_8_graphs):
os.remove(owl_graph_path)
super_classes, presence_matrix = test_detect_motifs()
super_classes, presence_matrix = get_motifs
presence_matrix = presence_matrix[SPECIFIED_INDICES, :]
high_level_concepts = {"patterns": super_classes, "presence_matrix": presence_matrix}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment