From a2e2e85993a11a0e4cbf873396dbd897e35e790d Mon Sep 17 00:00:00 2001 From: danielhmills <5824561+danielhmills@users.noreply.github.com> Date: Mon, 27 Jul 2020 16:34:31 -0400 Subject: [PATCH 1/4] Added relevant prefixes to SPASQL queries --- .../kbpedia-stage-actor-inference-rules.sql | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100755 reasoning-and-inference/kbpedia-stage-actor-inference-rules.sql diff --git a/reasoning-and-inference/kbpedia-stage-actor-inference-rules.sql b/reasoning-and-inference/kbpedia-stage-actor-inference-rules.sql new file mode 100755 index 0000000..a9ac80e --- /dev/null +++ b/reasoning-and-inference/kbpedia-stage-actor-inference-rules.sql @@ -0,0 +1,112 @@ +SPARQL CLEAR GRAPH ; +SPARQL CLEAR GRAPH ; +SPARQL CLEAR GRAPH ; + +-- Built-in inference rules + +DELETE +FROM DB.DBA.SYS_RDF_SCHEMA +WHERE RS_NAME = 'urn:kbpedia:stage-actor:owl:equivalent:class:subproperty:inference:rules' ; + +SPARQL +DELETE { + GRAPH + { + # owl:equivalentClass . + owl:equivalentClass . + + } + } ; + +SPARQL +INSERT { + GRAPH + { + owl:equivalentClass . + # owl:equivalentClass . + rdfs:subPropertyOf rdf:type . + owl:equivalentProperty a owl:TransitiveProperty . + owl:equivalentClass a owl:TransitiveProperty. + rdfs:subPropertyOf a owl:TransitiveProperty . + rdfs:subClassOf a owl:TransitiveProperty . + } + } ; + +RDFS_RULE_SET ('urn:kbpedia:stage-actor:owl:equivalent:class:subproperty:inference:rules', 'https://github.com/Cognonto/kbpedia/raw/master/versions/2.50/kbpedia_reference_concepts.zip') ; + +SELECT * +FROM DB.DBA.SYS_RDF_SCHEMA +WHERE RS_NAME = 'urn:kbpedia:stage-actor:owl:equivalent:class:subproperty:inference:rules' ; + +-- Tests + +-- 1.1 Test using class kbpedia:Comedian + + +SPARQL +DEFINE input:inference 'urn:kbpedia:stage-actor:owl:equivalent:class:subproperty:inference:rules' + +PREFIX owl: +PREFIX rdfs: +PREFIX bmo: +PREFIX schema: +PREFIX foaf: +PREFIX kbpedia: + + +SELECT COUNT(*) +WHERE { + ?s a kbpedia:Comedian . + } ; + + +-- Test 1.2: without reasoning + +SPARQL +# DEFINE input:inference 'urn:kbpedia:stage-actor:owl:equivalent:class:subproperty:inference:rules' +PREFIX owl: +PREFIX rdfs: +PREFIX bmo: +PREFIX schema: +PREFIX foaf: +PREFIX kbpedia: + +SELECT COUNT(*) +WHERE { + ?s a kbpedia:Comedian . + } ; + +-- Tests + +-- 2.1 Test using class wdt:Q2259451 + +SPARQL +DEFINE input:inference 'urn:kbpedia:stage-actor:owl:equivalent:class:subproperty:inference:rules' + +PREFIX owl: +PREFIX rdfs: +PREFIX bmo: +PREFIX schema: +PREFIX foaf: +PREFIX kbpedia: + + +SELECT COUNT(*) +WHERE { + ?s a . + } ; + +-- Test 2.2: without reasoning +SPARQL +# DEFINE input:inference 'urn:kbpedia:stage-actor:owl:equivalent:class:subproperty:inference:rules' +PREFIX owl: +PREFIX rdfs: +PREFIX bmo: +PREFIX schema: +PREFIX foaf: +PREFIX kbpedia: + +SELECT COUNT(*) +WHERE { + ?s a . + } ; \ No newline at end of file From fb441f2a634256c472054288c7a73ce057b79321 Mon Sep 17 00:00:00 2001 From: danielhmills <5824561+danielhmills@users.noreply.github.com> Date: Mon, 27 Jul 2020 16:36:10 -0400 Subject: [PATCH 2/4] Added relevant prefixes to SPASQL queries --- .../kbpedia-comedian-inference-rules.sql | 256 ++++++++---------- 1 file changed, 112 insertions(+), 144 deletions(-) mode change 100644 => 100755 reasoning-and-inference/kbpedia-comedian-inference-rules.sql diff --git a/reasoning-and-inference/kbpedia-comedian-inference-rules.sql b/reasoning-and-inference/kbpedia-comedian-inference-rules.sql old mode 100644 new mode 100755 index f7ee522..72dfee8 --- a/reasoning-and-inference/kbpedia-comedian-inference-rules.sql +++ b/reasoning-and-inference/kbpedia-comedian-inference-rules.sql @@ -1,144 +1,112 @@ -SPARQL CLEAR GRAPH ; -SPARQL CLEAR GRAPH ; -SPARQL CLEAR GRAPH ; - --- Built-in inference rules - -DELETE -FROM DB.DBA.SYS_RDF_SCHEMA -WHERE RS_NAME = 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' ; - - -SPARQL - -PREFIX wdt: -PREFIX wd: -PREFIX kbpedia: - -INSERT { - GRAPH - { - kbpedia:Comedian owl:equivalentClass wdt:Q245068 . - wd:P106 rdfs:subPropertyOf rdf:type . - owl:equivalentProperty a owl:TransitiveProperty . - owl:equivalentClass a owl:TransitiveProperty. - rdfs:subPropertyOf a owl:TransitiveProperty . - rdfs:subClassOf a owl:TransitiveProperty . - } - } ; - -RDFS_RULE_SET ('urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules', 'https://github.com/Cognonto/kbpedia/raw/master/versions/2.50/kbpedia_reference_concepts.zip') ; - -SELECT * -FROM DB.DBA.SYS_RDF_SCHEMA -WHERE RS_NAME = 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' ; - --- Tests - --- 1.1 Test using class kbpedia:Comedian - - -SPARQL -DEFINE input:inference 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' - -PREFIX owl: -PREFIX rdfs: -PREFIX bmo: -PREFIX schema: -PREFIX foaf: -PREFIX kbpedia: - - -SELECT COUNT(*) -WHERE { - ?s a kbpedia:Comedian . - } ; - - --- Test 1.2: without reasoning - -SPARQL -# DEFINE input:inference 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' -PREFIX owl: -PREFIX rdfs: -PREFIX bmo: -PREFIX schema: -PREFIX foaf: -PREFIX kbpedia: - -SELECT COUNT(*) -WHERE { - ?s a kbpedia:Comedian . - } ; - --- Tests - --- 2.1 Test using class wdt:Q245068 - -SPARQL -DEFINE input:inference 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' - -PREFIX owl: -PREFIX rdfs: -PREFIX bmo: -PREFIX schema: -PREFIX foaf: -PREFIX kbpedia: -PREFIX wdt: - - -SELECT COUNT(*) -WHERE { - ?s a wdt:Q245068 . - } ; - --- Test 2.2: without reasoning -SPARQL -# DEFINE input:inference 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' -PREFIX owl: -PREFIX rdfs: -PREFIX bmo: -PREFIX schema: -PREFIX foaf: -PREFIX kbpedia: - -SELECT COUNT(*) -WHERE { - ?s a wdt:Q245068 . - } ; - --- 3.1 Test using class wdt:Q245068 - -SPARQL -DEFINE input:inference 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' - -PREFIX owl: -PREFIX rdfs: -PREFIX bmo: -PREFIX schema: -PREFIX foaf: -PREFIX kbpedia: -PREFIX wdt: - - -SELECT * -WHERE { - ?s a wdt:Q245068 . - } -LIMIT 100 ; - --- Test 3.2: without reasoning -SPARQL -# DEFINE input:inference 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' -PREFIX owl: -PREFIX rdfs: -PREFIX bmo: -PREFIX schema: -PREFIX foaf: -PREFIX kbpedia: - -SELECT * -WHERE { - ?s a wdt:Q245068 . - } -LIMIT 100 ; \ No newline at end of file +SPARQL CLEAR GRAPH ; +SPARQL CLEAR GRAPH ; +SPARQL CLEAR GRAPH ; + +-- Built-in inference rules + +DELETE +FROM DB.DBA.SYS_RDF_SCHEMA +WHERE RS_NAME = 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' ; + +SPARQL +DELETE { + GRAPH + { + # owl:equivalentClass . + owl:equivalentClass . + + } + } ; + +SPARQL +INSERT { + GRAPH + { + owl:equivalentClass . + # owl:equivalentClass . + rdfs:subPropertyOf rdf:type . + owl:equivalentProperty a owl:TransitiveProperty . + owl:equivalentClass a owl:TransitiveProperty. + rdfs:subPropertyOf a owl:TransitiveProperty . + rdfs:subClassOf a owl:TransitiveProperty . + } + } ; + +RDFS_RULE_SET ('urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules', 'https://github.com/Cognonto/kbpedia/raw/master/versions/2.50/kbpedia_reference_concepts.zip') ; + +SELECT * +FROM DB.DBA.SYS_RDF_SCHEMA +WHERE RS_NAME = 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' ; + +-- Tests + +-- 1.1 Test using class kbpedia:Comedian + + +SPARQL +DEFINE input:inference 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' + +PREFIX owl: +PREFIX rdfs: +PREFIX bmo: +PREFIX schema: +PREFIX foaf: +PREFIX kbpedia: + + +SELECT COUNT(*) +WHERE { + ?s a kbpedia:Comedian . + } ; + + +-- Test 1.2: without reasoning + +SPARQL +# DEFINE input:inference 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' +PREFIX owl: +PREFIX rdfs: +PREFIX bmo: +PREFIX schema: +PREFIX foaf: +PREFIX kbpedia: + +SELECT COUNT(*) +WHERE { + ?s a kbpedia:Comedian . + } ; + +-- Tests + +-- 2.1 Test using class wdt:Q245068 + +SPARQL +DEFINE input:inference 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' + +PREFIX owl: +PREFIX rdfs: +PREFIX bmo: +PREFIX schema: +PREFIX foaf: +PREFIX kbpedia: + + +SELECT COUNT(*) +WHERE { + ?s a . + } ; + +-- Test 2.2: without reasoning +SPARQL +# DEFINE input:inference 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' +PREFIX owl: +PREFIX rdfs: +PREFIX bmo: +PREFIX schema: +PREFIX foaf: +PREFIX kbpedia: + +SELECT COUNT(*) +WHERE { + ?s a . + } ; \ No newline at end of file From 032f02ae4d7ec04685a7c86a256a10881b5d6d16 Mon Sep 17 00:00:00 2001 From: danielhmills <5824561+danielhmills@users.noreply.github.com> Date: Tue, 28 Jul 2020 18:46:02 -0400 Subject: [PATCH 3/4] Added Wikidata and KBpedia prefixes + SPARQL-FED functionality --- ...in-reasoning-and-inference-kb-comedian.sql | 178 +++++++++++++++ ...reasoning-and-inference-kb-mime-artist.sql | 170 ++++++++++++++ ...reasoning-and-inference-kb-philosopher.sql | 214 ++++++++++++++++++ ...reasoning-and-inference-kb-stage-actor.sql | 183 +++++++++++++++ 4 files changed, 745 insertions(+) create mode 100755 reasoning-and-inference/built-in-reasoning-and-inference-kb-comedian.sql create mode 100755 reasoning-and-inference/built-in-reasoning-and-inference-kb-mime-artist.sql create mode 100755 reasoning-and-inference/built-in-reasoning-and-inference-kb-philosopher.sql create mode 100755 reasoning-and-inference/built-in-reasoning-and-inference-kb-stage-actor.sql diff --git a/reasoning-and-inference/built-in-reasoning-and-inference-kb-comedian.sql b/reasoning-and-inference/built-in-reasoning-and-inference-kb-comedian.sql new file mode 100755 index 0000000..8e5c24b --- /dev/null +++ b/reasoning-and-inference/built-in-reasoning-and-inference-kb-comedian.sql @@ -0,0 +1,178 @@ +SPARQL CLEAR GRAPH ; +SPARQL CLEAR GRAPH ; +SPARQL CLEAR GRAPH ; + +--KBpedia Tbox (Terminology Box) + +SPARQL +PREFIX wd: +PREFIX wdt: +PREFIX kbpedia: + +INSERT INTO GRAPH +{ + ?class a ?o +} + +WHERE + { + SERVICE + { + SELECT * + FROM + WHERE + { + ?class a ?o. + FILTER (?class = kbpedia:Comedian). + } + } + + }; + +-- Wikidata Tbox (Terminology Box) + +SPARQL +PREFIX wd: +PREFIX wdt: +PREFIX kbpedia: + +INSERT INTO GRAPH +{ + ?class a ?o +} + +WHERE + { + SERVICE + { + SELECT * + #FROM + WHERE + { + ?class a ?o. + FILTER (?class = wd:Q245068). + } + } + + }; + +-- Wikidata Abox (Assertions Box) + +SPARQL +PREFIX wd: +PREFIX wdt: +PREFIX kbpedia: + +INSERT INTO GRAPH +{ + ?entity ?p ?class +} + +WHERE + { + SERVICE + { + SELECT * + WHERE + { + ?entity ?p ?class. + FILTER (?p = wdt:P106 && ?class = wd:Q245068). + } + } + + }; + +SPARQL +CLEAR GRAPH ; +DELETE +FROM DB.DBA.SYS_RDF_SCHEMA +WHERE RS_NAME = 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' ; + +SPARQL +PREFIX wd: +PREFIX wdt: +PREFIX kbpedia: + +DELETE { + GRAPH + { + #kbpedia:Comedian owl:equivalentClass wd:Q245068 . + wd:Q245068 owl:equivalentClass kbpedia:Comedian . + + } + } ; + +SPARQL +PREFIX wd: +PREFIX wdt: +PREFIX owl: +PREFIX rdfs: +PREFIX kbpedia: + +INSERT { + GRAPH + { + kbpedia:Comedian owl:equivalentClass wd:Q245068 . + #wd:Q245068 owl:equivalentClass kbpedia:Comedian . + wdt:P106 rdfs:subPropertyOf rdf:type . + owl:equivalentProperty a owl:TransitiveProperty . + owl:equivalentClass a owl:TransitiveProperty. + rdfs:subPropertyOf a owl:TransitiveProperty . + rdfs:subClassOf a owl:TransitiveProperty . + } + } ; + +RDFS_RULE_SET ('urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules', 'https://github.com/Cognonto/kbpedia/raw/master/versions/2.50/kbpedia_reference_concepts.zip') ; + +SELECT * +FROM DB.DBA.SYS_RDF_SCHEMA +WHERE RS_NAME = 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' ; + +-- Tests + +-- 1.1 Test using class kbpedia:Comedian + + +SPARQL +DEFINE input:inference 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' +PREFIX kbpedia: + +SELECT COUNT(*) +WHERE { + ?s a kbpedia:Comedian . + } ; + + +-- Test 1.2: without reasoning + +SPARQL +# DEFINE input:inference 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' +PREFIX kbpedia: + +SELECT COUNT(*) +WHERE { + ?s a kbpedia:Comedian . + } ; + +-- Tests + +-- 2.1 Test using class wdt:Q245068 + +SPARQL +DEFINE input:inference 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' +PREFIX wd: + +SELECT COUNT(*) +WHERE { + ?s a wd:Q245068 . + } ; + +-- Test 2.2: without reasoning +SPARQL +# DEFINE input:inference 'urn:kbpedia:comedian:owl:equivalent:class:subproperty:inference:rules' +PREFIX wd: + +SELECT COUNT(*) +WHERE { + ?s a wd:Q245068 . + } ; \ No newline at end of file diff --git a/reasoning-and-inference/built-in-reasoning-and-inference-kb-mime-artist.sql b/reasoning-and-inference/built-in-reasoning-and-inference-kb-mime-artist.sql new file mode 100755 index 0000000..9880a6a --- /dev/null +++ b/reasoning-and-inference/built-in-reasoning-and-inference-kb-mime-artist.sql @@ -0,0 +1,170 @@ +SPARQL CLEAR GRAPH ; +SPARQL CLEAR GRAPH ; +SPARQL CLEAR GRAPH ; + +--KBpedia Tbox (Terminology Box) + +SPARQL + +PREFIX wdt: +PREFIX wd: +PREFIX kbpedia: + +INSERT INTO GRAPH +{ + ?class a ?o +} + +WHERE + { + SERVICE + { + SELECT * + #FROM + WHERE + { + ?class a ?o. + FILTER (?class = kbpedia:Mime-Actor). + } + } + + }; + +-- Wikidata Tbox (Terminology Box) + +SPARQL + +PREFIX wd: +PREFIX wdt: +PREFIX kbpedia: +INSERT INTO GRAPH +{ + ?class a ?o +} + +WHERE + { + SERVICE + { + SELECT * + #FROM + WHERE + { + ?class a ?o. + FILTER (?class = wd:Q674067). + } + } + + }; + +-- Wikidata Abox (Assertions Box) + +SPARQL +PREFIX wd: +PREFIX wdt: +PREFIX kbpedia: +INSERT INTO GRAPH +{ + ?entity ?p ?class +} + +WHERE + { + SERVICE + { + SELECT * + WHERE + { + ?entity ?p ?class. + FILTER (?p = wdt:P106 && ?class = wd:Q674067). + } + LIMIT 500 + } + + }; + +-- Built-in inference rules + +DELETE +FROM DB.DBA.SYS_RDF_SCHEMA +WHERE RS_NAME = 'urn:kbpedia:mime-artist:owl:equivalent:class:subproperty:inference:rules' ; + + +SPARQL +PREFIX wd: +PREFIX wdt: +PREFIX owl: +PREFIX rdfs: +PREFIX kbpedia: +INSERT { + GRAPH + { + kbpedia:Mime-Actor owl:equivalentClass wd:Q674067 . + wdt:P106 rdfs:subPropertyOf rdf:type . + owl:equivalentProperty a owl:TransitiveProperty . + owl:equivalentClass a owl:TransitiveProperty. + rdfs:subPropertyOf a owl:TransitiveProperty . + rdfs:subClassOf a owl:TransitiveProperty . + } + } ; + +RDFS_RULE_SET ('urn:kbpedia:mime-artist:owl:equivalent:class:subproperty:inference:rules', 'https://github.com/Cognonto/kbpedia/raw/master/versions/2.50/kbpedia_reference_concepts.zip') ; + +SELECT * +FROM DB.DBA.SYS_RDF_SCHEMA +WHERE RS_NAME = 'urn:kbpedia:mime-artist:owl:equivalent:class:subproperty:inference:rules' ; + +-- Tests + +-- 1.1 Test using class kbpedia:Mime-Actor + + +SPARQL +DEFINE input:inference 'urn:kbpedia:mime-artist:owl:equivalent:class:subproperty:inference:rules' + + +PREFIX kbpedia: + + +SELECT COUNT(*) +WHERE { + ?s a kbpedia:Mime-Actor . + } ; + + +-- Test 1.2: without reasoning + +SPARQL +# DEFINE input:inference 'urn:kbpedia:mime-artist:owl:equivalent:class:subproperty:inference:rules' + +PREFIX kbpedia: + +SELECT COUNT(*) +WHERE { + ?s a kbpedia:Mime-Actor . + } ; + +-- Tests + +-- 2.1 Test using class wdt:Q674067 + +SPARQL +DEFINE input:inference 'urn:kbpedia:mime-artist:owl:equivalent:class:subproperty:inference:rules' + +PREFIX wd: + +SELECT COUNT(*) +WHERE { + ?s a wd:Q674067 . + } ; + +-- Test 2.2: without reasoning +SPARQL +# DEFINE input:inference 'urn:kbpedia:mime-artist:owl:equivalent:class:subproperty:inference:rules' +PREFIX wd: + + +SELECT COUNT(*) +WHERE { + ?s a wd:Q674067 . + } ; \ No newline at end of file diff --git a/reasoning-and-inference/built-in-reasoning-and-inference-kb-philosopher.sql b/reasoning-and-inference/built-in-reasoning-and-inference-kb-philosopher.sql new file mode 100755 index 0000000..99662c0 --- /dev/null +++ b/reasoning-and-inference/built-in-reasoning-and-inference-kb-philosopher.sql @@ -0,0 +1,214 @@ +SPARQL CLEAR GRAPH ; +SPARQL CLEAR GRAPH ; +SPARQL CLEAR GRAPH ; + +--KBpedia Tbox (Terminology Box) + +SPARQL +PREFIX wd: +PREFIX wdt: +PREFIX owl: +PREFIX rdfs: +PREFIX kbpedia: + +INSERT INTO GRAPH +{ + ?class a ?o +} + +WHERE + { + SERVICE + { + SELECT * + FROM + WHERE + { + ?class a ?o. + FILTER (?class = kbpedia:Philosopher). + } + } + + }; + +-- Wikidata Tbox (Terminology Box) + +SPARQL +PREFIX wd: +PREFIX wdt: +PREFIX owl: +PREFIX rdfs: +PREFIX kbpedia: + +INSERT INTO GRAPH +{ + ?class a ?o +} + +WHERE + { + SERVICE + { + SELECT * + #FROM + WHERE + { + ?class a ?o. + FILTER (?class = wd:Q4964182). + } + } + + }; + +-- Wikidata Abox (Assertions Box) + +SPARQL +PREFIX wd: +PREFIX wdt: +PREFIX owl: +PREFIX rdfs: +PREFIX kbpedia: + +INSERT INTO GRAPH +{ + ?entity ?p ?class +} + +WHERE + { + SERVICE + { + SELECT * + WHERE + { + ?entity ?p ?class. + FILTER (?p = wdt:P106 && ?class = wd:Q4964182). + } + } + + }; + +SPARQL +CLEAR GRAPH ; +DELETE +FROM DB.DBA.SYS_RDF_SCHEMA +WHERE RS_NAME = 'urn:kbpedia:philosopher:owl:equivalent:class:subproperty:inference:rules' ; + +SPARQL +PREFIX wd: +PREFIX kbpedia: + +DELETE { + GRAPH + { + wd:Q4964182 owl:equivalentClass kbpedia:Philosopher . + + } + } ; + +SPARQL +PREFIX wd: +PREFIX wdt: +PREFIX owl: +PREFIX rdfs: +PREFIX kbpedia: + +INSERT { + GRAPH + { + kbpedia:Philosopher owl:equivalentClass wd:Q4964182 . + #wd:Q4964182 owl:equivalentClass kbpedia:Philosopher . + wdt:P106 rdfs:subPropertyOf rdf:type . + owl:equivalentProperty a owl:TransitiveProperty . + owl:equivalentClass a owl:TransitiveProperty. + rdfs:subPropertyOf a owl:TransitiveProperty . + rdfs:subClassOf a owl:TransitiveProperty . + } + } ; + +RDFS_RULE_SET ('urn:kbpedia:philosopher:owl:equivalent:class:subproperty:inference:rules', 'https://github.com/Cognonto/kbpedia/raw/master/versions/2.50/kbpedia_reference_concepts.zip') ; + +SELECT * +FROM DB.DBA.SYS_RDF_SCHEMA +WHERE RS_NAME = 'urn:kbpedia:philosopher:owl:equivalent:class:subproperty:inference:rules' ; + +-- Tests + +-- 1.1 Test using class kbpedia:Philosopher + + +SPARQL +DEFINE input:inference 'urn:kbpedia:philosopher:owl:equivalent:class:subproperty:inference:rules' + +PREFIX wd: +PREFIX wdt: +PREFIX owl: +PREFIX rdfs: +PREFIX bmo: +PREFIX schema: +PREFIX foaf: +PREFIX kbpedia: + + +SELECT COUNT(*) +WHERE { + ?s a kbpedia:Philosopher . + } ; + + +-- Test 1.2: without reasoning + +SPARQL +# DEFINE input:inference 'urn:kbpedia:philosopher:owl:equivalent:class:subproperty:inference:rules' +PREFIX wd: +PREFIX wdt: +PREFIX owl: +PREFIX rdfs: +PREFIX bmo: +PREFIX schema: +PREFIX foaf: +PREFIX kbpedia: + +SELECT COUNT(*) +WHERE { + ?s a kbpedia:Philosopher . + } ; + +-- Tests + +-- 2.1 Test using class wdt:Q4964182 + +SPARQL +DEFINE input:inference 'urn:kbpedia:philosopher:owl:equivalent:class:subproperty:inference:rules' + +PREFIX wd: +PREFIX wdt: +PREFIX owl: +PREFIX rdfs: +PREFIX bmo: +PREFIX schema: +PREFIX foaf: +PREFIX kbpedia: + + +SELECT COUNT(*) +WHERE { + ?s a wd:Q4964182 . + } ; + +-- Test 2.2: without reasoning +SPARQL +# DEFINE input:inference 'urn:kbpedia:philosopher:owl:equivalent:class:subproperty:inference:rules' +PREFIX wd: +PREFIX wdt: +PREFIX owl: +PREFIX rdfs: +PREFIX bmo: +PREFIX schema: +PREFIX foaf: +PREFIX kbpedia: + +SELECT COUNT(*) +WHERE { + ?s a wd:Q4964182 . + } ; \ No newline at end of file diff --git a/reasoning-and-inference/built-in-reasoning-and-inference-kb-stage-actor.sql b/reasoning-and-inference/built-in-reasoning-and-inference-kb-stage-actor.sql new file mode 100755 index 0000000..ad0e77f --- /dev/null +++ b/reasoning-and-inference/built-in-reasoning-and-inference-kb-stage-actor.sql @@ -0,0 +1,183 @@ +SPARQL CLEAR GRAPH ; +SPARQL CLEAR GRAPH ; +SPARQL CLEAR GRAPH ; + +--KBpedia Tbox (Terminology Box) + + +SPARQL + +PREFIX wdt: +PREFIX wd: +PREFIX kbpedia: + +INSERT INTO GRAPH +{ + ?class a ?o +} + +WHERE + { + SERVICE + { + SELECT * + #FROM + WHERE + { + ?class a ?o. + FILTER (?class = kbpedia:ActorInPlays). + } + } + + }; + +-- Wikidata Tbox (Terminology Box) + +SPARQL + +PREFIX wd: +PREFIX wdt: +PREFIX kbpedia: +INSERT INTO GRAPH +{ + ?class a ?o +} + +WHERE + { + SERVICE + { + SELECT * + #FROM + WHERE + { + ?class a ?o. + FILTER (?class = wd:Q2259451). + } + } + + }; + +-- Wikidata Abox (Assertions Box) + +SPARQL +PREFIX wd: +PREFIX wdt: +PREFIX kbpedia: +INSERT INTO GRAPH +{ + ?entity ?p ?class +} + +WHERE + { + SERVICE + { + SELECT * + WHERE + { + ?entity ?p ?class. + FILTER (?p = wdt:P106 && ?class = wd:Q2259451). + } + LIMIT 500 + } + + }; + +-- Built-in inference rules + +SPARQL +CLEAR GRAPH ; +DELETE +FROM DB.DBA.SYS_RDF_SCHEMA +WHERE RS_NAME = 'urn:kbpedia:stage-actor:owl:equivalent:class:subproperty:inference:rules' ; + +SPARQL +PREFIX wd: +PREFIX wdt: +PREFIX owl: +PREFIX rdfs: +PREFIX kbpedia: +DELETE { + GRAPH + { + #kbpedia:ActorInPlays owl:equivalentClass wd:Q2259451 . + wd:Q2259451 owl:equivalentClass kbpedia:ActorInPlays . + } + } ; + +SPARQL +PREFIX wd: +PREFIX wdt: +PREFIX owl: +PREFIX rdfs: +PREFIX kbpedia: +INSERT { + GRAPH + { + kbpedia:ActorInPlays owl:equivalentClass wd:Q2259451 . + wdt:P106 rdfs:subPropertyOf rdf:type . + owl:equivalentProperty a owl:TransitiveProperty . + owl:equivalentClass a owl:TransitiveProperty. + rdfs:subPropertyOf a owl:TransitiveProperty . + rdfs:subClassOf a owl:TransitiveProperty . + } + } ; + +RDFS_RULE_SET ('urn:kbpedia:stage-actor:owl:equivalent:class:subproperty:inference:rules', 'https://github.com/Cognonto/kbpedia/raw/master/versions/2.50/kbpedia_reference_concepts.zip') ; + +SELECT * +FROM DB.DBA.SYS_RDF_SCHEMA +WHERE RS_NAME = 'urn:kbpedia:stage-actor:owl:equivalent:class:subproperty:inference:rules' ; + +-- Tests + +-- 1.1 Test using class kbpedia:ActorInPlays + + +SPARQL +DEFINE input:inference 'urn:kbpedia:stage-actor:owl:equivalent:class:subproperty:inference:rules' +PREFIX kbpedia: + + +SELECT COUNT(*) +WHERE { + ?s a kbpedia:ActorInPlays . + } ; + + +-- Test 1.2: without reasoning + +SPARQL +# DEFINE input:inference 'urn:kbpedia:stage-actor:owl:equivalent:class:subproperty:inference:rules' +PREFIX kbpedia: + +SELECT COUNT(*) +WHERE { + ?s a kbpedia:ActorInPlays . + } ; + +-- Tests + +-- 2.1 Test using class wdt:Q2259451 + +SPARQL +DEFINE input:inference 'urn:kbpedia:stage-actor:owl:equivalent:class:subproperty:inference:rules' +PREFIX wd: + + + +SELECT COUNT(*) +WHERE { + ?s a wd:Q2259451 . + } ; + +-- Test 2.2: without reasoning +SPARQL +# DEFINE input:inference 'urn:kbpedia:stage-actor:owl:equivalent:class:subproperty:inference:rules' +PREFIX wd: + +SELECT COUNT(*) +WHERE { + ?s a wd:Q2259451 . + } ; \ No newline at end of file From a42c76e22f1c8e80193dab94eb9f016f1fbc263f Mon Sep 17 00:00:00 2001 From: danielhmills <5824561+danielhmills@users.noreply.github.com> Date: Wed, 29 Jul 2020 13:51:35 -0400 Subject: [PATCH 4/4] Added Wikidata and KBpedia prefixes + SPARQL-FED functionality --- .../built-in-reasoning-and-inference-kb-comedian.sql | 1 + .../built-in-reasoning-and-inference-kb-mime-artist.sql | 2 +- .../built-in-reasoning-and-inference-kb-philosopher.sql | 2 ++ .../built-in-reasoning-and-inference-kb-stage-actor.sql | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/reasoning-and-inference/built-in-reasoning-and-inference-kb-comedian.sql b/reasoning-and-inference/built-in-reasoning-and-inference-kb-comedian.sql index 8e5c24b..b134cf6 100755 --- a/reasoning-and-inference/built-in-reasoning-and-inference-kb-comedian.sql +++ b/reasoning-and-inference/built-in-reasoning-and-inference-kb-comedian.sql @@ -78,6 +78,7 @@ WHERE ?entity ?p ?class. FILTER (?p = wdt:P106 && ?class = wd:Q245068). } + LIMIT 100 } }; diff --git a/reasoning-and-inference/built-in-reasoning-and-inference-kb-mime-artist.sql b/reasoning-and-inference/built-in-reasoning-and-inference-kb-mime-artist.sql index 9880a6a..af6a50b 100755 --- a/reasoning-and-inference/built-in-reasoning-and-inference-kb-mime-artist.sql +++ b/reasoning-and-inference/built-in-reasoning-and-inference-kb-mime-artist.sql @@ -78,7 +78,7 @@ WHERE ?entity ?p ?class. FILTER (?p = wdt:P106 && ?class = wd:Q674067). } - LIMIT 500 + LIMIT 100 } }; diff --git a/reasoning-and-inference/built-in-reasoning-and-inference-kb-philosopher.sql b/reasoning-and-inference/built-in-reasoning-and-inference-kb-philosopher.sql index 99662c0..8c76240 100755 --- a/reasoning-and-inference/built-in-reasoning-and-inference-kb-philosopher.sql +++ b/reasoning-and-inference/built-in-reasoning-and-inference-kb-philosopher.sql @@ -9,6 +9,7 @@ PREFIX wd: PREFIX wdt: PREFIX owl: PREFIX rdfs: + PREFIX kbpedia: INSERT INTO GRAPH @@ -84,6 +85,7 @@ WHERE ?entity ?p ?class. FILTER (?p = wdt:P106 && ?class = wd:Q4964182). } + LIMIT 100 } }; diff --git a/reasoning-and-inference/built-in-reasoning-and-inference-kb-stage-actor.sql b/reasoning-and-inference/built-in-reasoning-and-inference-kb-stage-actor.sql index ad0e77f..843d51e 100755 --- a/reasoning-and-inference/built-in-reasoning-and-inference-kb-stage-actor.sql +++ b/reasoning-and-inference/built-in-reasoning-and-inference-kb-stage-actor.sql @@ -79,7 +79,7 @@ WHERE ?entity ?p ?class. FILTER (?p = wdt:P106 && ?class = wd:Q2259451). } - LIMIT 500 + LIMIT 100 } };