query inference

1 view
Skip to first unread message

Tze-John Tang

unread,
Mar 6, 2015, 4:50:08 PM3/6/15
to sta...@clarkparsia.com
From the command line, I can use stardog explain to show why something is inferred, i.e.

[stardog@ip-10-239-11-157 staging]$ stardog reasoning explain "kg;reasoning=QL" "<http://schemas.abbvienet.com/ontologies/infrastructure.owl#Person> a <urn:x-abbvie:rdf-service#MasterEntity>
"
INFERRED <http://schemas.abbvienet.com/ontologies/infrastructure.owl#Person> a <urn:x-abbvie:rdf-service#MasterEntity>
   ASSERTED <urn:x-abbvie:rdf-service#viewConfiguration> rdfs:domain <urn:x-abbvie:rdf-service#MasterEntity>
   ASSERTED <http://schemas.abbvienet.com/ontologies/infrastructure.owl#Person> <urn:x-abbvie:rdf-service#viewConfiguration> <urn:x-abbvie:rdf-service:309b8bf5efe86c7a2769902ff440f6e6a9dee418>

[stardog@ip-10-239-11-157 staging]$ stardog reasoning explain "kg;reasoning=QL" "<http://schemas.abbvienet.com/ontologies/infrastructure.owl#Account> a <urn:x-abbvie:rdf-service#MasterEntity>
"
Input axiom is not a valid inference; no explanation generated.


 Is there anyway for me to do the same thing in a query?  If I do query for the graph which contains the inferred triple:

[stardog@ip-10-239-11-157 staging]$ stardog query execute "kg;reasoning=QL" "select * where { graph ?g { <http://schemas.abbvienet.com/ontologies/infrastructure.owl#Person> a <urn:x-abbvie:rdf-service#MasterEntity> . } }"
+-------+
|   g   |
+-------+
|       |
+-------+

Query returned 1 results in 00:00:00.058


I get one result with an empty graph (g) value. I assume this means that this is in the default graph? But if I do the same query for the above case where there is no inferred axiom, I get the same result.

[stardog@ip-10-239-11-157 staging]$ stardog query execute "kg;reasoning=QL" "select * where { graph ?g { <http://schemas.abbvienet.com/ontologies/infrastructure.owl#Account> a <urn:x-abbvie:rdf-service#MasterEntity> . } }"
+-------+
|   g   |
+-------+
|       |
+-------+

Query returned 1 results in 00:00:00.058


If I do a search for a subject where the subject is a master entity, I get:

[stardog@ip-10-239-11-157 staging]$ stardog query execute "kg;reasoning=QL" "select * where { graph ?g { ?s a <urn:x-abbvie:rdf-service#MasterEntity> . } }"
+---------------------------------+-------------------------------------------------------------------+
|                g                |                                 s                                 |
+---------------------------------+-------------------------------------------------------------------+
+---------------------------------+-------------------------------------------------------------------+

Query returned 1 results in 00:00:00.059



So if I know the subject, and I know the inferred rdf type, what kind of query can I execute to check if #Account is a #MasterEntity?

Thanks,

-tj

Evren Sirin

unread,
Mar 9, 2015, 9:05:22 AM3/9/15
to Stardog
Having no binding for graph does not mean it is the default graph. No
GRAPH pattern in a query is supposed to match the default graph unless
you turn on the query.all.graphs option so something else must be
going there. Can you send us some minimal data so we can try to
reproduce?

It looks like what you need is not a SELECT query but an ASK query:

