BHoM / RDF_Prototypes

Research project of the Cluster of Excellence "Integrative Computational Design and Construction for Architecture" (IntCDC) https://www.intcdc.uni-stuttgart.de/ **Project Name**: Knowledge Representation for Multi-Disciplinary Co-Design of Buildings. https://www.intcdc.uni-stuttgart.de/research/research-projects/rp-20/
GNU Lesser General Public License v3.0
9 stars 4 forks source link

Prefix issue:: ":" is used for both bhom native and non-native objects with different URIs #56

Open DiellzaElshani opened 1 year ago

DiellzaElshani commented 1 year ago

Description:

In bhOWL for each class or property we use its github URI.

for example:

In the ttl we define @ prefix : https://www.bhom.org/ . which means. whenever we see a colon ":" a bhom.org can be placed before the colon, and this would form a URI that pinpoints to the URI of the class.

which is wrong in two ways:

  1. we use : in front of custom classes too, which concatenated with bhom.org would give invalid URI, and it is inconsistent with the link above. image

  2. Also BHoM native objects have a wrong URI, because adding bhom.org in front of :BH.oM.Architecture.Elements.Room also does not give us (https://github.com/BHoM/BHoM/blob/main/Architecture_oM/Elements/Room.cs). And using something like: _ArchitectureoM/Elements/Room.cs to name the class woulnd work, becuase of RDF syntax using /.

image

Steps to reproduce:

I have two suggestions: 1) We use a unique URI for both, bhom classes and custom objects, so we don't have to differentiate between the prefix. We then add one more input to Tbox settings, to define a prefix for it. image

Eventually in future we can also publish have a way to publish a page with this ontology (like rdf https://www.w3.org/1999/02/22-rdf-syntax-ns# or bot https://w3c-lbd-cg.github.io/bot/ ). Which does not have to be public, but accessible from the ones who use the ontology.

2) We create a static page with bhom ontology, and we use bhom: prefix in front of each bhom native object. But for the Custom ones, we define this imaginary URI, which we can publish and share internally with the ones who will use the ontology. In this case we would use ":" only in front of NON-BHoM native objects.

I think the second option is a better solution.

Expected behaviour:

Test file(s):

DiellzaElshani commented 1 year ago

@danielhz's suggestion and comment:

The way we define classes with github URI works in term of identifying classes, but not according to the linked data principles. A good URL design is one that:

  1. Distinguish objects from documents. In this case you GET an class Bar, but you get a document of the Web page of the class Bar in the Github repository. It is better to use a distinct URL, for instance:

https://github.com/BHoM/BHoM/blob/main/Structure_oM/Elements/Bar.cs#class

or

https://bhom.org/ontology/Sttructure_oM/Bar

And then, this URL should not retrieve just a page, but a RDF document describing the class Bar.


I think that you should avoid conflicts between classes defined by other people. Maybe you can generate a service that is connected to BHoM where to store classes and predicates. So, if your BHoM code can generate a particular class Bar that is different from other people class Bar.

So, the generator can use this service as a parameter, maybe with a namespace to create classes and predicates. So you can generate URLs like this one:

http://ourontologyservice.org/saoYuBot9AhrooGhiemi/Bar

The to_rdf() should have the option to post the ontology to this service. Maybe, we can just use a Solid POD to manage ontologies and data.

DiellzaElshani commented 1 year ago

-I will add more explanation later.

Alongside the API URI for resources, we still would need a publicly published TTL version of all BHoM objects. This page needs to look like this: https://www.w3.org/1999/02/22-rdf-syntax-ns# where all classes, object properties and datatype properties are listed.

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .

@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@base   <www.bhom.org> .

<LINK TO THE WEBISTE WHERE THIS FILE IS LOCATED> rdf:type owl:Ontology;
                          dc:title "BHoM Ontology (bhOWL)"@en;
                          dc:description "The Buildings and Habitats object Model Ontology"@en.

#################################################################
#    Classes
#################################################################

