Skip to content

Tutrtle decimals not trimmed and lexically inconsistent :( #70

Description

@henrieglesorotos

HELLO FRIENDS!

We've migrated to Maplib 0.20.26, and we see different forms of the same xsd:decimal value depending on the output format, eg:

N-Triples:
"12.34"^^http://www.w3.org/2001/XMLSchema#decimal
"798"^^http://www.w3.org/2001/XMLSchema#decimalTurtle:
"12.340000000000"^^xsd:decimal
"798.000000000000"^^xsd:decimal

Turtle serialisation is preserving the Decimal(38, 12) whilst n-triples is trimming. Whilst the values are identical, lexically they are different, impacting idempotent additions, deletes etc. We want a nice clean set of triples :(

Replcate here -

from decimal import Decimal

import polars as pl
from maplib import Model

template = """
@prefix ex: <http://example.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

ex:DecimalTemplate [xsd:decimal ?value] :: {
    ottr:Triple(ex:subject, ex:amount, ?value)
} .
"""

data = pl.DataFrame(
    {"value": [Decimal("12.3400"), Decimal("798.0")]},
    schema={"value": pl.Decimal(38, 12)},
)

model = Model()
model.add_template(template)
model.map("http://example.org/DecimalTemplate", data)

print(model.writes(format="ntriples"))
print(model.writes(format="turtle"))

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions