-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystemreasoning.sparqlbook
110 lines (110 loc) · 10.8 KB
/
systemreasoning.sparqlbook
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
[
{
"kind": 1,
"language": "markdown",
"value": "# System Reasoning",
"metadata": {}
},
{
"kind": 1,
"language": "markdown",
"value": "This query gets all the mission:Component",
"metadata": {}
},
{
"kind": 2,
"language": "sparql",
"value": "PREFIX base: <http://imce.jpl.nasa.gov/foundation/base#>\nPREFIX mission: <http://imce.jpl.nasa.gov/foundation/mission#>\nPREFIX structure: <http://opencaesar.io/open-source-rover/vocabulary/structure#>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\nSELECT DISTINCT ?c1_localname ?c2_localname\nWHERE {\n\t?c1 a mission:Component ;\n OPTIONAL{\n ?c1 base:isContainedIn ?c2 .\n }\n\t# Extract the local name\n BIND(STRAFTER(STR(?c1), \"#\") AS ?c1_localname) .\n BIND(STRAFTER(STR(?c2), \"#\") AS ?c2_localname) .\n\n}\nORDER BY ?c1_localname ",
"metadata": {}
},
{
"kind": 2,
"language": "sparql",
"value": "PREFIX base: <http://imce.jpl.nasa.gov/foundation/base#>\nPREFIX mission: <http://imce.jpl.nasa.gov/foundation/mission#>\nPREFIX structure: <http://opencaesar.io/open-source-rover/vocabulary/structure#>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\nSELECT DISTINCT ?c1_localname ?c2_localname ?c2_id ?c2_cname\nWHERE {\n\t?c1 a structure:System ;\n OPTIONAL{\n ?c1 structure:hasSubsystem ?c2 .\n OPTIONAL{\n ?c2 base:hasIdentifier ?c2_id .\n ?c2 base:hasCanonicalName ?c2_cname .\n }\n }\n\t# Extract the local name\n BIND(STRAFTER(STR(?c1), \"#\") AS ?c1_localname) .\n BIND(STRAFTER(STR(?c2), \"#\") AS ?c2_localname) .\n\n} \nORDER BY ?c1_localname ",
"metadata": {}
},
{
"kind": 1,
"language": "markdown",
"value": "# Scenario Query",
"metadata": {}
},
{
"kind": 2,
"language": "sparql",
"value": "PREFIX base: <http://imce.jpl.nasa.gov/foundation/base#>\nPREFIX mission: <http://imce.jpl.nasa.gov/foundation/mission#>\nPREFIX structure: <http://opencaesar.io/open-source-rover/vocabulary/structure#>\nPREFIX scenario: <http://opencaesar.io/open-source-rover/vocabulary/scenario#>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\nSELECT DISTINCT ?scenario ?task ?f2_id ?f2_cname ?f3_id\nWHERE {\n\t?f1 a scenario:Scenario ;\n OPTIONAL{\n ?f1 scenario:hasTask ?f2 .\n OPTIONAL{\n ?f2 base:hasIdentifier ?f2_id .\n ?f2 base:hasCanonicalName ?f2_cname .\n#\t\t\tOPTIONAL{\n#\t\t\t\t?f2_invoke base:hasIdentifier ?f2_invoke_id. \n#\t\t\t} \n }\n OPTIONAL{\n ?f2 mission:invokes ?f3 .\n ?f3 base:hasIdentifier ?f3_id .\n }\n }\n\t# Extract the local name\n BIND(STRAFTER(STR(?f1), \"#\") AS ?scenario) .\n BIND(STRAFTER(STR(?f2), \"#\") AS ?task) .\n\tFILTER(REGEX(STR(?f1), \"http://opencaesar.io/open-source-rover/description/behavior/scenario_move#\")).\n} \nORDER BY ?f2_id ",
"metadata": {}
},
{
"kind": 2,
"language": "sparql",
"value": "PREFIX base: <http://imce.jpl.nasa.gov/foundation/base#>\nPREFIX mission: <http://imce.jpl.nasa.gov/foundation/mission#>\nPREFIX structure: <http://opencaesar.io/open-source-rover/vocabulary/structure#>\nPREFIX scenario: <http://opencaesar.io/open-source-rover/vocabulary/scenario#>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\nPREFIX oml: <http://opencaesar.io/oml#>\n\n\n\nSELECT DISTINCT ?scenario ?t ?task ?f2_id ?f2_cname ?statevariable ?value ?f3_id \nWHERE {\n\t?f1 a scenario:Scenario ;\n OPTIONAL{\n ?f1 scenario:hasTask ?f2 .\n OPTIONAL{\n ?f2 base:hasIdentifier ?f2_id .\n ?f2 base:hasCanonicalName ?f2_cname .\n ?f2 scenario:hasPlannedStartTime ?t .\n }\n OPTIONAL{\n ?f2 mission:invokes ?f3 .\n ?f3 base:hasIdentifier ?f3_id .\n }\n OPTIONAL{\n ?f2 scenario:manipulates ?sv .\n OPTIONAL{\n ?m oml:hasSource ?f2 .\n ?m scenario:setStateValue ?value .\n }\n }\n }\n\t# Extract the local name\n BIND(STRAFTER(STR(?f1), \"#\") AS ?scenario) .\n BIND(STRAFTER(STR(?f2), \"#\") AS ?task) .\n BIND(STRAFTER(STR(?sv), \"#\") AS ?statevariable) .\n\tFILTER(REGEX(STR(?f1), \"http://opencaesar.io/open-source-rover/description/behavior/scenario_move#\")).\n} \nORDER BY ?f2_id ",
"metadata": {}
},
{
"kind": 1,
"language": "markdown",
"value": "# Start query from relation instance",
"metadata": {}
},
{
"kind": 2,
"language": "sparql",
"value": "PREFIX base: <http://imce.jpl.nasa.gov/foundation/base#>\nPREFIX mission: <http://imce.jpl.nasa.gov/foundation/mission#>\nPREFIX structure: <http://opencaesar.io/open-source-rover/vocabulary/structure#>\nPREFIX scenario: <http://opencaesar.io/open-source-rover/vocabulary/scenario#>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\nPREFIX oml: <http://opencaesar.io/oml#>\n\nSELECT DISTINCT ?manipulate ?task ?time ?statevariable ?value\nWHERE {\n\t?m a scenario:Manipulates;\n\t\toml:hasSource ?t ;\n\t\toml:hasTarget ?s ;\n\t\tscenario:setStateValue ?value ;\n\t\tOPTIONAL{\n\t\t\t?t scenario:hasPlannedStartTime ?time .\n\t\t}\n\n\t# Extract the local name\n BIND(STRAFTER(STR(?m), \"#\") AS ?manipulate) .\n BIND(STRAFTER(STR(?t), \"#\") AS ?task) .\n BIND(STRAFTER(STR(?s), \"#\") AS ?statevariable) .\n} \nORDER BY ?m",
"metadata": {}
},
{
"kind": 1,
"language": "markdown",
"value": "# Start Query from Task",
"metadata": {}
},
{
"kind": 2,
"language": "sparql",
"value": "PREFIX base: <http://imce.jpl.nasa.gov/foundation/base#>\nPREFIX mission: <http://imce.jpl.nasa.gov/foundation/mission#>\nPREFIX structure: <http://opencaesar.io/open-source-rover/vocabulary/structure#>\nPREFIX scenario: <http://opencaesar.io/open-source-rover/vocabulary/scenario#>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\nPREFIX oml: <http://opencaesar.io/oml#>\n\nSELECT DISTINCT ?task ?id ?time ?statevariable ?manipulate ?value \nWHERE {\n\t?t a scenario:Task ;\n\t\tbase:hasIdentifier ?id ;\n\t\tscenario:hasPlannedStartTime ?time ;\n\t\tscenario:manipulates ?s .\n\n OPTIONAL{\n ?m oml:hasSource ?t .\n ?m scenario:setStateValue ?value .\n }\n \t# Extract the local name\n BIND(STRAFTER(STR(?m), \"#\") AS ?manipulate) .\n BIND(STRAFTER(STR(?t), \"#\") AS ?task) .\n BIND(STRAFTER(STR(?s), \"#\") AS ?statevariable) .\n} \nORDER BY ?id ",
"metadata": {}
},
{
"kind": 1,
"language": "markdown",
"value": "上のコードの場合、ダブってしまう。あるタスクが、2つのSVを操作する場合に、クエリー結果がダブってしまう。",
"metadata": {}
},
{
"kind": 1,
"language": "markdown",
"value": "下記はテスト用。だがうまくいかなかった",
"metadata": {}
},
{
"kind": 2,
"language": "sparql",
"value": "PREFIX base: <http://imce.jpl.nasa.gov/foundation/base#>\nPREFIX mission: <http://imce.jpl.nasa.gov/foundation/mission#>\nPREFIX structure: <http://opencaesar.io/open-source-rover/vocabulary/structure#>\nPREFIX scenario: <http://opencaesar.io/open-source-rover/vocabulary/scenario#>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\nPREFIX oml: <http://opencaesar.io/oml#>\n\nSELECT DISTINCT ?task ?id ?time ?statevariable ?manipulate ?value \nWHERE {\n\t?t scenario:manipulates ?s .\n OPTIONAL{\n ?t base:hasIdentifier ?id .\n ?t scenario:hasPlannedStartTime ?time .\n }\n \n # ?m oml:hasSource ?t .\n\n OPTIONAL{\n # ?m oml:hasSource ?t .\n }\n \n\n# OPTIONAL{\n# ?m oml:hasSource ?t .\n# ?m scenario:setStateValue ?value .\n# }\n \t# Extract the local name\n BIND(STRAFTER(STR(?m), \"#\") AS ?manipulate) .\n BIND(STRAFTER(STR(?t), \"#\") AS ?task) .\n BIND(STRAFTER(STR(?s), \"#\") AS ?statevariable) .\n} \nORDER BY ?id ",
"metadata": {}
},
{
"kind": 1,
"language": "markdown",
"value": "# for R timeline visualization",
"metadata": {}
},
{
"kind": 2,
"language": "sparql",
"value": "PREFIX base: <http://imce.jpl.nasa.gov/foundation/base#>\nPREFIX mission: <http://imce.jpl.nasa.gov/foundation/mission#>\nPREFIX structure: <http://opencaesar.io/open-source-rover/vocabulary/structure#>\nPREFIX scenario: <http://opencaesar.io/open-source-rover/vocabulary/scenario#>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\nPREFIX oml: <http://opencaesar.io/oml#>\n\nSELECT DISTINCT ?manipulate ?f2_id ?f2_cname ?task ?time ?statevariable ?value ?f3_id\nWHERE {\n\t?m a scenario:Manipulates;\n\t\toml:hasSource ?t ;\n\t\toml:hasTarget ?s ;\n\t\tscenario:setStateValue ?value ;\n\t\tOPTIONAL{\n\t\t\t?t scenario:hasPlannedStartTime ?time .\n\t\t\t?t base:hasIdentifier ?f2_id .\n\t\t\t?t base:hasCanonicalName ?f2_cname .\n\t OPTIONAL{\n ?t mission:invokes ?f3 .\n ?f3 base:hasIdentifier ?f3_id .\n }\n\t\t\n\t\t}\n\n\t# Extract the local name\n BIND(STRAFTER(STR(?m), \"#\") AS ?manipulate) .\n BIND(STRAFTER(STR(?t), \"#\") AS ?task) .\n BIND(STRAFTER(STR(?s), \"#\") AS ?statevariable) .\n} \nORDER BY ?m",
"metadata": {}
},
{
"kind": 1,
"language": "markdown",
"value": "component-filtered",
"metadata": {}
},
{
"kind": 2,
"language": "sparql",
"value": "PREFIX base: <http://imce.jpl.nasa.gov/foundation/base#>\nPREFIX mission: <http://imce.jpl.nasa.gov/foundation/mission#>\nPREFIX structure: <http://opencaesar.io/open-source-rover/vocabulary/structure#>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\nSELECT DISTINCT ?c1_localname ?c1_id ?c1_name ?c1_type ?c2_localname ?c2_id ?c2_name\nWHERE {\n VALUES ?componentType { structure:System structure:Subsystem structure:Assembly}\n\n\t?c1 a ?componentType ;\n\t\tbase:hasIdentifier ?c1_id ;\n\t\tbase:hasCanonicalName ?c1_name ;\n\n OPTIONAL{\n ?c1 base:isContainedIn ?c2 ;\n OPTIONAL{\n ?c2 base:hasIdentifier ?c2_id ;\n base:hasCanonicalName ?c2_name .\n }\n }\n\t# Extract the local name\n BIND(STRAFTER(STR(?c1), \"#\") AS ?c1_localname) .\n BIND(STRAFTER(STR(?c2), \"#\") AS ?c2_localname) .\n\n\tOPTIONAL {\n\t\t?c1 a structure:System ;\n\t\t\tBIND(\"System\" AS ?c1_type) .\n\t}\n\tOPTIONAL {\n\t\t?c1 a structure:Subsystem ;\n\t\t\tBIND(\"Subsystem\" AS ?c1_type) .\n\t}\n\tOPTIONAL {\n\t\t?c1 a structure:Assembly ;\n\t\t\tBIND(\"Assembly\" AS ?c1_type) .\n\t}\n\n# FILTER (REGEX(?c1_type, \"^Subsystem\") + REGEX(?c1_type, \"^System\"))\n}\nORDER BY ?c2_id",
"metadata": {}
}
]