qudt / qudt-public-repo

QUDT -Quantities, Units, Dimensions and dataTypes - public repository
Other
114 stars 71 forks source link

Draft: Add triples for numeric values in xsd:double and xsd:decimal #869

Closed fkleedorfer closed 6 months ago

fkleedorfer commented 7 months ago

This allows for using scientific notation, which provides a better developer experience. Equivalence between the values should be checked via SHACL constraints.

fkleedorfer commented 7 months ago

So far, the original triples have not be removed, so there may be duplicates.

fkleedorfer commented 7 months ago

I just noticed that this is based on the release data, not the latest state of the main branch. Will fix that asap

EDIT: fixed it

fkleedorfer commented 7 months ago

@steveraysteveray how do you want to remove the original triples?

a) I can generate a list of triples to be deleted b) I can write an update query that deletes the triples

Or maybe you have another way using your RDF IDE?

steveraysteveray commented 7 months ago

An update query would be great. Thanks for your help.

steveraysteveray commented 7 months ago

By the way, we quickly did a test query on your files as follows. It seems to work fine. We first checked that every xsd:double conversionMultiplier indeed had an xsd:decimal equivalent. Please go ahead and do the cleanups using your preferred approach.

DELETE {?u qudt:conversionMultiplier ?m .}
WHERE {
?u a qudt:Unit .
?u qudt:conversionMultiplier ?m .
BIND (DATATYPE(?m) AS ?mT) .
FILTER (?mT = xsd:double) .
}
fkleedorfer commented 6 months ago

Here are the queries for deleting the spurious properties:

https://gist.github.com/fkleedorfer/90d8b2b0720f3154bfc367b06e422e65

... to be applied before adding the triples in the PR

fkleedorfer commented 6 months ago

I'll see if I can adapt the SHACL constraint that checks them for equality from #821

steveraysteveray commented 6 months ago

Great! In the end I used variants of the following query to do the cleanup (Note the various commented-out lines). It can also be used with a FILTER != line to test for equality. We found that the SPARQL engine in TopBraid doesn't look any deeper than 16 digits when comparing an xsd:double to an xsd:decimal.

#SELECT (COUNT (DISTINCT ?u) AS ?count)
#DELETE {?u qudt:standardUncertainty ?m .}
SELECT *
WHERE {
?u a qudt:ConstantValue .
#?u qudt:standardUncertainty ?m .
#BIND (DATATYPE(?m) AS ?mT) .
#FILTER (?mT = xsd:double) .
?u qudt:standardUncertainty ?n .
BIND (DATATYPE(?n) AS ?nT) .
FILTER (?nT = xsd:decimal) .
?u qudt:standardUncertaintySN ?s .
BIND (DATATYPE(?s) AS ?sT) .
}