Skip to content

Commit cb0c6be

Browse files
authored
Document improvements to import and export functions (#232)
* Document improvements to import and export functions. * Improve documentation of how RDF files are interpreted. * Add SKOS to included ontologies.
1 parent 1b0cd88 commit cb0c6be

File tree

4 files changed

+136
-1
lines changed

4 files changed

+136
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<mxfile host="app.diagrams.net" modified="2022-09-15T15:00:07.279Z" agent="5.0 (X11)" etag="ol6Mp0m8xKfYCrX_vnMN" version="20.3.0" type="device"><diagram id="OcSXqWj7B0u8RQeyNCZC" name="Seite-1">7V1rc+I4Fv01VM1+iMuS/MAfE7qZ6druqt7J1PTufHNAgDvGYm3RQP/6kbAN6GHsOH4lDKlKd2Qs7HvuPTq6uhYjNFnvf439zeoLmeNwBM35foQ+jCC00Jj95g2HtMG1rLRhGQfztAmcGx6DnzhrNLPWbTDHifBGSkhIg43YOCNRhGdUaPPjmOzEty1IKH7qxl9ipeFx5odq67dgTldp6xi65/bfcLBc5Z8MHC89svbzN2d3kqz8OdldNKGPIzSJCaHp/9b7CQ657XK7pOdNC46eLizGEa1ywnZphf/7+fzXf34l38J4P7f8Pxd3MO3lhx9usxseQSdk/T0sCOuW2zUk8fGI8/8tv9SHEUSm6bHXZZOz5P/ivb/ecMvdT2McPG3jZd4bu6y0w/SNmUXoITdzTLbRHPMrBezwbhVQ/LjxZ/zojvkVa1vRdZgdzq4ZxxTvC40BTiZmronJGtP4wN6Sn+BmqGRuCa3s790ZZJAjt7oAGGVtfuZXy1PXZ9Oz/2TWfwESqCUk/h3622SoMNgiCqh3FKyWUPiMI3+oILDLHxgKjoJC5sXmL1XgsCYcEBWOfcI+9D6hcRAVEdO/rqBh9hESFtSAYWrAgG2B4SpgQNQMEkFE8RLHg4UCOEPDYlyLnjzPNPllyijMAsru7H4SUCa7oqHSkxQQ0FFBGHdJTrkyvQwI+zYCAo2HFhAAKGCkQ+0NjBTQHRwaOhErWQlH83s+L2N/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ZNDIpf/HhGhsrHymJW30Oi21u9bG/sKS1E2MAybGl7tMoEOi7vq2XSdNXp5q2QpltezvrOSNOt+y0y+nKFrLboK5tDkME+4azEmIYzO5WwbpWtzVicPWZ/kpiuyJJEfvjx3Cql9IXU//mEz4TXWRzf8R1Tesi+P8vfUiItHVyuFkgRmBWrNKqU3apK2S0QNpUj8HVQtTbz5he4Kv72gN6jRhYavX/nj9vbdsGDERo2Eweud341pDmud9u2/KiXUimPsE2M50yBUFw1wt6XtCnfN/i9SRtdYqgJR/pjyDStBLOGpxsSN+zP85dRpqidv9ETffwb</diagram></mxfile>
346 KB
Loading

docs/usage/ontologies/ontologies_included.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ domains of application, are listed below.
2525
- [](#the-prov-ontology-prov-o)
2626
\- Provenance information
2727

28+
- [](#simple-knowledge-organization-system-skos)
29+
\- Knowledge organization systems
30+
2831
- [](#the-city-ontology)
2932
\- Example ontology aimed at demonstrating the usage of SimPhoNy
3033

@@ -187,6 +190,25 @@ To install the [PROV-O ontology](https://www.w3.org/TR/prov-o/), use
187190
pico install prov
188191
```
189192

193+
## Simple Knowledge Organization System (SKOS)
194+
195+
```{eval-rst}
196+
.. epigraph::
197+
198+
SKOS is an area of work developing specifications and standards to support
199+
the use of knowledge organization systems (KOS) such as thesauri,
200+
classification schemes, subject heading systems and taxonomies within the
201+
framework of the Semantic Web.
202+
203+
-- `Introduction to SKOS <https://www.w3.org/2004/02/skos/intro>`_
204+
```
205+
206+
To install [SKOS](https://www.w3.org/TR/2009/REC-skos-reference-20090818/), use
207+
208+
```sh
209+
pico install skos
210+
```
211+
190212
## The City ontology
191213

192214
The City ontology is a simple, example ontology included with SimPhoNy. It

docs/usage/sessions/import_export.ipynb

Lines changed: 113 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
"id": "afd633af-b85c-449b-94c7-2ff99a097150",
177177
"metadata": {},
178178
"source": [
179-
"If instead, you wish to export all the contents of a session, then pass the session object to be exported."
179+
"If instead, you wish to export all the individuals in a session, then pass the session object to be exported."
180180
]
181181
},
182182
{
@@ -372,6 +372,118 @@
372372
"\n",
373373
"semantic2dot(session)"
374374
]
375+
},
376+
{
377+
"cell_type": "markdown",
378+
"id": "8b84a2b7-0bd9-4cf4-aa09-a1b2138ba43e",
379+
"metadata": {},
380+
"source": [
381+
"## Interpretation of RDF files"
382+
]
383+
},
384+
{
385+
"cell_type": "markdown",
386+
"id": "81211841-d564-4974-b0a7-eef4982fa3e4",
387+
"metadata": {},
388+
"source": [
389+
"The [ontology languages supported by SimPhoNy](../ontologies/supported_formats.md) can be serialized as RDF files, but the [RDF standard](https://www.w3.org/TR/rdf-concepts/) can store data that does not necessarily have anything to do with an ontology. Moreover, as described in the [introduction to sessions](introduction.ipynb), SimPhoNy sessions have been designed to exlusively store assertional knowledge (ontology individuals). \n",
390+
"\n",
391+
"Due to these factors, SimPhoNy enforces a few constraints when importing and exporting individuals from/to RDF files, that can, however, **also be disabled if desired**.\n",
392+
"\n",
393+
"1. No terminological knowledge can be present in the file. Any RDF triple with predicate `rdf:type` and one of `owl:Class`, `rdfs:Class`, `owl:AnnotationProperty`, `rdf:Property`, `owl:DatatypeProperty`, `owl:ObjectProperty`, `owl:Restriction` as object raises an exception.\n",
394+
"\n",
395+
"2. The subjects of any RDF triple with predicate `rdf:type` and an IRI not listed above as object are considered to be the identifiers of ontology individuals. Therefore, SymPhoNy will look into its installed ontologies for a class matching the object of the triple. If this lookup fails, an exception is raised. This behavior is meant to prevent you from making the mistake of importing data for which you have not installed the corresponding ontology.\n",
396+
"\n",
397+
"3. If an RDF triple where the subject has been succesfully identified as an ontology individual has a predicate different from `rdf:type` that cannot be recognized as an annotation, relationship nor an attribute, an exception will be raised.\n",
398+
"\n",
399+
"4. If an RDF triple where the subject has been succesfully identified as an ontology individual has a predicate that can be recognized as a relationship, but has an object that cannot be recognized as an ontology individual (for example, because no `rdf:type` has been defined for it), then an exception will be raised.\n",
400+
"\n",
401+
"5. If an RDF triple where the subject has been succesfully identified as an ontology individual has a predicate that can be recognized as a relationship, but has a literal as an object, an exception will be raised.\n",
402+
"\n",
403+
"6. If an RDF triple where the subject has been succesfully identified as an ontology individual has a predicate that can be recognized as an attribute, but has a IRI as an object, an exception will be raised.\n",
404+
"\n",
405+
"7. Any triples whose subject cannot be identified as terminological knowledge, as ontology individuals, or for which (2) does not apply are **not imported**. No warning nor exception of any kind is raised for such triples."
406+
]
407+
},
408+
{
409+
"cell_type": "markdown",
410+
"id": "97478c07-c469-4f64-b219-ff1d12e3b322",
411+
"metadata": {},
412+
"source": [
413+
"<div class=\"admonition warning\">\n",
414+
"<div class=\"admonition-title\" style=\"font-weight: bold\"><div style=\"display: inline-block\">Warning</div></div>\n",
415+
" \n",
416+
"Point (7) implies that using the default options, you can lose data that was originally in the source, **without** warnings nor errors to notify you about it. Keep reading to learn how to prevent it. \n",
417+
" \n",
418+
"</div>"
419+
]
420+
},
421+
{
422+
"cell_type": "markdown",
423+
"id": "29fbacc8-3c05-4f4c-a7e2-f8836c1c7535",
424+
"metadata": {},
425+
"source": [
426+
"There are two keyword arguments that can be passed to the import and export functions to bypass these checks.\n",
427+
"\n",
428+
"- `all_triples`: When set to `True`, no exceptions will be raised for points (2)*, (3), (4), (5), (6). Warnings will still be emitted.\n",
429+
"- `all_statements`: When set to `True`, none of the points above apply. All RDF triples are imported, and **no information is lost**. No warnings are emitted."
430+
]
431+
},
432+
{
433+
"cell_type": "markdown",
434+
"id": "e3208b1d-bc73-4a8c-a541-dd30f0a970f8",
435+
"metadata": {},
436+
"source": [
437+
"<div class=\"admonition note\">\n",
438+
"<div class=\"admonition-title\" style=\"font-weight: bold\"><div style=\"display: inline-block\">Note</div></div>\n",
439+
" \n",
440+
"\\* To be recognized as an ontology individual, at least one of the types of the subject need to be defined in the [installed ontologies](../ontologies/pico.md). If you use `all_triples=True` when none of the types are defined in the installed ontologies, then (7) applies to such subject (its information is lost).\n",
441+
" \n",
442+
"</div>"
443+
]
444+
},
445+
{
446+
"cell_type": "markdown",
447+
"id": "b15e4a71-b146-45da-9b55-e7306725dba0",
448+
"metadata": {},
449+
"source": [
450+
"<div class=\"admonition warning\">\n",
451+
"<div class=\"admonition-title\" style=\"font-weight: bold\"><div style=\"display: inline-block\">Warning</div></div>\n",
452+
" \n",
453+
"Be careful when using `all_triples` and especially, when using `all_statements`. SimPhoNy's sessions have been designed to work only with ontology individuals. If you use `all_statements=True`, then also classes, relationships, annotations and attributes will be imported to the session, but as SimPhoNy is not ready to deal with this situation, this may lead to errors.\n",
454+
" \n",
455+
"</div>\n"
456+
]
457+
},
458+
{
459+
"cell_type": "markdown",
460+
"id": "00cbc181-d4b3-4c12-847e-5b3c97f88579",
461+
"metadata": {},
462+
"source": [
463+
"Below there is sample RDF graph that helps understanding all the cases."
464+
]
465+
},
466+
{
467+
"cell_type": "markdown",
468+
"id": "96b841a5-80fa-4a9b-9a07-44bde08c31c0",
469+
"metadata": {},
470+
"source": [
471+
"![Sample RDF graph exemplifying cases where the constraints above apply](../../_static/importexport_graph.png)"
472+
]
473+
},
474+
{
475+
"cell_type": "markdown",
476+
"id": "d8a3156b-c999-4097-8478-b003f6a357f6",
477+
"metadata": {},
478+
"source": [
479+
"1. The triple (`example:Skaters`, `rdf:type`, `owl:Class`) would trigger this case, because it defines terminological knowledge.\n",
480+
"2. The triple (`example:Marco`, `rdf:type`, `foaf:Person`) matches this case, because the namespace `foaf` is not installed.\n",
481+
"3. The triple (`example:Klaus`, `foaf:knows`, `example:Lena`) raises an exception, because the namespace `foaf` is not installed.\n",
482+
"4. The triple (`example:Freiburg`, `city:hasInhabitant`, `example:Rob`) triggers this case, because `example:Rob` does not have any type assigned and therefore, it is not identified as an ontology individual.\n",
483+
"5. The triple (`example:Freiburg`, `city:hasWorker`, `Lena (xsd:string)`) matches this case, as \"has worker\" is a relationship, but the object is a literal.\n",
484+
"6. The triple (`example:Freiburg`, `city:coordinates`, `<geo:47.995,7.85>`) raises an exception, because \"coordinates\" is an attribute, but the object is an IRI.\n",
485+
"7. The triple (`example:Something`, `example:predicate`, `example:Thing`) fits into this case."
486+
]
375487
}
376488
],
377489
"metadata": {

0 commit comments

Comments
 (0)