Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/_static/importexport_graph.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +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/zUI/SYKZaBjRiunpeK5M0iQjsY8g23iGywU29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MAybGl7tMoEOi7vq2XSdNXp5q2QpltezvrOSNOt+y0y+nKFrLboK5tDkME+4azEmIYzO5WwbpWtzVicPWZ/kpiuyJJEfvjx3Cql9IXU//mEz4TXWRzf8R1Tesi+P8vfUiItHVyuFkgRmBWrNKqU3apK2S0QNpUj8HVQtTbz5he4Kv72gN6jRhYavX/nj9vbdsGDERo2Eweud341pDmud9u2/KiXUimPsE2M50yBUFw1wt6XtCnfN/i9SRtdYqgJR/pjyDStBLOGpxsSN+zP85dRpqidv9ETffwb</diagram></mxfile>
Binary file added docs/_static/importexport_graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions docs/usage/ontologies/ontologies_included.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ domains of application, are listed below.
- [](#the-prov-ontology-prov-o)
\- Provenance information

- [](#simple-knowledge-organization-system-skos)
\- Knowledge organization systems

- [](#the-city-ontology)
\- Example ontology aimed at demonstrating the usage of SimPhoNy

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

## Simple Knowledge Organization System (SKOS)

```{eval-rst}
.. epigraph::

SKOS is an area of work developing specifications and standards to support
the use of knowledge organization systems (KOS) such as thesauri,
classification schemes, subject heading systems and taxonomies within the
framework of the Semantic Web.

-- `Introduction to SKOS <https://www.w3.org/2004/02/skos/intro>`_
```

To install [SKOS](https://www.w3.org/TR/2009/REC-skos-reference-20090818/), use

```sh
pico install skos
```

## The City ontology

The City ontology is a simple, example ontology included with SimPhoNy. It
Expand Down
114 changes: 113 additions & 1 deletion docs/usage/sessions/import_export.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
"id": "afd633af-b85c-449b-94c7-2ff99a097150",
"metadata": {},
"source": [
"If instead, you wish to export all the contents of a session, then pass the session object to be exported."
"If instead, you wish to export all the individuals in a session, then pass the session object to be exported."
]
},
{
Expand Down Expand Up @@ -372,6 +372,118 @@
"\n",
"semantic2dot(session)"
]
},
{
"cell_type": "markdown",
"id": "8b84a2b7-0bd9-4cf4-aa09-a1b2138ba43e",
"metadata": {},
"source": [
"## Interpretation of RDF files"
]
},
{
"cell_type": "markdown",
"id": "81211841-d564-4974-b0a7-eef4982fa3e4",
"metadata": {},
"source": [
"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",
"\n",
"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",
"\n",
"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",
"\n",
"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",
"\n",
"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",
"\n",
"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",
"\n",
"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",
"\n",
"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",
"\n",
"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."
]
},
{
"cell_type": "markdown",
"id": "97478c07-c469-4f64-b219-ff1d12e3b322",
"metadata": {},
"source": [
"<div class=\"admonition warning\">\n",
"<div class=\"admonition-title\" style=\"font-weight: bold\"><div style=\"display: inline-block\">Warning</div></div>\n",
" \n",
"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",
" \n",
"</div>"
]
},
{
"cell_type": "markdown",
"id": "29fbacc8-3c05-4f4c-a7e2-f8836c1c7535",
"metadata": {},
"source": [
"There are two keyword arguments that can be passed to the import and export functions to bypass these checks.\n",
"\n",
"- `all_triples`: When set to `True`, no exceptions will be raised for points (2)*, (3), (4), (5), (6). Warnings will still be emitted.\n",
"- `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."
]
},
{
"cell_type": "markdown",
"id": "e3208b1d-bc73-4a8c-a541-dd30f0a970f8",
"metadata": {},
"source": [
"<div class=\"admonition note\">\n",
"<div class=\"admonition-title\" style=\"font-weight: bold\"><div style=\"display: inline-block\">Note</div></div>\n",
" \n",
"\\* 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",
" \n",
"</div>"
]
},
{
"cell_type": "markdown",
"id": "b15e4a71-b146-45da-9b55-e7306725dba0",
"metadata": {},
"source": [
"<div class=\"admonition warning\">\n",
"<div class=\"admonition-title\" style=\"font-weight: bold\"><div style=\"display: inline-block\">Warning</div></div>\n",
" \n",
"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",
" \n",
"</div>\n"
]
},
{
"cell_type": "markdown",
"id": "00cbc181-d4b3-4c12-847e-5b3c97f88579",
"metadata": {},
"source": [
"Below there is sample RDF graph that helps understanding all the cases."
]
},
{
"cell_type": "markdown",
"id": "96b841a5-80fa-4a9b-9a07-44bde08c31c0",
"metadata": {},
"source": [
"![Sample RDF graph exemplifying cases where the constraints above apply](../../_static/importexport_graph.png)"
]
},
{
"cell_type": "markdown",
"id": "d8a3156b-c999-4097-8478-b003f6a357f6",
"metadata": {},
"source": [
"1. The triple (`example:Skaters`, `rdf:type`, `owl:Class`) would trigger this case, because it defines terminological knowledge.\n",
"2. The triple (`example:Marco`, `rdf:type`, `foaf:Person`) matches this case, because the namespace `foaf` is not installed.\n",
"3. The triple (`example:Klaus`, `foaf:knows`, `example:Lena`) raises an exception, because the namespace `foaf` is not installed.\n",
"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",
"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",
"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",
"7. The triple (`example:Something`, `example:predicate`, `example:Thing`) fits into this case."
]
}
],
"metadata": {
Expand Down