Hi Kingsely,
Thanks for the kind reply. It works for me. I guess I was confused that
subProperty should be transitive instead of making the target property a
subproperty of a transitive property.
Thanks.
With regards,
Jason Koh
cseweb.ucsd.edu/~jbkoh
On Thu, May 31, 2018 at 7:05 AM, Kingsley Idehen <kide...@openlinksw.com>
wrote:
> On 5/23/18 8:32 PM, Jason Koh wrote:
>
> Hi,
>
> First I would like to appreciate this community where I am receiving a lot
> of help.
>
> I have a query would like to get answers but a variable predicate.
>
> The dataset is:
> ```
> # Insert Triples
> sparql
>
> prefix owl: <http://www.w3.org/2002/07/owl#>
> prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> prefix : <http://example.com#>
>
> insert data {
> graph <urn:proptest> {
> :PropB a owl:TransitiveProperty.
> :PropB1 rdfs:subPropertyOf :PropB.
> :PropB2 rdfs:subPropertyOf :propB1.
>
> :b a :EntityB.
> :b1 a :EntityB.
> :b2 a :EntityB.
> :aaa a :EntityB;
> :propB :b;
> :propB1 :b1;
> :propB2 :b2.
> }
> };
> ```
> Basically there is "aaa" who is related to "b", "b1", "b2" with "PropB",
> "PropB1", "PropB2". And they have a hierarchy as PropB2 is a sub property
> of PropB1 that is a sub property of PropB.
>
> However, below query does not return anything:
> ```
> sparql
> prefix owl: <http://www.w3.org/2002/07/owl#>
> prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> prefix : <http://example.com#>
>
> select ?s ?p ?o from <urn:proptest> where {
> ?p rdfs:subPropertyOf* :PropB.
> ?s ?p ?o.
> };
> ```
>
> So I added reasoning rules based on Kingsley's previous comment.
>
> Here's the rule graph:
> ```
> sparql
> prefix owl: <http://www.w3.org/2002/07/owl#>
> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> prefix : <http://example.com#>
>
> insert data {
> graph <urn:proptest:rules> {
> :PropB a owl:TransitiveProperty.
> :PropB1 rdfs:subPropertyOf :PropB.
> :PropB2 rdfs:subPropertyOf :propB1.
> }
> };
> ```
>
> Then I inserted the rule with a command:
> ``rdfs_rule_set ('urn:proptest:rules', 'urn:proptest:rules') ;``
>
> Then I enabled the rule in the query:
> ```
> sparql
> DEFINE input:inference 'urn:proptest:rules'
> prefix owl: <http://www.w3.org/2002/07/owl#>
> prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> prefix : <http://example.com#>
>
> select ?s ?p ?o from <urn:proptest> where {
> ?p rdfs:subPropertyOf* :PropB.
> ?s ?p ?o.
> };
> ```
> But still it does not return anything.
>
> I am not sure if the query is valid in SPARQL or there is something I miss
> in Virtuoso.
>
> If there is anything that I can learn about, please let me know.
>
> Thank you!
>
>
> With regards,
> Jason Koh
> cseweb.ucsd.edu/~jbkoh <http://cseweb.ucsd.edu/%7Ejbkoh>
>
>
> Jason,
>
> Here is a complete script. Please study it.
>
> ```
>
> -- Clear Graphs
>
> SPARQL CLEAR GRAPH <urn:rdfs:inference:rules:def> ;
> SPARQL CLEAR GRAPH <urn:rdfs:inference:rules:test> ;
>
>
>
> -- Load TBox Data
>
> SPARQL
> PREFIX owl: <http://www.w3.org/2002/07/owl#>
> <http://www.w3.org/2002/07/owl#>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> <http://www.w3.org/2000/01/rdf-schema#>
> PREFIX : <#>
>
> INSERT DATA {
> GRAPH <urn:rdfs:inference:rules:def>
> {
> rdfs:subPropertyOf a owl:TransitiveProperty .
> rdfs:subClassOf a owl:TransitiveProperty .
> :rel1 a rdf:Property .
> :rel2 rdfs:subPropertyOf :rel1 .
> :rel3 rdfs:subPropertyOf :rel2 .
>
> }
> };
>
> -- Load Abox Data
>
> SPARQL
> PREFIX owl: <http://www.w3.org/2002/07/owl#>
> <http://www.w3.org/2002/07/owl#>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> <http://www.w3.org/2000/01/rdf-schema#>
> PREFIX : <#>
>
> INSERT DATA {
> GRAPH <urn:rdfs:inference:rules:test>
> {
> :this :rel3 :that .
> :this :rel3 :that .
> :that :rel2 :other .
> :other :rel1 :final .
> }
> };
>
> SPARQL
>
> SELECT *
> FROM <urn:rdfs:inference:rules:def>
> WHERE {?s ?p ?o} ;
>
> RDFS_RULE_SET ('urn:rdfs:inference:rules', 'urn:rdfs:inference:rules:def')
> ;
>
> SELECT *
> FROM DB.DBA.SYS_RDF_SCHEMA
> WHERE RS_NAME = 'urn:rdfs:inference:rules' ;
>
> -- Test Query 1 using Property Path "+" operator
>
> SPARQL
>
> DEFINE input:inference 'urn:rdfs:inference:rules'
> PREFIX owl: <http://www.w3.org/2002/07/owl#>
> <http://www.w3.org/2002/07/owl#>
> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> <http://www.w3.org/2000/01/rdf-schema#>
> PREFIX : <#>
>
> SELECT DISTINCT :this ?p ?o
> FROM <urn:rdfs:inference:rules:test>
> WHERE {
> :this :rel1+ ?o ;
> ?p ?o2.
>
> } ;
>
>
> -- Test Query 2 using Property Path "*" operator
>
> SPARQL
>
> DEFINE input:inference 'urn:rdfs:inference:rules'
> PREFIX owl: <http://www.w3.org/2002/07/owl#>
> <http://www.w3.org/2002/07/owl#>
> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> <http://www.w3.org/2000/01/rdf-schema#>
> PREFIX : <#>
>
> SELECT DISTINCT :this ?o ?p ?o2
> FROM <urn:rdfs:inference:rules:test>
> WHERE {
> :this :rel1* ?o .
> ?o ?p ?o2 .
> } ;
>
>
> ```
>
>
> --
> Regards,
>
> Kingsley Idehen
> Founder & CEO
> OpenLink Software (Home Page: http://www.openlinksw.com)
>
> Weblogs (Blogs):
> Legacy Blog: http://www.openlinksw.com/blog/~kidehen/
> Blogspot Blog: http://kidehen.blogspot.com
> Medium Blog: https://medium.com/@kidehen
>
> Profile Pages:
> Pinterest: https://www.pinterest.com/kidehen/
> Quora: https://www.quora.com/profile/Kingsley-Uyi-Idehen
> Twitter: https://twitter.com/kidehen
> Google+: https://plus.google.com/+KingsleyIdehen/about
> LinkedIn: http://www.linkedin.com/in/kidehen
>
> Web Identities (WebID):
> Personal: http://kingsley.idehen.net/public_home/kidehen/profile.ttl#i
> :
> http://id.myopenlink.net/DAV/home/KingsleyUyiIdehen/Public/kingsley.ttl#this
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Virtuoso-users mailing list
> Virtuoso-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/virtuoso-users
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Virtuoso-users mailing list
Virtuoso-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/virtuoso-users