-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwireless-plans-product-features.sql
117 lines (88 loc) · 3.03 KB
/
wireless-plans-product-features.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
-- Additional commands
SPARQL CLEAR GRAPH <urn:spin:rule:features:lib1> ;
SPARQL DROP SPIN LIBRARY <urn:spin:rule:features:lib1> ;
-- Test Query
SPARQL
PREFIX oplfeat: <http://www.openlinksw.com/ontology/features#>
PREFIX schema: <http://schema.org/>
SELECT DISTINCT ?s2 schema:additionalProperty AS ?relation ?s3
WHERE {
?s schema:offers ?s1.
?s1 a schema:Offer .
?s1 schema:itemOffered ?s2 .
?s2 a schema:Product .
?s2 oplfeat:hasFeature | schema:additionalProperty ?s3 .
?s1 schema:priceSpecification ?s4 .
?s1 schema:image ?s6 .
?s4 schema:price ?s7.
?s4 schema:priceCurrency ?s8.
?s1 schema:name ?s5 .
?s3 schema:name ?s9.
?s2 schema:name ?s10.
OPTIONAL {?s rdfs:label ?s11 . FILTER (LANG(?s11) = "en") } .
} ;
-- create the rule
-- SPARQL CREATE GRAPH <urn:spin:rule:features:lib1> ;
SPARQL
PREFIX oplfeat: <http://www.openlinksw.com/ontology/features#>
PREFIX spin: <http://spinrdf.org/spin#>
PREFIX sp: <http://spinrdf.org/sp#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX schema: <http://schema.org/>
PREFIX : <#>
WITH <urn:spin:rule:features:lib1>
INSERT {
schema:Product a owl:Class ;
rdfs:label "Mobile plan feature";
spin:rule [
a sp:Construct;
sp:text """
PREFIX oplfeat: <http://www.openlinksw.com/ontology/features#>
PREFIX schema: <http://schema.org/>
CONSTRUCT {
?this schema:additionalProperty ?feature .
}
WHERE {
?this (oplfeat:hasFeature | schema:additionalProperty) ?feature .
}
"""
] .
} ;
EXEC ('SPARQL ' || SPARQL_SPIN_GRAPH_TO_DEFSPIN('urn:spin:rule:features:lib1'));
-- run a sparql query to test the spin rule
-- Test 0
-- To prove customer inference rule via select
SPARQL
PREFIX oplfeat: <http://www.openlinksw.com/ontology/features#>
PREFIX schema: <http://schema.org/>
SELECT DISTINCT
?s schema:additionalProperty ?feature
WHERE {
?s a schema:Product ;
(oplfeat:hasFeature | schema:additionalProperty) ?feature .
}
LIMIT 5 ;
-- Test 1 (Reasoning & Inference Context Enabled)
SPARQL
DEFINE input:macro-lib <urn:spin:rule:features:lib1>
PREFIX schema: <http://schema.org/>
PREFIX oplfeat: <http://www.openlinksw.com/ontology/features#>
SELECT DISTINCT ?s schema:additionalProperty AS ?relation ?feature
WHERE
{
?s a schema:Product;
schema:additionalProperty ?feature .
}
LIMIT 5 ;
-- Test 2 (Reasoning & Inference Context Disabled)
SPARQL
# DEFINE input:macro-lib <urn:spin:rule:features:lib1>
PREFIX schema: <http://schema.org/>
PREFIX oplfeat: <http://www.openlinksw.com/ontology/features#>
SELECT DISTINCT ?s schema:additionalProperty AS ?relation ?feature
WHERE
{
?s a schema:Product;
schema:additionalProperty ?feature .
}
LIMIT 5 ;