Re: Convert string to float in a SPARQL query

2016-09-16 Thread Rob Vesse
As Andy has pointed out it is the decimal separator that is the problem.

SPARQL defers to XML Schema Datatypes for its datatype support and that 
mandates certain lexical forms for datatypes including the use of ‘.’ As the 
decimal separator as opposed to ‘,’ in your data.

Assuming that you control the source of the data prior to it becoming RDF it 
would be best to try and fix the conversion of the data at that stage.

If you don’t control the data then your best option is probably to create an 
extension function within Jena that is capable of parsing the Values in the 
format given in the data and use this in place of the xsd:float() function. 
Please see the following documentation for more guidance:

http://jena.apache.org/documentation/query/extension.html#value-functions

 Rob

On 16/09/2016 09:33, "Andy Seaborne"  wrote:



On 15/09/16 22:56, lookman sanni wrote:
> Hi all,
>
> I am trying to perform a filter in a SPARQL query, through the below code:
>
> FILTER ( abs(xsd:float(?tAmount1)) = abs(xsd:float(?tAmount2)) )
>
> The query is being parsed correctly, but I am not getting the expected
> result. Any clue why this would not convert and compare those amounts
> properly ? The amounts are formatted like this: "+8644,00".
>
> Thanks in advance for the help.
>

In XSD, floats have "." not "," for the decimal separator.

Andy







Re: Convert string to float in a SPARQL query

2016-09-16 Thread Andy Seaborne



On 15/09/16 22:56, lookman sanni wrote:

Hi all,

I am trying to perform a filter in a SPARQL query, through the below code:

FILTER ( abs(xsd:float(?tAmount1)) = abs(xsd:float(?tAmount2)) )

The query is being parsed correctly, but I am not getting the expected
result. Any clue why this would not convert and compare those amounts
properly ? The amounts are formatted like this: "+8644,00".

Thanks in advance for the help.



In XSD, floats have "." not "," for the decimal separator.

Andy


Re: Convert string to float in a SPARQL query

2016-09-16 Thread james anderson
good morning;

> On 2016-09-15, at 23:56, lookman sanni  wrote:
> 
> Hi all,
> 
> I am trying to perform a filter in a SPARQL query, through the below code:
> 
> FILTER ( abs(xsd:float(?tAmount1)) = abs(xsd:float(?tAmount2)) )
> 
> The query is being parsed correctly, but I am not getting the expected
> result. Any clue why this would not convert and compare those amounts
> properly ? The amounts are formatted like this: "+8644,00".
> 
> Thanks in advance for the help.

have you tried to use the query itself to diagnose the issue?
if you make it have it return the solution bindings for the cases which do not 
match your expectation, perhaps extended with converted values, you may see 
that there is some assumption embedded in your query which is not reflected in 
your data.

it is also possible the discrepancy between the result and your expectation 
arises somewhere else in the query.
if you are in a position to post it in its entirety, it might be possible to 
shed light on that.

best regards, from berlin
---
james anderson | ja...@dydra.com | http://dydra.com







Re: Convert string to float in a SPARQL query

2016-09-15 Thread lookman sanni
I am trying to convert some text values to numeric so that I can compare
their absolute values.

Hopefully it is clearer.
Le 16 sept. 2016 00:01, "A. Soroka"  a écrit :

> https://stackoverflow.com/help/mcve
>
> What data are you using? What is the complete action you are exercising?
> What results do you expect? What results do you get?
>
> ---
> A. Soroka
> The University of Virginia Library
>
> > On Sep 15, 2016, at 5:56 PM, lookman sanni  wrote:
> >
> > Hi all,
> >
> > I am trying to perform a filter in a SPARQL query, through the below
> code:
> >
> > FILTER ( abs(xsd:float(?tAmount1)) = abs(xsd:float(?tAmount2)) )
> >
> > The query is being parsed correctly, but I am not getting the expected
> > result. Any clue why this would not convert and compare those amounts
> > properly ? The amounts are formatted like this: "+8644,00".
> >
> > Thanks in advance for the help.
> >
> > --
> > Best Regards
> >
> > Lookman SANNI
>
>


Re: Convert string to float in a SPARQL query

2016-09-15 Thread A. Soroka
https://stackoverflow.com/help/mcve

What data are you using? What is the complete action you are exercising? What 
results do you expect? What results do you get?

---
A. Soroka
The University of Virginia Library

> On Sep 15, 2016, at 5:56 PM, lookman sanni  wrote:
> 
> Hi all,
> 
> I am trying to perform a filter in a SPARQL query, through the below code:
> 
> FILTER ( abs(xsd:float(?tAmount1)) = abs(xsd:float(?tAmount2)) )
> 
> The query is being parsed correctly, but I am not getting the expected
> result. Any clue why this would not convert and compare those amounts
> properly ? The amounts are formatted like this: "+8644,00".
> 
> Thanks in advance for the help.
> 
> -- 
> Best Regards
> 
> Lookman SANNI