Dear all,
I have a very basic question...I need to compare literals that are floats and tried to use two ways. 1) using sh:equals to compare 2 properties and 2) using SPARQL where I filter != different values
For the filter I tried usingFILTER (xsd:float(?value1)!=xsd:float(?value1)).orFILTER (?value1!=?value1).Both give the same outcome.
Below I listed a summary of the tests I did
I think sh:equals treats the literals as strings even though they are floats. It also gives 2 results. I thing this looks like according to the SHACL spec although I didn't if the sh:equals ignores the datatype.
In SPARQL you may be better off with xsd:decimal than xsd:float, as xsd:decimal has more precision. But this is more of a SPARQL/ARQ question for which you may get more qualified help elsewhere, e.g. on jena-users.
Holger
Best regardsChavdar--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/63a7e8ba-468e-4803-a1c4-31afca5d55e9n%40googlegroups.com.
Dear Holger,
Thanks. I will approach the other forum.
Just to clarify – yes all literals were typed literals with datatype float. So sh:equals was comparing float to float
Did you mean that I should use xsd:decimal in the SPARQL query although in data graph it is coming as float?
Something like this
?var1 which is float in data graph
?var2 which is float in data graph
xsd:decimal(?var1)!=xsd:decimal(?var2)
Best regards
Chavdar
Since sh:equals is based on RDF node equality, values such as "1.0"^^xsd:float and "1"^^xsd:float count as distinct. Maybe that's the issue you are running into?
SPARQL does comparison by (mathematical) values, so 1.0 = 1
there.
Holger
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/3c8ac02a-8d85-4657-b3b1-33c603447b2fn%40googlegroups.com.