### https://github.com/BHoM/BHoM/blob/main/Architecture_oM/Elements/Room.cs
:BH.oM.Architecture.Elements.Room rdf:type owl:Class;
        rdfs:subClassOf :BH.oM.Analytical.Elements.IRegion;
        rdfs:subClassOf :BH.oM.Base.BHoMObject;
        rdfs:label "Room"@en .

### https://github.com/BHoM/BHoM/blob/main/BHoM/Interface/IBHoMObject.cs
:BH.oM.Base.IBHoMObject rdf:type owl:Class;
        rdfs:subClassOf :BH.oM.Base.IObject;
        rdfs:label "IBHoMObject"@en .

        ...

Daniel also agrees on using the API documentation URIs. "You can use this URL for concept Bar: https://bhom.xyz/api/object.html#!?namespace=BH.oM.Structure.Elements&object=Bar

Moreover, the final goal is to provide also some RDF data when requesting that URLs. This can be done by using content-negotiation to provide an alternative RDF view, or embedding RDF in the HTML pages (e.g., with RDFa)."

DiellzaElshani commented 1 year ago

Using the API as URI doesn't work apparently, because of the & and =symbols on the URI. https://bhom.xyz/api/object.html#!?namespace=BH.oM.Architecture.Elements&object=Room

prefix bhom: <https://bhom.xyz/api/object.html#!?namespace=BH.oM.>
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

bhom:Architecture.Elements&object=Room   rdf:type    owl:Class.

Validation report: Unexpected "bhom:Architecture.Elements&object=Room "

image

So, @alelom could you please generate a ttl text with all bhom classes and post somewhere on BHoM Website, or github? I will edit it manually if needed. And, we can use the link from there then.

For the moment, what we can do first is:

