You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Rob Hall <kv...@gmail.com> on 2012/07/13 16:50:11 UTC

Multiple Bindings for single value

Hey,

   I have an OntModel with an attached pellet reasoner that I am querying
with ARQ. It contains typed literals (for example, *"0"^^<
http://www.w3.org/2001/XMLSchema#long>*) which I've added directly using
the typed literal api as follows:

*model.add(individual, Vocabulary.atIndex, model.createTypedLiteral(new
Long(ii)));*
*
*
Where atIndex is a data property that relates individuals to to an indexing
value. When I run a SPARQL query to retrieve this data, I get multiple rows
for each individual value like such:

---------------------------------------------------------------------------------------------------------------
| index                                        | inv
                                |
================================================================
| 0                                              | example:inv-0
                            |
| "0"^^xsd:long                             | example:inv-0
                      |
================================================================

When I then view any serialization of this dataset, I see exactly one
relation between the individual and the value (with a different datatype).
(N-TRIPPLE example below).

*<http://example/ont#inv-0> <http://example/ont#atIndex> "0"^^<
http://www.w3.org/2001/XMLSchema#integer> .*
*
*
I've attempted to modify the query provided below in several ways but I've
yet to find a successful way to retrieve one distinct row. Adding DISTINCT
or GROUP BY clauses do nothing as jena treats them as distinct nodes (which
it makes sense that it does). I've attempted filter queries to limit
results using xpath string comparison operations to no avail.

PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
PREFIX vocab: <http://example/ont#>
SELECT ?index ?inv
WHERE {
?inv vocab:atIndex ?index .
} ORDER BY ?index

Re: Multiple Bindings for single value

Posted by Joshua TAYLOR <jo...@gmail.com>.
On Fri, Jul 13, 2012 at 3:05 PM, Andy Seaborne <an...@apache.org> wrote:
>>> model.createTypedLiteral(new Long(ii)));
>
> That puts in a typed literal as xsd:long, because xsd:long reflects all the
> range limitations of a Java Long.
>
> Try putting in a xsd:integer with:
>
> m.createTypedLiteral("0", XSDDatatype.XSDinteger) ;
>
> because it looks like inference is inferring this value from the derived
> datatype xsd:long.

(Coworker of Rob --- we'd be discussing this before emails got sent.
Replying on his behalf for the moment...)

We also ended playing with BigIntegers too, since it seems to be the
case that unqualified integers in SPARQL queries and results are
xsd:integers, which correspond to Java BigIntegers.

Given some experiments with what happened with Pellet vs without, we
were starting to come to the same conclusion (i.e., that one of the
triples was inferred), but we weren't sure what sort of OWL inference
about datatypes is allowed, and hence whether this was something that
could be explained that way.  It seems like this is the case though.

> PS This would not happen with TDB - it stores the integer value, and looses
> the xsd:long/xsd:integer distinction.

Actually, the base model is stored with TDB, but I guess Pellet's
storage isn't.  Maybe it's worth looking into whether Pellet can be
made to use TDB for storage.

//JT

-- 
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/

Re: Multiple Bindings for single value

Posted by Andy Seaborne <an...@apache.org>.
Rob,

 >> model.createTypedLiteral(new Long(ii)));

That puts in a typed literal as xsd:long, because xsd:long reflects all 
the range limitations of a Java Long.

Try putting in a xsd:integer with:

m.createTypedLiteral("0", XSDDatatype.XSDinteger) ;

because it looks like inference is inferring this value from the derived 
datatype xsd:long.

Once the data to query has two ways (two RDF terms) to write one value, 
it's hard to write a query to do value-based equality without 
post-processing the results.

	Andy

PS This would not happen with TDB - it stores the integer value, and 
looses the xsd:long/xsd:integer distinction.




