NREL / BuildingMOTIF

Building Metadata OnTology Interoperability Framework (BuildingMOTIF). For models, see https://models.open223.info/
https://buildingmotif.readthedocs.io/
Other
49 stars 7 forks source link

Naming parameters created from SHACL Rules #204

Closed lazlop closed 1 year ago

lazlop commented 1 year ago

Is there any way to reliably and helpfully name parameters that are created based on SHACL rules?

For example, I am creating a TimeseriesReference using the template in Brick-full.ttl

from buildingmotif.dataclasses import Library
brick = Library.load(ontology_graph="Brick-full.ttl")
from buildingmotif.namespaces import REF
ref_template = brick.get_template_by_name(REF.TimeseriesReference)

The ref_template will have the parameter name, then a randomly named parameter for the TimeseriesId (p12,p27,p3, etc.).

print(ref_template.parameters)
    {'name', 'p27'}
gtfierro commented 1 year ago

I'm not quite sure how to effectively approach that w/o requiring that the SHACL shapes have some extra annotation saying what the parameter should be called. Maybe we parse out rdfs:label or something similar, but it's not clear what the heuristic would be for determining the name

lazlop commented 1 year ago

That's a good point. I think having some rdfs:label would work well, even if the name is nonsense it would at least be consistent and would allow one to find the shape definition in the ontology. Another idea is to skolemize the ontology files before storing them, so the naming could be consistent. This would also allow one to find the shape in the ontology, but it wouldn't require an extra parameter to be added to the SHACL shapes. In the example above, the only reason I knew 'p27' required the TimeseriesID is because it was the only constraint other than the name in the template.

TShapinsky commented 1 year ago

Whatever the solution is. It seems like we should prioritize programmatic usage or these auto-generated templates. At the very least that means deterministic parameter names.

gtfierro commented 1 year ago

Sorry this took me so long to get to, but this should be addressed in https://github.com/NREL/BuildingMOTIF/pull/278 . We use sh:name to inform the parameters when they are generated