Stardog literal comparison behaviour

1 view
Skip to first unread message

zhilia...@gmail.com

unread,
Aug 18, 2015, 2:02:28 AM8/18/15
to Stardog, naru...@gmail.com
Hi Stardog team, 

Given the below data, which I imported using the Sesame api,


<owl:DatatypeProperty rdf:about="http://w.co/mfd#hasRevenue">
        <rdfs:domain rdf:resource="http://w.co/mfd#Manufacturer"/>
        <rdfs:range rdf:resource="&xsd;long"/>
    </owl:DatatypeProperty> 

<owl:NamedIndividual rdf:about="http://w.co/mfd#Apple">
        <rdf:type rdf:resource="http://w.co/mfd#Manufacturer"/>
        <hasRevenue rdf:datatype="&xsd;long">182795000000</hasRevenue>
        <hasName xml:lang="en">Apple Inc</hasName>
        <manufacture rdf:resource="http://w.co/mfd#iPhone5"/>
        <manufacture rdf:resource="http://w.co/mfd#iPhone6"/>
        <rdfs:label xml:lang="en">Apple Inc</rdfs:label>
    </owl:NamedIndividual>



I expected the following query to yield results, yet it didn't. Changing the datatype from <http://www.w3.org/2001/XMLSchema#long> to <http://www.w3.org/2001/XMLSchema#float> or <http://www.w3.org/2001/XMLSchema#double>
yielded the expected results. Please confirm if this is a bug.

SELECT distinct ?s WHERE {  ?s <http://w.co/mfd#hasRevenue> ?o1  .  FILTER( ?o1 > "10"^^<http://www.w3.org/2001/XMLSchema#long> )}  -> 0 results
SELECT distinct ?s WHERE {  ?s <http://w.co/mfd#hasRevenue> ?o1  .  FILTER( ?o1 > "10"^^<http://www.w3.org/2001/XMLSchema#integer> )}  -> 0 results

Further checking with the following query

SELECT (datatype(?o1) AS ?datatype) WHERE {  ?s <http://w.co/mfd#hasRevenue> ?o1 } 


We are using Stardog v3.0.

Evren Sirin

unread,
Aug 18, 2015, 2:25:12 AM8/18/15
to Stardog, naru...@gmail.com
On Tue, Aug 18, 2015 at 2:02 AM, <zhilia...@gmail.com> wrote:
> Hi Stardog team,
>
> Given the below data, which I imported using the Sesame api,
>
>
> <owl:DatatypeProperty rdf:about="http://w.co/mfd#hasRevenue">
> <rdfs:domain rdf:resource="http://w.co/mfd#Manufacturer"/>
> <rdfs:range rdf:resource="&xsd;long"/>
> </owl:DatatypeProperty>
>
> <owl:NamedIndividual rdf:about="http://w.co/mfd#Apple">
> <rdf:type rdf:resource="http://w.co/mfd#Manufacturer"/>
> <hasRevenue rdf:datatype="&xsd;long">182795000000</hasRevenue>
> <hasName xml:lang="en">Apple Inc</hasName>
> <manufacture rdf:resource="http://w.co/mfd#iPhone5"/>
> <manufacture rdf:resource="http://w.co/mfd#iPhone6"/>
> <rdfs:label xml:lang="en">Apple Inc</rdfs:label>
> </owl:NamedIndividual>
>
>
>
> I expected the following query to yield results, yet it didn't. Changing the
> datatype from <http://www.w3.org/2001/XMLSchema#long> to
> <http://www.w3.org/2001/XMLSchema#float> or
> <http://www.w3.org/2001/XMLSchema#double>
> yielded the expected results. Please confirm if this is a bug.
>
> SELECT distinct ?s WHERE { ?s <http://w.co/mfd#hasRevenue> ?o1 . FILTER(
> ?o1 > "10"^^<http://www.w3.org/2001/XMLSchema#long> )} -> 0 results
> SELECT distinct ?s WHERE { ?s <http://w.co/mfd#hasRevenue> ?o1 . FILTER(
> ?o1 > "10"^^<http://www.w3.org/2001/XMLSchema#integer> )} -> 0 results

Yes, this is a bug and we have an open ticket for this issue (#643).

>
> Further checking with the following query
>
> SELECT (datatype(?o1) AS ?datatype) WHERE { ?s <http://w.co/mfd#hasRevenue>
> ?o1 }
>
> yields <http://www.w3.org/2001/XMLSchema#integer>.

This is related to literal canonicalization and it is the expected
result (xsd:integer is infinite and it is a supertype of xsd:long).
See [1] for literal canonicalization.

Best,
Evren

[1] http://docs.stardog.com/#_canonicalized_literals

>
> We are using Stardog v3.0.
>
> --
> -- --
> 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
Reply all
Reply to author
Forward
0 new messages