-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathquora-faq-built-in-inference.sql
82 lines (62 loc) · 1.97 KB
/
quora-faq-built-in-inference.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
-- Cleanup
SPARQL CLEAR GRAPH <urn:inference:oplfaq> ;
SPARQL CLEAR GRAPH <https://github.com/OpenLinkSoftware/Turtle-Based-FAQ-Documents/raw/master/quora-faqs.ttl> ;
DELETE
FROM DB.DBA.SYS_RDF_SCHEMA
WHERE RS_NAME = 'urn:inference:oplfaq:rule' ;
-- Load FAQ .TTL
SPARQL LOAD <https://github.com/OpenLinkSoftware/Turtle-Based-FAQ-Documents/raw/master/quora-faqs.ttl> ;
-- Load Rules
SPARQL
PREFIX oplfaq: <http://www.openlinksw.com/ontology/faq#>
PREFIX schema: <http://schema.org/>
INSERT INTO GRAPH <urn:inference:oplfaq>
{
oplfaq:Agent rdfs:subClassOf schema:Agent .
oplfaq:Question rdfs:subClassOf schema:Question .
oplfaq:answer rdfs:subPropertyOf schema:acceptedAnswer .
oplfaq:hasQuestionText rdfs:subPropertyOf schema:text .
oplfaq:hasAnswerText rdfs:subPropertyOf schema:text .
} ;
-- Confirm addition of rules
SPARQL
PREFIX oplfaq: <http://www.openlinksw.com/ontology/faq#>
PREFIX schema: <http://schema.org/>
SELECT *
FROM <urn:inference:oplfaq>
WHERE
{
?s ?p ?o .
};
-- Create built-in inference rule
rdfs_rule_set
(
'urn:inference:oplfaq:rule' ,
'urn:inference:oplfaq'
) ;
SELECT *
FROM DB.DBA.SYS_RDF_SCHEMA
WHERE RS_NAME = 'urn:inference:oplfaq:rule' ;
-- Test without built-in inference rule
SPARQL
PREFIX schema: <http://schema.org/>
PREFIX oplfaq: <http://www.openlinksw.com/ontology/faq#>
SELECT *
FROM <https://github.com/OpenLinkSoftware/Turtle-Based-FAQ-Documents/raw/master/quora-faqs.ttl>
WHERE
{
?s a schema:Question ;
schema:acceptedAnswer ?answer .
} ;
-- Test with built-in inference rule
SPARQL
DEFINE input:inference 'urn:inference:oplfaq:rule'
PREFIX schema: <http://schema.org/>
PREFIX oplfaq: <http://www.openlinksw.com/ontology/faq#>
SELECT *
FROM <https://github.com/OpenLinkSoftware/Turtle-Based-FAQ-Documents/raw/master/quora-faqs.ttl>
WHERE
{
?s a schema:Question ;
schema:acceptedAnswer ?answer .
} ;