On 13/07/12 18:10, Rob Hall wrote:
> Update: I found that a small change is making the difference. It seems that
> the combination of* *axioms within my model and the language spec used when
> creating it are causing the duplication to occur. The following list
> denotes the base spec that I used when creating my reasoner; whether or not
> my model imported my axioms; and finally, whether the test (that no
> 'duplicate' rows existed) passed.
>
>
>     1. OntModelSpec.OWL_DL_MEM & Empty Model - Passed
>     2. OntModelSpec.OWL_DL_MEM & Allowed Imports - Failed
>     3. OntModelSpec.OWL_MEM & Empty Model - Passed
>     4. OntModelSpec.OWL_MEM & Allowed Imports - Passed
>
>
> On Fri, Jul 13, 2012 at 10:50 AM, Rob Hall <kv...@gmail.com> wrote:
>
>>
>> Hey,
>>
>>     I have an OntModel with an attached pellet reasoner that I am querying
>> with ARQ. It contains typed literals (for example, *"0"^^<
>> http://www.w3.org/2001/XMLSchema#long>*) which I've added directly using
>> the typed literal api as follows:
>>
>> *model.add(individual, Vocabulary.atIndex, model.createTypedLiteral(new
>> Long(ii)));*
>> *
>> *
>> Where atIndex is a data property that relates individuals to to an
>> indexing value. When I run a SPARQL query to retrieve this data, I get
>> multiple rows for each individual value like such:
>>
>>
>> ---------------------------------------------------------------------------------------------------------------
>> | index                                        | inv
>>                                  |
>> ================================================================
>> | 0                                              | example:inv-0
>>                              |
>> | "0"^^xsd:long                             | example:inv-0
>>                          |
>> ================================================================
>>
>> When I then view any serialization of this dataset, I see exactly one
>> relation between the individual and the value (with a different datatype).
>> (N-TRIPPLE example below).
>>
>> *<http://example/ont#inv-0> <http://example/ont#atIndex> "0"^^<
>> http://www.w3.org/2001/XMLSchema#integer> .*
>> *
>> *
>> I've attempted to modify the query provided below in several ways but I've
>> yet to find a successful way to retrieve one distinct row. Adding DISTINCT
>> or GROUP BY clauses do nothing as jena treats them as distinct nodes (which
>> it makes sense that it does). I've attempted filter queries to limit
>> results using xpath string comparison operations to no avail.
>>
>> PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
>> PREFIX vocab: <http://example/ont#>
>> SELECT ?index ?inv
>> WHERE {
>> ?inv vocab:atIndex ?index .
>> } ORDER BY ?index
>>
>
>
>



Re: Multiple Bindings for single value

Posted by Rob Hall <kv...@gmail.com>.
Update: I found that a small change is making the difference. It seems that
the combination of* *axioms within my model and the language spec used when
creating it are causing the duplication to occur. The following list
denotes the base spec that I used when creating my reasoner; whether or not
my model imported my axioms; and finally, whether the test (that no
'duplicate' rows existed) passed.


   1. OntModelSpec.OWL_DL_MEM & Empty Model - Passed
   2. OntModelSpec.OWL_DL_MEM & Allowed Imports - Failed
   3. OntModelSpec.OWL_MEM & Empty Model - Passed
   4. OntModelSpec.OWL_MEM & Allowed Imports - Passed


On Fri, Jul 13, 2012 at 10:50 AM, Rob Hall <kv...@gmail.com> wrote:

>
> Hey,
>
>    I have an OntModel with an attached pellet reasoner that I am querying
> with ARQ. It contains typed literals (for example, *"0"^^<
> http://www.w3.org/2001/XMLSchema#long>*) which I've added directly using
> the typed literal api as follows:
>
> *model.add(individual, Vocabulary.atIndex, model.createTypedLiteral(new
> Long(ii)));*
> *
> *
> Where atIndex is a data property that relates individuals to to an
> indexing value. When I run a SPARQL query to retrieve this data, I get
> multiple rows for each individual value like such:
>
>
> ---------------------------------------------------------------------------------------------------------------
> | index                                        | inv
>                                 |
> ================================================================
> | 0                                              | example:inv-0
>                             |
> | "0"^^xsd:long                             | example:inv-0
>                         |
> ================================================================
>
> When I then view any serialization of this dataset, I see exactly one
> relation between the individual and the value (with a different datatype).
> (N-TRIPPLE example below).
>
> *<http://example/ont#inv-0> <http://example/ont#atIndex> "0"^^<
> http://www.w3.org/2001/XMLSchema#integer> .*
> *
> *
> I've attempted to modify the query provided below in several ways but I've
> yet to find a successful way to retrieve one distinct row. Adding DISTINCT
> or GROUP BY clauses do nothing as jena treats them as distinct nodes (which
> it makes sense that it does). I've attempted filter queries to limit
> results using xpath string comparison operations to no avail.
>
> PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
> PREFIX vocab: <http://example/ont#>
> SELECT ?index ?inv
> WHERE {
> ?inv vocab:atIndex ?index .
> } ORDER BY ?index
>



-- 
Robert Trevor Hall
Phone: (315) 719-5039