sage-org / sage-client

🦄 JS client for evaluating SPARQL queries against a SaGe server
MIT License
3 stars 5 forks source link

Number representation mismatch #2

Closed Rintarou closed 6 years ago

Rintarou commented 6 years ago

Although similar to this sage-jena issue and concerning roughly the same queries: aggregates/agg - [avg](), [min](), [max](), and [sum](), this version of the bug is one step removed.

when running any of the aforementioned query, we get those kind of results:

<?xml version="1.0" encoding="UTF-8"?>
<sparql xlmns="http://www.w3.org/2005/sparql-results#">
  <head>
    <variable name="s"/>
    <variable name="avg"/>
  </head>
  <results>
    <result>
      <binding name="s">
        <uri>http://www.example.org/mixed2</uri>
      </binding>
      <binding name="avg">
        <uri>0.2</uri>
      </binding>
    </result>
    <result>
      <binding name="s">
        <uri>http://www.example.org/mixed1</uri>
      </binding>
      <binding name="avg">
        <uri>1.6</uri>
      </binding>
    </result>
    <result>
      <binding name="s">
        <uri>http://www.example.org/ints</uri>
      </binding>
      <binding name="avg">
        <uri>2</uri>
      </binding>
    </result>
</results>
</sparql>

instead of those:

<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
  <head>
    <variable name="s"/>
    <variable name="avg"/>
  </head>
  <results>
    <result>
      <binding name="s">
        <uri>http://www.example.org/mixed1</uri>
      </binding>
      <binding name="avg">
        <literal datatype="http://www.w3.org/2001/XMLSchema#decimal">1.6</literal>
      </binding>
    </result>
    <result>
      <binding name="s">
        <uri>http://www.example.org/mixed2</uri>
      </binding>
      <binding name="avg">
        <literal datatype="http://www.w3.org/2001/XMLSchema#double">2.0E-1</literal>
      </binding>
    </result>
    <result>
      <binding name="s">
        <uri>http://www.example.org/ints</uri>
      </binding>
      <binding name="avg">
        <literal datatype="http://www.w3.org/2001/XMLSchema#decimal">2.0</literal>
      </binding>
    </result>
  </results>
</sparql>

The matter lies in the fact that numbers are not represented using scientific notation at all. This behavior is accentuated whith numbers that go in the thousands or more.

This bug affects a dozen of queries.

While fixing this query, watch out for the same issue linked at the top; namely using lowercase 'e' for powers of ten, rather than the expected uppercase 'e'.

corentinmrnn commented 6 years ago

Remaining number representation mismatches are common with jena and sage-jena, the others have been fixed