simphony / simphony-osp

A framework that aims to achieve interoperability between software such as simulation engines, databases and data repositories using a knowledge graph as the common language.
https://simphony.readthedocs.io
Other
16 stars 12 forks source link

Use proper namespaces when exporting to RDF #630

Closed yoavnash closed 3 years ago

yoavnash commented 3 years ago

The function serialize_rdf_graph creates an RDF file whose namespaces are not defined (and therefore uc1, uc2, etc. are used instead), although they are defined in the configuration YAML file used to install the underlying ontology.

Exported file:

@prefix ns1: <http://emmo.info/emmo/middle/math#> .
@prefix ns2: <http://emmo.info/emmo/middle/metrology#> .

<http://www.osp-core.com/cuds#9bb7306e-13df-476d-a967-cdff5cb700e2> a <http://the-marketplace-project.eu/uc3#EMMO_adf671ea_6c5c_4276_9767_d3ae90d8b80b> ;
    ns2:EMMO_8ef3cd6d_ae58_4a8d_9fc0_ad8f49015cd0 <http://www.osp-core.com/cuds#cff90dae-cde9-429c-81e3-a11c31807263> .

<http://www.osp-core.com/cuds#cff90dae-cde9-429c-81e3-a11c31807263> a ns1:EMMO_18d180e4_5e3e_42f7_820c_e08951223486 ;
    ns1:EMMO_faf79f53_749d_40b2_807c_d34244c192f4 "1.94" ;
    ns2:INVERSE_OF_hasQuantityValue <http://www.osp-core.com/cuds#9bb7306e-13df-476d-a967-cdff5cb700e2> .

From emmo.yml:

identifier: emmo
[...]
namespaces:
    math: http://emmo.info/emmo/middle/math
    metrology: http://emmo.info/emmo/middle/metrology
    [...]
yoavnash commented 3 years ago

The following code shows that some namespaces are missing:

from osp.core.namespaces import math, metrology
from osp.core.utils import get_rdf_graph

g = get_rdf_graph()
for ns_prefix, namespace in g.namespaces():
    print(ns_prefix, namespace)

Output:

xml http://www.w3.org/XML/1998/namespace
rdf http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs http://www.w3.org/2000/01/rdf-schema#
xsd http://www.w3.org/2001/XMLSchema#
yoavnash commented 3 years ago

This line shows that there's namespace binding in the installation step, but it appears that some disappear somewhere along the way.

kysrpex commented 3 years ago

@yoavnash I assume this should not be hard to fix. I will have a look at it as soon as possible.