-- Cleanup SPARQL CLEAR GRAPH ; SPARQL DROP SPIN LIBRARY ; -- Load Rules from data source -- SPARQL -- DEFINE get:soft "no-sponge" -- LOAD INTO ; -- Remove rdf:type relations that have ldp:Resource, rdf:Resource as objects -- SPARQL DELETE WHERE { GRAPH { ?p ?o }}; -- SPARQL DELETE WHERE { GRAPH { ?p ?o } }; TTLP (' @prefix owl: . @prefix sp: . @prefix spl: . @prefix spin: . @prefix rdf: . @prefix rdfs: . @prefix xsd: . @prefix foaf: . @prefix rel: . @prefix wdrs: . @prefix schema: . @prefix ecrm: . foaf:Person a rdfs:Class ; rdfs:label "People"^^xsd:string ; spin:rule [ a sp:Construct, spin:Rule ; rdfs:label "Identity Reconciliation using owl:InverseFunctionalProperty Semantics" ; rdfs:comment """Generates explicit coreferences from IFP designaton of foaf:mbox relationship type (relation)""" ; sp:text """ CONSTRUCT {?this owl:sameAs ?that} WHERE { ?this foaf:mbox ?mbox1 . ?that foaf:mbox ?mbox2 . FILTER (?mbox1 = ?mbox2) FILTER (?this != ?that) FILTER (! isblank(?that)) FILTER (! isblank(?this)) # FILTER (?this = ) } """ ] . ', '', 'urn:spin:rule:foaf:ifp:lib1', 4096 ) ; -- Rules Load Verification SPARQL SELECT COUNT (*) FROM WHERE {?s ?p ?o} ; -- Generate Macros EXEC ('SPARQL ' || SPARQL_SPIN_GRAPH_TO_DEFSPIN('urn:spin:rule:foaf:ifp:lib1')); -- Control Tests --- -- Cleanup Named Graph to be used for Control Test SPARQL CLEAR GRAPH ; -- Copy Data to Control Test Named Graph SPARQL COPY TO ; -- Control Check 1 (totals need to match across source and target named graphs) SPARQL SELECT count (*) FROM WHERE {?s ?p ?o} ; SPARQL SELECT count (*) FROM WHERE {?s ?p ?o} ; -- Remove owl:sameAs relations SPARQL DELETE { GRAPH {?s owl:sameAs ?o} } WHERE { GRAPH {?s owl:sameAs ?o} } ; -- Control Check 2 (total must differ due to effect of owl:sameAs relation deletions ) SPARQL SELECT count (*) FROM WHERE {?s ?p ?o} ; SPARQL SELECT count (*) FROM WHERE {?s ?p ?o} ; -- Test Query 1 -- Successful if materialization of missing owl:sameAs relations occurs, courtesy of Custom IFP Inference Rule Pragma SPARQL DEFINE input:macro-lib # DEFINE input:inference ‘urn:ifp:inference:rule’ # DEFINE input:same-as "yes" SELECT DISTINCT ?s owl:sameAs as ?sameAs ?o # FROM FROM WHERE { ?s a foaf:Person ; owl:sameAs ?o . FILTER (?s = ) } ; -- Test Query 2 -- Successful if materialization of missing owl:sameAs relations occurs, courtesy of Custom IFP Inference Rule Pragma -- Current Status: Fail SPARQL DEFINE input:macro-lib # DEFINE input:same-as "yes" DESCRIBE ?s # FROM FROM WHERE { ?s a foaf:Person ; owl:sameAs ?o . FILTER (?s = ) } ; -- Test Query 3 -- Successful if materialization of missing owl:sameAs relations occurs, courtesy of Custom IFP Inference Rule Pragma -- plus materialization of other relations based on "samesAs" -- Current Status: Fail -- Proof: Uncomment FROM -- and then comment out FROM , and then comment out "DEFINE input:macro-lib " -- the solutions are different. The second solution correctly includes materialized relations from "owl:sameAs" inference pragma SPARQL DEFINE input:macro-lib DEFINE input:same-as "yes" DESCRIBE ?s # FROM FROM WHERE { ?s a foaf:Person ; owl:sameAs ?o . FILTER (?s = ) } ; -- Test Query 4 SPARQL DEFINE input:macro-lib # DEFINE input:same-as "yes" SELECT DISTINCT ?s ?sameAs ?mainEntityOfPage # FROM FROM WHERE { ?s a foaf:Person ; owl:sameAs ?sameAs ; schema:mainEntityOfPage ?mainEntityOfPage . FILTER (?s = ) } ; -- Test Query 5 -- Successful if materialization of missing owl:sameAs relations occurs, courtesy of Custom IFP Inference Rule Pragma -- plus materialization of other relations based on "samesAs" -- Current Status: Fail -- Proof: Uncomment FROM -- and then comment out FROM , and then comment out "DEFINE input:macro-lib " -- the solutions are different. The second solution correctly includes materialized relations from "owl:sameAs" inference pragma SPARQL DEFINE input:macro-lib DEFINE input:same-as "yes" SELECT DISTINCT ?s ?sameAs ?mainEntityOfPage # FROM FROM WHERE { ?s a foaf:Person ; owl:sameAs ?sameAs ; schema:mainEntityOfPage ?mainEntityOfPage . FILTER (?s = ) } ;