This content has been marked as final.
Show 7 replies
-
1. Re: sparql query using variable paths
alwu-Oracle Aug 15, 2012 10:18 PM (in response to 366556)Hi,
Can you use something like this?
select *
where { ind:123 (:hasA|:hasB|:hasC|:hasD)+ ?x }
If you really don't know all those property names/URIs before hand, then
you can define a super property :hasRelation of all those :has* properties, run
inference, and execute the following query
select *
where { ind:123 (:hasRelation)+ ?x }
Here I assume you defined:
:hasA rdfs:subPropertyOf :hasRelation .
:hasB rdfs:subPropertyOf :hasRelation .
...
Hope it helps,
Zhe Wu -
2. Re: sparql query using variable paths
366556 Aug 15, 2012 11:17 PM (in response to alwu-Oracle)I've made hasRelation a superproperty of my other properties and used OWLPRIME inferencing with the following settings: SNOMED,INTERSECTSCOH,INTERSECT,CHAIN
However, running this query didn't return any results
select *
where { ind:123 (:hasRelation)+ ?x }
If I try the following query I'm only getting the immediate results links to ind:123 (i.e. ind:124, ind:127) but not indirect links
select *
where { ind:123 :hasRelation ?x }
Am I missing any other settings? -
3. Re: sparql query using variable paths
alwu-Oracle Aug 15, 2012 11:21 PM (in response to 366556)Please cut & paste your TBox (the sub property definitions) and the code snippet you used to run SPARQL queries against the asserted model as well as the inferred graph.
Thanks,
Zhe -
4. Re: sparql query using variable paths
366556 Aug 15, 2012 11:54 PM (in response to alwu-Oracle):hasA rdf:type owl:ObjectProperty ;
rdfs:subPropertyOf :hasRelation .
:hasB rdf:type owl:ObjectProperty ;
rdfs:subPropertyOf :hasRelation .
:hasC rdf:type owl:ObjectProperty ;
rdfs:subPropertyOf :hasRelation .
:hasD rdf:type owl:ObjectProperty ;
rdfs:subPropertyOf :hasRelation .
String q1 = "SELECT ?x, ?y
where {?x (:hasRelation)+ ?y} ";
Stirng q2 = "SELECT ?x, ?y
where {?x :hasRelation ?y} ";
Oracle oracle = new Oracle(szJdbcURL, szUser, szPasswd);
Attachment attachment = Attachment.createInstance(new String[]{"my_asset","my_model"},
new String[]{"OWLPRIME"}, InferenceMaintenanceMode.UPDATE_WHEN_COMMIT, QueryOptions.ALLOW_QUERY_INVALID_AND_DUP);
GraphOracleSem graph = new GraphOracleSem(oracle, "vm_model", attachment);
ModelOracleSem inferencedModel = new ModelOracleSem(graph);
Query query = QueryFactory.create(q1);
Edited by: a1239090 on Aug 15, 2012 4:54 PM -
5. Re: sparql query using variable paths
alwu-Oracle Aug 16, 2012 12:26 AM (in response to 366556)Hi,
Did you have a graph.performInference() somewhere in your code?
Thanks,
Zhe -
6. Re: sparql query using variable paths
366556 Aug 16, 2012 12:31 AM (in response to alwu-Oracle)I've created a virtual model before that. -
7. Re: sparql query using variable paths
alwu-Oracle Aug 16, 2012 4:34 AM (in response to 366556)Hi,
If you have created a virtual model before, then the following will do. Note that I am assuming that the virtual model is created based on two models "my_asset","my_model" and the rulebase OWLPRIME.
Attachment attachment = Attachment.createInstance(new String[]{"my_model"},
new String[]{"OWLPRIME"}, InferenceMaintenanceMode.UPDATE_WHEN_COMMIT, QueryOptions.ALLOW_QUERY_INVALID_AND_DUP);
GraphOracleSem graph = new GraphOracleSem(oracle, "my_asset", attachment, true);
graph.performInference();
Thanks,
Zhe