On 05/12/12 20:35, Paul Gearon wrote:
I know you said that the property value is not duplicated, but it really
looks like it is. Could something unexpected have created it?

Can you please confirm that the following returns nothing?

SELECT ?activity ?r1 ?r2
WHERE {
  ?activity ont:rating ?r1 . ?activity ont:rating ?r2
  FILTER (!sameTerm(?r1, ?r2)) }

Paul's right - the key here is "sameterm"

"1"^^xsd:float and "1.0"^^xsd:float are the same value but different terms. "+1"^^xsd:byte is the same value but a different term.

As literals, the lexical forms are different so they are different RDF terms even though they represent (to a system that understands xsd:float) the same value. Many names for the same value, just like many URIs are possible for the same individual.

Doing an arithmetic operation on the term tends to produce a canonical form.

        Andy





Regards,
Paul



On Wed, Dec 5, 2012 at 12:48 PM, Emmanuelle <[email protected]> wrote:

Hi,

I'm getting duplicated results when executing the following query (I'm
using jena 2.7.0):

SELECT ?activity ?rating WHERE {?activity ont:rating ?rating }
....
| ind:obj675_p2c22A   | "0.75"^^xsd:float |
| ind:obj3967_p2c22A  | "1"^^xsd:float    |
| ind:obj3967_p2c22A  | "1.0"^^xsd:float  |
....
Only values equal to their integer part are duplicated this way.

The "ind:obj3967_p2c22A" individual is unique and the datatype
property value is not duplicated in the ontology, it's functional with
range float:

<owl:DatatypeProperty rdf:about="&ont;rating">
         <rdf:type rdf:resource="&owl;FunctionalProperty"/>
         <rdfs:range rdf:resource="&xsd;float"/>
</owl:DatatypeProperty>

I could get around it by doing:
SELECT ?activity ((?rating  * 1.0) as ?r) WHERE {?activity ont:rating
?rating }

but I couldn't find a way to get a accurate result when aggregating, e.g.:
SELECT (count(?activity) as ?totA) (sum(?rating) as ?totR) WHERE ....

Is it the expected behavior? Is there a way to set the precision of
float values when querying the ontology to avoid duplication?

Thanks in advance.
Emmanuelle



Reply via email to