diff --git a/bindings/python/dataset.py b/bindings/python/dataset.py index 649433637..74bcb7850 100644 --- a/bindings/python/dataset.py +++ b/bindings/python/dataset.py @@ -27,7 +27,7 @@ # XXX TODO - Make a local cache of EMMO such that we only download it once TS_EMMO = Triplestore("rdflib") -TS_EMMO.parse("https://w3id.org/emmo/1.0.0-rc1") +TS_EMMO.parse("https://w3id.org/emmo/1.0.0-rc3") EMMO_VERSIONIRI = TS_EMMO.value("https://w3id.org/emmo", OWL.versionIRI) @@ -38,6 +38,15 @@ triplestore=TS_EMMO, ) +# XXX TODO: Switch to EMMO.hasDimension when this relation is in EMMO. +# Please don't change the IRI when adding it. +#Dimension = EMMO.Dimension +Dimension = "https://w3id.org/emmo#EMMO_b4c97fa0_d82c_406a_bda7_597d6e190654" +#hasDimension = EMMO.hasDimension +hasDimension = "https://w3id.org/emmo#EMMO_0a9ae0cb_526d_4377_9a11_63d1ce5b3499" +#hasScalarData = EMMO.hasScalarData +hasScalarData = "https://w3id.org/emmo#EMMO_e5a34647_a955_40bc_8d81_9b784f0ac527" + EMMO_TYPES = { "blob": "BinaryData", "bool": "BooleanData", @@ -133,7 +142,7 @@ def get_shape(ts, dimiri, dimensions=None, mappings=None, uri=None): label = str(obj) elif pred == EMMO.elucidation: descr = str(obj) - elif pred == RDF.type and obj not in (EMMO.Dimension,): + elif pred == RDF.type and obj not in (Dimension,): mapsto.append(obj) if not label: raise KBError("dimension has no prefLabel:", dimiri) @@ -160,7 +169,7 @@ def get_unit_symbol(iri): symbol = TS_EMMO.value(iri, EMMO.unitSymbol) if symbol: return str(symbol) - for r in TS_EMMO.restrictions(iri, EMMO.hasSymbolValue, type="value"): + for r in TS_EMMO.restrictions(iri, EMMO.unitSymbolValue, type="value"): symbol = r["value"] if symbol: return str(symbol) @@ -189,7 +198,7 @@ def get_unit_iri(unit): for r, _, o in ts.triples(predicate=OWL.hasValue): if ( ts.has(r, RDF.type, OWL.Restriction) and - ts.has(r, OWL.onProperty, EMMO.hasSymbolValue) + ts.has(r, OWL.onProperty, EMMO.unitSymbolValue) ): s = ts.value(predicate=RDFS.subClassOf, object=r) unit_cache[o.value] = s @@ -289,7 +298,7 @@ def addmap(uri, iri): triples.extend([ (prop_iri, RDFS.subClassOf, restriction_iri), (restriction_iri, RDF.type, OWL.Restriction), - (restriction_iri, OWL.onProperty, EMMO.hasScalarData), + (restriction_iri, OWL.onProperty, hasScalarData), (restriction_iri, OWL.someValuesFrom, EMMO[emmotype]), ]) else: @@ -304,13 +313,13 @@ def addmap(uri, iri): (prop_iri, RDFS.subClassOf, EMMO.Array), (prop_iri, RDFS.subClassOf, restriction_iri), (restriction_iri, RDF.type, OWL.Restriction), - (restriction_iri, OWL.onProperty, EMMO.hasDimension), + (restriction_iri, OWL.onProperty, hasDimension), ]) for i, dim in enumerate(prop.shape): dim_iri = f"{iri}#{prop.name}_dimension{i}" addmap(f"{meta.uri}#{dim}", dim_iri) triples.extend([ - (dim_iri, RDF.type, EMMO.Dimension), + (dim_iri, RDF.type, Dimension), (dim_iri, EMMO.hasSymbolValue, Literal(dim, datatype=XSD.string)), (dim_iri, EMMO.elucidation, en(dim_descr[dim])), @@ -448,9 +457,9 @@ def get_dataset( someval = po.get(OWL.someValuesFrom) if onprop == EMMO.hasMeasurementUnit: unit = get_unit_symbol(oncls) - elif onprop == EMMO.hasScalarData: + elif onprop == hasScalarData: emmotype = emmotypes[someval] - elif onprop == EMMO.hasDimension: + elif onprop == hasDimension: shape = get_shape( ts, onval, dimensions, mappings, uri ) diff --git a/bindings/python/tests/test_dataset1_save.py b/bindings/python/tests/test_dataset1_save.py index 5007b8c30..d0872e197 100644 --- a/bindings/python/tests/test_dataset1_save.py +++ b/bindings/python/tests/test_dataset1_save.py @@ -62,7 +62,7 @@ (FLUID.LJPotential, EMMO.isDescriptionFor, EMMO.MolecularEntity), (FLUID.TemperatureField, MAP.mapsTo, EMMO.ThermodynamicTemperature), (FLUID.ntimes, MAP.mapsTo, EMMO.Time), - (FLUID.npositions, MAP.mapsTo, EMMO.Position), + (FLUID.npositions, MAP.mapsTo, EMMO.PositionVector), ] #add_dataset(ts, chem.meta, base_iri=base_iri) add_dataset(ts, Fluid, iri=EX.FluidData, mappings=mappings) diff --git a/bindings/python/tests/test_dataset2_load.py b/bindings/python/tests/test_dataset2_load.py index 04ca0c0c7..fc94a58d7 100644 --- a/bindings/python/tests/test_dataset2_load.py +++ b/bindings/python/tests/test_dataset2_load.py @@ -44,7 +44,7 @@ (FLUID.LJPotential, EMMO.isDescriptionFor, EMMO.MolecularEntity), (FLUID.TemperatureField, MAP.mapsTo, EMMO.ThermodynamicTemperature), (FLUID.ntimes, MAP.mapsTo, EMMO.Time), - (FLUID.npositions, MAP.mapsTo, EMMO.Position), + (FLUID.npositions, MAP.mapsTo, EMMO.PositionVector), }