You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Benson Margulies <bi...@gmail.com> on 2010/12/30 19:39:30 UTC

Unexpected triples in construct query with a property path

I'll paste enough to repro at the bottom.

In short ... I start with some triples in an OntModel create with
.createOntologyModel(). They include:

 <http://www.basistech.com/ontologies/2010/12/rules#locatedAt>
      rdfs:subPropertyOf rex:relationship .

<uri:jug:taliban#1>
      <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
                    rex:Organization ;
      <http://www.basistech.com/ontologies/2010/12/rules#locatedAt>
                    <uri:jug:pakistan#1> ;
      rex:hasNormalizedText
                    "Taliban" .

I query with (this is part of an N-way union, and the CONSTRUCT list
includes ?s2 ?p ?o)

 {
         # start with the triples that have the specified text
          _:b2 rex:hasNormalizedText "<<<MATCH>>>" .
         # any subject that can be reached from there by a single
relationship step.
          _:b2 ?pred ?s2 .
         # where the relationship is defined by one of ours.
          ?pred rdfs:subPropertyOf* rex:relationship .
          ?s2 ?p ?o .
        }

and the results includes the following invented triple for the base
property. It's more or

<uri:jug:taliban#1>
      <http://www.basistech.com/ontologies/2010/6/rex.owl#relationship>
              <uri:jug:pakistan#1> .

---------- test data --------------


@prefix x-arq:   <urn:x-arq:> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rex:     <http://www.basistech.com/ontologies/2010/6/rex.owl#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .
@prefix :        <http://www.basistech.com/ontologies/2010/6/rex.owl#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rex:     <http://www.basistech.com/ontologies/2010/6/rex.owl#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

# Turtle file with data for some unit tests.

 <http://www.basistech.com/ontologies/2010/12/rules#locatedAt>
      rdfs:subPropertyOf rex:relationship .

<uri:jug:taliban#1>
      <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
                    rex:Organization ;
      <http://www.basistech.com/ontologies/2010/12/rules#locatedAt>
                    <uri:jug:pakistan#1> ;
      rex:hasNormalizedText
                    "Taliban" ;
      owl:sameAs
                    <uri:jug:taliban#2> ;
      owl:sameAs
                    <uri:jug:taliban#3> ;
      owl:sameAs    <uri:jug:staliban#1> .


<uri:jug:staliban#1>
      <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
                    rex:Organization ;
      <http://www.basistech.com/ontologies/2010/12/rules#locatedAt>
                    <uri:jug:pakistan#1> ;
      rex:hasNormalizedText
                    "STaliban" .

<uri:jug:pakistan#1>
      <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
                    rex:Location ;
      rex:hasNormalizedText
                    "Pakistan" ;
      rex:hasOriginalText
                    "Pakistan" ;
      owl:sameAs    <uri:jug:x#notIndia> .

<uri:jug:x#notIndia>
      <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
                    rex:Location ;
      rex:hasNormalizedText
                    "Not India" .

<uri:jug:x#someplace>
      <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
                    rex:Location ;
      rex:hasNormalizedText
                    "Someplace Else" .

<uri:jug:taliban#2>
      <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
                    rex:Organization ;
      <http://www.basistech.com/ontologies/2010/12/rules#locatedAt>
                    <uri:jug:x#someplace> ;
      rex:hasNormalizedText
                    "Taliban" .

<uri:jug:taliban#3>
      <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
                    rex:Organization ;
      <http://www.basistech.com/ontologies/2010/12/rules#locatedAt>
            <uri:jug:afghan#1> ;
      rex:hasNormalizedText
                    "Taliban" .

<uri:jug:afghan#1>
      <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
                    rex:Location ;
      rex:hasNormalizedText
                    "Afghanistan" ;
      rex:hasOriginalText
                    "Afghanistan" .

<uri:jug:unrelated#1>
      <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
                    rex:Person ;
      rex:hasNormalizedText
                    "Smith" ;
      rex:hasOriginalText
                    "Smif" .

Re: Unexpected triples in construct query with a property path

Posted by Andy Seaborne <an...@epimorphics.com>.

On 30/12/10 18:39, Benson Margulies wrote:
> I'll paste enough to repro at the bottom.
>
> In short ... I start with some triples in an OntModel create with
> .createOntologyModel().

.createOntologyModel() includes some inference, including subproperty.

> They include:
>
>   <http://www.basistech.com/ontologies/2010/12/rules#locatedAt>
>        rdfs:subPropertyOf rex:relationship .
>
> <uri:jug:taliban#1>
>        <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
>                      rex:Organization ;
>        <http://www.basistech.com/ontologies/2010/12/rules#locatedAt>
>                      <uri:jug:pakistan#1>  ;
>        rex:hasNormalizedText
>                      "Taliban" .
>
> I query with (this is part of an N-way union, and the CONSTRUCT list
> includes ?s2 ?p ?o)
>
>   {
>           # start with the triples that have the specified text
>            _:b2 rex:hasNormalizedText "<<<MATCH>>>" .
>           # any subject that can be reached from there by a single
> relationship step.
>            _:b2 ?pred ?s2 .
>           # where the relationship is defined by one of ours.
>            ?pred rdfs:subPropertyOf* rex:relationship .
>            ?s2 ?p ?o .
>          }
>
> and the results includes the following invented triple for the base
> property. It's more or
>
> <uri:jug:taliban#1>
>        <http://www.basistech.com/ontologies/2010/6/rex.owl#relationship>
>                <uri:jug:pakistan#1>  .

The inference from

 >   <http://www.basistech.com/ontologies/2010/12/rules#locatedAt>
 >        rdfs:subPropertyOf rex:relationship .

on

<uri:jug:taliban#1>
       <http://www.basistech.com/ontologies/2010/12/rules#locatedAt>
                     <uri:jug:pakistan#1> ;

concludes

 > <uri:jug:taliban#1>
 >        <http://www.basistech.com/ontologies/2010/6/rex.owl#relationship>
 >                <uri:jug:pakistan#1>  .

so it appears in the answers.

For Jena, the inference engines are rule based.  You can think of it as 
calculating all the possible triples and making them visible in the 
data.  For forward-chaining, that is how it works; for backward chaining 
it only does work at query time; it's not a correct understanding for 
some OWL constructs like disjunction.

Using inference and property paths for inference is likely to be 
confusing.  In fact, because it's CONSTRUCT, the duplicate work gets 
suppressed because a graph is a set of triples.

	Andy