ASK { GRAPH ?g {
<http://schemas.abbvienet.com/ontologies/infrastructure.owl#Account> a
<urn:x-abbvie:rdf-service#MasterEntity> . } }

You can simply check the boolean result of the ASK query. But if there
is something wrong with the select query results then the ask query
might return incorrect results too.

Best,
Evren
> --
> -- --
> You received this message because you are subscribed to the C&P "Stardog"
> group.
> To post to this group, send email to sta...@clarkparsia.com
> To unsubscribe from this group, send email to
> stardog+u...@clarkparsia.com
> For more options, visit this group at
> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

Tze-John Tang

unread,
Mar 9, 2015, 11:25:55 AM3/9/15
to sta...@clarkparsia.com
Evern,

Correct.  I was using the select query to troubleshoot why the ASK was always returning true even though there is no inferred triples. As seen in my select queries, I am getting 1 row back in each case.

I have attached a dump of my urn:x-abbvie:rdf-service:config graph in config.ttl, and then I also have the owl file loaded in the urn:x-abbvie:rdf-service graph.  Let me know if you have any questions about them.

Thanks.

-tj
config.ttl
rdf-service.owl

Evren Sirin

unread,
Mar 10, 2015, 11:35:28 AM3/10/15
to Stardog
Below is what I tried with your data where I get the expected answers
in all cases. What version of Stardog are you using? Did you change
any configuration options in the database metadata or
stardog.properties? Do you see any errors or warnings in stardog.log?

Best,
Evren

stardog-2.2.4$ bin/stardog-admin db create -o reasoning.schema.graphs="*" -n kg
Creating index: 100% complete in 00:00:00 (0.0K triples/sec)
Creating index finished in 00:00:00.011
Loading complete.
Inserted 0 triples in 00:00:00.056 at 0.0K triples/sec
Successfully created database 'kg'.

stardog-2.2.4$ bin/stardog data add -g urn:x-abbvie:rdf-service:config
kg config.ttl
Adding data from file: config.ttl
Added 7 triples in 00:00:00.090
stardog-2.2.4$ bin/stardog data add -g urn:x-abbvie:rdf-service kg
rdf-service.owl
Adding data from file: rdf-service.owl
Added 62 triples in 00:00:00.074
stardog-2.2.4$ bin/stardog query -r QL kg "ASK { GRAPH ?g
{<http://schemas.abbvienet.com/ontologies/infrastructure.owl#Person> a
<urn:x-abbvie:rdf-service#MasterEntity>}}"
Result: true.
stardog-2.2.4$ bin/stardog query -r QL kg "ASK FROM
<tag:stardog:api:context:all> {
<http://schemas.abbvienet.com/ontologies/infrastructure.owl#Person> a
<urn:x-abbvie:rdf-service#MasterEntity>}"
Result: true.
stardog-2.2.4$ bin/stardog query -r QL kg "SELECT ?g { GRAPH ?g
{<http://schemas.abbvienet.com/ontologies/infrastructure.owl#Person> a
<urn:x-abbvie:rdf-service#MasterEntity>}}"
+---------------------------------+
| g |
+---------------------------------+
| urn:x-abbvie:rdf-service:config |
+---------------------------------+

Query returned 1 results in 00:00:00.055
stardog-2.2.4$ bin/stardog query -r QL kg "ASK { GRAPH ?g
{<http://schemas.abbvienet.com/ontologies/infrastructure.owl#Account>
a <urn:x-abbvie:rdf-service#MasterEntity>}}"
Result: false.
stardog-2.2.4$ bin/stardog query -r QL kg "ASK FROM
<tag:stardog:api:context:all> {
<http://schemas.abbvienet.com/ontologies/infrastructure.owl#Account> a
<urn:x-abbvie:rdf-service#MasterEntity>}"
Result: false.
stardog-2.2.4$ bin/stardog query -r QL kg "SELECT ?g { GRAPH ?g
{<http://schemas.abbvienet.com/ontologies/infrastructure.owl#Account>
a <urn:x-abbvie:rdf-service#MasterEntity>}}"
+-------+
| g |
+-------+
+-------+

Query returned 0 results in 00:00:00.040

Tze-John Tang

unread,
Mar 10, 2015, 3:58:05 PM3/10/15
to sta...@clarkparsia.com
Evren,

When I try with the data subset I sent you, I get what you see, which is what I would expect. I will take a look and see if I can find what subset of my data I can give you to reproduce it.  If I need to send it all to you, can you give me a secure location to drop it off at? Mike had a abbvie-inbox in dropbox created, but it seems like I am having browser script errors when accessing their page at the moment.

In my problematic instance.. with reasoning on, I actually get a single result, as opposed to 0 results. When I take reasoning off, then I get 0 results. And then when I try to explain the inferred triple that returns a single row, I get that the axiom is not valid.

[stardog@ip-10-239-11-157 staging]$ stardog query -r QL kg "SELECT ?g { GRAPH ?g
a <urn:x-abbvie:rdf-service#MasterEntity>}}"
+-------+
|   g   |
+-------+
|       |
+-------+

Query returned 1 results in 00:00:00.054
[stardog@ip-10-239-11-157 staging]$ stardog reasoning explain "kg;reasoning=QL" "<http://schemas.abbvienet.com/ontologies/infrastructure.owl#Account>
a <urn:x-abbvie:rdf-service#MasterEntity> ."
Input axiom is not a valid inference; no explanation generated.
[stardog@ip-10-239-11-157 staging]$ stardog query kg "SELECT ?g { GRAPH ?g                                             {<http://schemas.abbvienet.com/ontologies/infrastructure.owl#Account>
a <urn:x-abbvie:rdf-service#MasterEntity>}}"
+-------+
|   g   |
+-------+
+-------+

Query returned 0 results in 00:00:00.049
[stardog@ip-10-239-11-157 staging]$



Tze-John Tang

unread,
Mar 10, 2015, 4:05:40 PM3/10/15
to sta...@clarkparsia.com
Evren,

Actually I can duplicate the result after loading another ontology into it's own graph. It is attached.

-tj
infrastructure.owl

Evren Sirin

unread,
Mar 10, 2015, 4:31:36 PM3/10/15
to Stardog
Yes, I see the behavior now. Thanks for the data, we'll look into this
and get back to you.

Best,
Evren

Evren Sirin

unread,
Mar 11, 2015, 9:58:44 AM3/11/15
to Stardog
The issue here is related to the feature called "punning". Punning is
using the same URI as a name for both a class and an individual. This
is allowed in OWL but makes modeling tricky and should be used with
care. I don't know the details of the domain so it might be a good
idea to use punning here but changing the modeling to avoid punning
might be an option.

We'll be working on to fix the bug that causes the incorrect result.
The bug is triggered only in certain cases so a workaround that you
can use until we fix the bug is the following query:

ASK {
GRAPH ?g {
?x a <urn:x-abbvie:rdf-service#MasterEntity>
FILTER (str(?x)='http://schemas.abbvienet.com/ontologies/infrastructure.owl#Person')
}
}

Note that it is important to use the str function in the FILTER.
Otherwise Stardog would inline the value in the FILTER that would make
this equivalent to the query where the bug is triggered.

Finally, if you will be using punning in your domain then you should
enable the configuration option called reasoning.punning.enabled in
Stardog to get complete reasoning results. Without that option set,
Stardog will assume classes and individuals in your database are
disjoint and will optimize your queries accordingly that might result
in missed results.

Best,
Evren
Reply all
Reply to author
Forward
0 new messages