1) introduce a bhom prefix (even though the URI won't actually work), with the current URIs and setup. 2) input a custom URI for non-bhom classes (custom, other C# classes, etc). (In future these data needs to be also published on that URI btw, but at this point we do not care about publishing it). 3) input a custom URI for instances, ABox.

I suggest, the workflow in grasshopper should look like:

read back

And here is a ttl exemplifying how it should look like:


@prefix : <http://www.Costum.com/> .
@prefix bhom:<https://bhom.xyz/bhOWL#>.
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@base   <http://www.Costum.com> .

<Costum.com> rdf:type owl:Ontology;
                          dc:title "Timber buulding Ontology"@en;
                          dc:description "This ontology helps to do this and that"@en.

#################################################################
#    Annotation Properties
#################################################################

###  http://purl.org/dc/elements/1.1/#description
<http://purl.org/dc/elements/1.1/#description> rdf:type owl:AnnotationProperty .
###  http://purl.org/dc/elements/1.1/#title
<http://purl.org/dc/elements/1.1/#title> rdf:type owl:AnnotationProperty .

#################################################################
#    Datatypes
#################################################################

<https://github.com/BHoM/RDF_Prototypes/blob/main/RDF_oM/Base64JsonSerialized.cs> rdf:type rdfs:Datatype ;
rdfs:label "Base64JsonSerialized"@en .

#################################################################
#    Classes
#################################################################

### http://www.Costum.com/Building
  :Building rdf:type owl:Class;
          rdfs:subClassOf bhom:Base.CustomObject;
          rdfs:label "Building"@en .

### https://github.com/BHoM/BHoM/blob/main/BHoM/Interface/IBHoMObject.cs
bhom:Base.IBHoMObject rdf:type owl:Class;
        rdfs:subClassOf bhom:Base.IObject;
        rdfs:label "IBHoMObject"@en .

### https://github.com/BHoM/BHoM/blob/main/BHoM/Interface/IObject.cs
bhom:Base.IObject rdf:type owl:Class;
        rdfs:label "IObject"@en .

### https://github.com/BHoM/BHoM/blob/main/BHoM/CustomObject.cs
bhom:Base.CustomObject rdf:type owl:Class;
        rdfs:subClassOf bhom:Base.BHoMObject;
        rdfs:label "CustomObject"@en .

### https://github.com/BHoM/BHoM/blob/main/BHoM/BHoMObject.cs
bhom:Base.BHoMObject rdf:type owl:Class;
        rdfs:subClassOf bhom:Base.IBHoMObject;
        rdfs:label "BHoMObject"@en .

### https://github.com/BHoM/BHoM/blob/main/Physical_oM/Elements/Column.cs
bhom:Physical.Elements.Column rdf:type owl:Class;
        rdfs:subClassOf bhom:Physical.Elements.IFramingElement;
        rdfs:subClassOf bhom:Base.BHoMObject;
        rdfs:label "Column"@en .

### https://github.com/BHoM/BHoM/blob/main/Physical_oM/Elements/IFramingElement.cs
bhom:Physical.Elements.IFramingElement rdf:type owl:Class;
        rdfs:subClassOf bhom:Physical.IPhysical;
        rdfs:subClassOf bhom:Dimensional.IElement1D;
        rdfs:subClassOf bhom:Dimensional.IElementM;
        rdfs:label "IFramingElement"@en .

### https://github.com/BHoM/BHoM/blob/main/Physical_oM/IPhysical.cs
bhom:Physical.IPhysical rdf:type owl:Class;
        rdfs:subClassOf bhom:Base.IBHoMObject;
        rdfs:label "IPhysical"@en .

### https://github.com/BHoM/BHoM/blob/main/Dimensional_oM/IElement1D.cs
bhom:Dimensional.IElement1D rdf:type owl:Class;
        rdfs:subClassOf bhom:Dimensional.IElement;
        rdfs:label "IElement1D"@en .

### https://github.com/BHoM/BHoM/blob/main/Dimensional_oM/IElement.cs
bhom:Dimensional.IElement rdf:type owl:Class;
        rdfs:subClassOf bhom:Base.IObject;
        rdfs:label "IElement"@en .

### https://github.com/BHoM/BHoM/blob/main/Dimensional_oM/IElementM.cs
bhom:Dimensional.IElementM rdf:type owl:Class;
        rdfs:subClassOf bhom:Base.IObject;
        rdfs:label "IElementM"@en .

### https://github.com/BHoM/BHoM/blob/main/Geometry_oM/Curve/ICurve.cs
bhom:Geometry.ICurve rdf:type owl:Class;
        rdfs:subClassOf bhom:Geometry.IGeometry;
        rdfs:subClassOf bhom:Dimensional.IElement1D;
        rdfs:label "ICurve"@en .

### https://github.com/BHoM/BHoM/blob/main/Geometry_oM/Interface/IGeometry.cs
bhom:Geometry.IGeometry rdf:type owl:Class;
        rdfs:subClassOf bhom:Base.IObject;
        rdfs:label "IGeometry"@en .

### https://github.com/BHoM/BHoM/blob/main/Geometry_oM/Curve/Polyline.cs
bhom:Geometry.Polyline rdf:type owl:Class;
        rdfs:subClassOf bhom:Geometry.ICurve;
        rdfs:label "Polyline"@en .

### https://github.com/BHoM/BHoM/blob/main/Geometry_oM/Vector/Point.cs
bhom:Geometry.Point rdf:type owl:Class;
        rdfs:subClassOf bhom:Geometry.IGeometry;
        rdfs:subClassOf bhom:Dimensional.IElement0D;
        rdfs:label "Point"@en .

### https://github.com/BHoM/BHoM/blob/main/Dimensional_oM/IElement0D.cs
bhom:Dimensional.IElement0D rdf:type owl:Class;
        rdfs:subClassOf bhom:Dimensional.IElement;
        rdfs:label "IElement0D"@en .

### https://github.com/BHoM/BHoM/blob/main/Physical_oM/FramingProperties/IFramingElementProperty.cs
bhom:Physical.FramingProperties.IFramingElementProperty rdf:type owl:Class;
        rdfs:subClassOf bhom:Base.IBHoMObject;
        rdfs:label "IFramingElementProperty"@en .

#################################################################
#    Object Properties
#################################################################

### https://github.com/BHoM/BHoM/blob/main/Physical_oM/Elements/Column.cs#L41
bhom:Physical.Elements.Column.Location rdf:type owl:ObjectProperty ;
rdfs:domain bhom:Physical.Elements.IFramingElement ;
rdfs:range bhom:Geometry.ICurve ;
rdfs:label "Location (BH.oM.Physical.Elements.Column.Location)"@en .

### https://github.com/BHoM/BHoM/blob/main/Geometry_oM/Curve/Polyline.cs#L38
bhom:Geometry.Polyline.ControlPoints rdf:type owl:ObjectProperty ;
rdfs:domain bhom:Geometry.Polyline ;
rdfs:range :rdf:Seq ;
rdfs:label "ControlPoints (BH.oM.Geometry.Polyline.ControlPoints)"@en .

### https://github.com/BHoM/BHoM/blob/main/Physical_oM/Elements/Column.cs#L42
bhom:Physical.Elements.Column.Property rdf:type owl:ObjectProperty ;
rdfs:domain bhom:Physical.Elements.IFramingElement ;
rdfs:range bhom:Physical.FramingProperties.IFramingElementProperty ;
rdfs:label "Property (bhom:Physical.Elements.Column.Property)"@en .

#################################################################
#    Data properties
#################################################################

### http://visualdataweb.org/Building#x
:Building.x rdf:type owl:DatatypeProperty ;
rdfs:domain :Building ;
rdfs:range xsd:double ;
rdfs:label "x"@en .

### http://visualdataweb.org/Type
:Type rdf:type owl:DatatypeProperty ;
rdfs:domain :Building ;
rdfs:range xsd:string ;
rdfs:label "Type"@en .

### https://github.com/BHoM/BHoM/blob/main/Geometry_oM/Vector/Point.cs#L37
bhom:Geometry.Point.X rdf:type owl:DatatypeProperty ;
rdfs:domain bhom:Geometry.Point ;
rdfs:range xsd:double ;
rdfs:label "X (BH.oM.Geometry.Point.X)"@en .

### https://github.com/BHoM/BHoM/blob/main/Geometry_oM/Vector/Point.cs#L40
bhom:Geometry.Point.Y rdf:type owl:DatatypeProperty ;
rdfs:domain bhom:Geometry.Point ;
rdfs:range xsd:double ;
rdfs:label "Y (BH.oM.Geometry.Point.Y)"@en .

### https://github.com/BHoM/BHoM/blob/main/Geometry_oM/Vector/Point.cs#L43
bhom:Geometry.Point.Z rdf:type owl:DatatypeProperty ;
rdfs:domain bhom:Geometry.Point ;
rdfs:range xsd:double ;
rdfs:label "Z (BH.oM.Geometry.Point.Z)"@en .

### https://github.com/BHoM/BHoM/blob/main/BHoM/BHoMObject.cs#L34
bhom:Base.BHoMObject.BHoM_Guid rdf:type owl:DatatypeProperty ;
rdfs:domain bhom:Base.BHoMObject ;
rdfs:range xsd:string ;
rdfs:label "BHoM_Guid (BH.oM.Base.BHoMObject.BHoM_Guid)"@en .

### https://github.com/BHoM/BHoM/blob/main/BHoM/BHoMObject.cs#L36
bhom:Base.BHoMObject.Name rdf:type owl:DatatypeProperty ;
rdfs:domain :BH.oM.Base.BHoMObject ;
rdfs:range xsd:string ;
rdfs:label "Name (BH.oM.Base.BHoMObject.Name)"@en .

### https://github.com/BHoM/BHoM/blob/main/BHoM/BHoMObject.cs#L42
bhom:Base.BHoMObject.CustomData rdf:type owl:DatatypeProperty ;
rdfs:domain bhom:Base.BHoMObject ;
rdfs:range <https://github.com/BHoM/RDF_Prototypes/blob/main/RDF_oM/Base64JsonSerialized.cs>;
rdfs:label "CustomData (BH.oM.Base.BHoMObject.CustomData)"@en .

#################################################################
#    Individuals
#################################################################

<https://www.uni-stuttgart.de/resources/Data/D938B9974B5087DA2A2405FC40CC66A89B92E3FFC1AC31B4B1A84785B8643AEF> rdf:type owl:NamedIndividual ,
        :Building ;
        :x "5"^^xsd:double;
        :Type "Building"^^xsd:string .

<https://www.uni-stuttgart.de/resources/Data/C85662131CB1A4513D0255F88B3E801E6433345CFBEAC0B94CE7C31215815E95> rdf:type owl:NamedIndividual ,
        bhom:Physical.Elements.Column ;
        bhom:Physical.Elements.Column.Location <http://customizefrom-ontologysettings.aboxsettings.individualsbaseaddress/1D83B9B8C9B4423A97D33B6F5F7649E6841F6113D2D74F04BB9B27C5D480CF93> ;
        bhom:Base.BHoMObject.BHoM_Guid "f6b01f5d-a925-4ab6-a6f5-67e30b8eb748"^^xsd:string;
        bhom:Base.BHoMObject.Name "MyColumn"^^xsd:string .

<https://www.uni-stuttgart.de/resources/Data/1D83B9B8C9B4423A97D33B6F5F7649E6841F6113D2D74F04BB9B27C5D480CF93> rdf:type owl:NamedIndividual ,
        bhom:Geometry.Polyline ;
        bhom:Geometry.Polyline.ControlPoints rdf:Seq ;
        rdf:_0 <https://www.uni-stuttgart.de/resources/Data/706710804BEE7BFD4E6F686EB9D06CF24E607B46F090F3AB7F3897D5D6A51C62> ;
        rdf:_1 <https://www.uni-stuttgart.de/resources/Data/D6B171A7D2F0698B6033D322F43BF38D2F2B8AE47D1CB4E5D889E2A633331C54>  .

<https://www.uni-stuttgart.de/resources/Data/706710804BEE7BFD4E6F686EB9D06CF24E607B46F090F3AB7F3897D5D6A51C62> rdf:type owl:NamedIndividual ,
        bhom:Geometry.Point ;
        bhom:Geometry.Point.X "35.1863354037267"^^xsd:double;
        bhom:Geometry.Point.Y "-21.1231884057971"^^xsd:double;
        bhom:Geometry.Point.Z "0"^^xsd:double .

<https://www.uni-stuttgart.de/resources/Data/D6B171A7D2F0698B6033D322F43BF38D2F2B8AE47D1CB4E5D889E2A633331C54> rdf:type owl:NamedIndividual ,
        bhom:Geometry.Point ;
        bhom:Geometry.Point.X "32.6811594202899"^^xsd:double;
        bhom:Geometry.Point.Y "-11.5579710144928"^^xsd:double;
        bhom:Geometry.Point.Z "0"^^xsd:double .
DiellzaElshani commented 1 year ago

When generating URI for properties, we use the number line of the code, where that is defined:

### https://github.com/BHoM/BHoM/blob/main/Geometry_oM/Vector/Point.cs#L37
:BH.oM.Geometry.Point.X rdf:type owl:DatatypeProperty ;

For custom objects we concatenate the name with the domain class:

### http://Custom.org/Building#Type
:Building.Type rdf:type owl:DatatypeProperty ;
rdfs:domain :Building ;
rdfs:range xsd:string ;
rdfs:label "Type"@en .

However, for non-bhom objects, we can consider that there is a URI that hosts all definitions. So, instead we need to get something like:

### http://Custom.org/Type
    :Type rdf:type owl:DatatypeProperty ;
                           rdfs:domain :Building ;
                            rdfs:range xsd:string ;
                             rdfs:label "Type"@en .

image