Skip to content

Commit

Permalink
Add Ontology BB examples
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-metalinkage committed Jan 8, 2025
1 parent acfb5f0 commit c82d6e8
Show file tree
Hide file tree
Showing 9 changed files with 245 additions and 2 deletions.
10 changes: 8 additions & 2 deletions _sources/exercise0/description.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ The tutorial will introduce these in a step-wise fashion - feel free to skip ahe
### Steps
1. Read the [Overview documentation](https://ogcincubator.github.io/bblocks-docs) and answer the following questions to guide your discovery process:
- How do the underlying [principles](https://ogcincubator.github.io/bblocks-docs/overview/principles) relate to improvement of specifications in your domain? Which best reflect the needs and understandings of your community to improve interoperability?
- What [types of building blocks](https://ogcincubator.github.io/bblocks-docs/overview/types) do you need to create
- What [types of building blocks](https://ogcincubator.github.io/bblocks-docs/overview/types) do you need to create? (e.g. schemas, APIs, ontologies etc?)
- What types of resources are you starting with?
- What [registers](https://ogcincubator.github.io/bblocks-docs/overview/registers) contain Building Blocks you can reuse?
- What technologies do you want to explore (e.g. JSON schema, JSON-LD, SHACL)
1. View the online "build" and "repository" forms of a Building Block register and learn to navigate between the two. [Watch]()
1. Learn [how to build](https://ogcincubator.github.io/bblocks-docs/build/local) Building Blocks for reuse from source components.
- note if you cannot run locally you can rely on [github automation](https://ogcincubator.github.io/bblocks-docs/build/github) on your own online fork of this tutorial.

### Schema or model?

Schemas express data models in a specific structure - Building Blocks can combine or separate these different aspects:
- Exercises 1-8 show how JSON schemas can be modularised and semantically annotated.
- Exercise 9 shows an ontology-only based building block with no defined schema that can be reused by multiple alternative schemas.
- Exercise 10 shows how an ontology may be constrained for use in a particular context, to document assumptions that may be relevant, for example a subset expressible in a particular schema.


24 changes: 24 additions & 0 deletions _sources/exercise9/bblock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "metaschema.yaml",
"name": "9 - Schema-agnostic (Semantic) Building Block",
"highlighted": true,
"abstract": "A building block defining a building block for a data model described in ontology standards OWL and SHACL. Such a building block allows logical constraints to be inherited by multiple implementation schemas using semantic annotations (such as JSON-LD)",
"status": "under-development",
"dateTimeAddition": "2023-04-05T00:00:00Z",
"itemClass": "model",
"register": "building-blocks-tutorial",
"version": "0.1",
"dateOfLastChange": "2023-04-05",
"ontology": "ontology.ttl",
"sources": [
{
"title": "Sample source document",
"link": "https://example.com/sources/1"
}
],
"maturity": "mature",
"scope": "unstable",
"tags": ["building-blocks-tutorial",
"templates"
]
}
14 changes: 14 additions & 0 deletions _sources/exercise9/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Exercise 4

Goal: Define a Building Block for a semantic data model

This approach is appropriate where a given schema is one of many possible schemas for the same underlying semantic model, and allows defining the model and logical constraints independently, with re-usable validation rules and unit testing advantages.

### Steps
- uncomment line
- examine file "ontology.ttl"
- run build
- run viewer
- navigate to "Exercise 9"/Ontology and examine classes
- view validation results on "about tab"
- view validation results at [Validation Report](validation) or [build-local/...](/register/build-local/tests/bbr/template/exercise3/_report.json)
12 changes: 12 additions & 0 deletions _sources/exercise9/examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
$schema: https://raw.githubusercontent.com/opengeospatial/bblocks-postprocess/refs/heads/master/ogc/bblocks/schemas/examples.schema.yaml
## Prefixes for examples
prefixes:
mynamespace: http://example.org/ns1/
## List of examples
examples:
- title: Example

snippets:
- language: ttl
ref: examples/example.ttl

13 changes: 13 additions & 0 deletions _sources/exercise9/examples/example.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix : <https://w3id.org/example#> .
@prefix eg: <https://w3id.org/example-data#> .

eg:Fred
a :Researcher ;
:partOf eg:GnomesInc ;
rdfs:label "Fred the Gardener" .

eg:GnomesInc
a :Organization ;
rdfs:label "Gnomes Inc. Gardeners to the Stars" .
143 changes: 143 additions & 0 deletions _sources/exercise9/ontology.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
@prefix : <https://w3id.org/example#> .
@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#> .
@base <https://w3id.org/example> .

<https://w3id.org/example> rdf:type owl:Ontology ;
owl:versionIRI <https://w3id.org/example/1.0.0> ;
<http://purl.org/dc/elements/1.1/abstract> "An example vocabulary designed to illustrate how to publish vocabularies on the Web following the FAIR principles"@en ;
<http://purl.org/dc/elements/1.1/description> "This is an example ontology to illustrate some of the annotations that should be included"@en ;
<http://purl.org/dc/elements/1.1/title> "The example ontology"@en ;
<http://purl.org/dc/terms/created> "February 4th, 2020"@en ;
<http://purl.org/dc/terms/creator> "Daniel Garijo"@en ,
"Maria Poveda-Villalon"@en ;
<http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by/2.0/> ;
<http://purl.org/vocab/vann/preferredNamespacePrefix> "exo"@en ;
<http://purl.org/vocab/vann/preferredNamespaceUri> "https://w3id.org/example" ;
<http://schema.org/citation> "Cite this vocabulary as: Garijo, D. and Poveda-Villalon, M. The example ontology 1.0.0."@en ;
rdfs:comment "An example vocabulary designed to illustrate how to publish vocabularies on the Web following the FAIR principles. This vocabulary describes two simple classes with 2 properties and a data property."@en ;
owl:versionInfo "1.0.0"@en .

#################################################################
# Annotation properties
#################################################################

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


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


### 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/publisher
<http://purl.org/dc/elements/1.1/publisher> rdf:type owl:AnnotationProperty .


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


### http://purl.org/dc/terms/created
<http://purl.org/dc/terms/created> rdf:type owl:AnnotationProperty .


### http://purl.org/dc/terms/creator
<http://purl.org/dc/terms/creator> rdf:type owl:AnnotationProperty .


### http://purl.org/dc/terms/license
<http://purl.org/dc/terms/license> rdf:type owl:AnnotationProperty .


### http://purl.org/vocab/vann/example
<http://purl.org/vocab/vann/example> rdf:type owl:AnnotationProperty .


### http://purl.org/vocab/vann/preferredNamespacePrefix
<http://purl.org/vocab/vann/preferredNamespacePrefix> rdf:type owl:AnnotationProperty .


### http://purl.org/vocab/vann/preferredNamespaceUri
<http://purl.org/vocab/vann/preferredNamespaceUri> rdf:type owl:AnnotationProperty .


### http://schema.org/author
<http://schema.org/author> rdf:type owl:AnnotationProperty .


### http://schema.org/citation
<http://schema.org/citation> rdf:type owl:AnnotationProperty .


### http://www.linkedmodel.org/schema/vaem#rationale
<http://www.linkedmodel.org/schema/vaem#rationale> rdf:type owl:AnnotationProperty .


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

### http://www.w3.org/2001/XMLSchema#date
xsd:date rdf:type rdfs:Datatype .


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

### https://w3id.org/example#hasMember
:hasMember rdf:type owl:ObjectProperty ;
rdfs:domain :Organization ;
rdfs:range :Researcher ;
rdfs:comment "This example property indicates that an Organization has a Researcher as member"@en ;
rdfs:label "has member"@en .


### https://w3id.org/example#partOf
:partOf rdf:type owl:ObjectProperty ;
rdfs:domain :Researcher ;
rdfs:range :Organization ;
rdfs:comment "This property links instances from Researcher to Organization"@en ;
rdfs:label "part of"@en .


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

### https://w3id.org/example#foundedIn
:foundedIn rdf:type owl:DatatypeProperty ;
rdfs:domain :Organization ;
rdfs:range xsd:date ;
rdfs:comment "Date when an organization was founded"@en ;
rdfs:label "founded in"@en .


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

### https://w3id.org/example#Organization
:Organization rdf:type owl:Class ;
<http://purl.org/vocab/vann/example> "University of Southern California"@en ;
rdfs:comment "An organized body of people with a particular purpose, especially a business, society, association, etc."@en ;
rdfs:label "Organization"@en .


### https://w3id.org/example#Researcher
:Researcher rdf:type owl:Class ;
<http://purl.org/vocab/vann/example> "An example using the Researcher class, e.g., Bob is a professor at the University of Southern California."@en ;
<http://www.linkedmodel.org/schema/vaem#rationale> "The reason why this concept was added to the ontology. This could reflect some agreement or use cases that may need to be reflected here. For example: The concept Researcher was added to the ontology to represent those authors of scientific publications that belong to a public institution."@en ;
rdfs:comment "A definition of your class. For example, A researcher is a person who publishes scientific papers, writes research proposals and mentors students"@en ;
rdfs:label "Researcher"@en .


### Generated by the OWL API (version 5.1.14) https://github.com/owlcs/owlapi/
15 changes: 15 additions & 0 deletions _sources/exercise9/rules.shacl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix : <https://w3id.org/example#> .
@base <https://www.ogc.org/rules/template/> .

<#testValues>
a sh:NodeShape ;
sh:targetClass :Researcher ;
sh:message "Researchers must belong to at least one named Organization" ;
sh:property [ sh:path :partOf ;
sh:class :Organization ;
sh:minCount 1 ]
.
5 changes: 5 additions & 0 deletions _sources/exercise9/tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Tests

These tests are not show in the examples for the building block but provide a way to test the building block.

tests ending with -fail.(extension) must fail as expected for validation to pass.
11 changes: 11 additions & 0 deletions _sources/exercise9/tests/example-fail.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix : <https://w3id.org/example#> .
@prefix eg: <https://w3id.org/example-data#> .

eg:Fred
a :Researcher ;
rdfs:label "Fred the Gardener" .

eg:GnomesInc
rdfs:label "Gnomes Inc. Gardeners to the Stars" .

0 comments on commit c82d6e8

Please sign in to comment.