Skip to content

Commit

Permalink
skos section
Browse files Browse the repository at this point in the history
  • Loading branch information
jbarrasa committed Sep 29, 2020
1 parent 8d1dde9 commit d9fba77
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 4 deletions.
Binary file added docs/modules/ROOT/images/skos_fetch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/modules/ROOT/images/skos_inline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 82 additions & 2 deletions docs/modules/ROOT/pages/importing-ontologies.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
= Importing Ontologies
:page-pagination:


Ontologies are serialised as RDF, so they can be imported using plain `n10s.rdf.import.fetch` but the `n10s.onto.import.fetch` method will give us a higher level of control over how an RDFS or OWL ontology is imported into Neo4j.
It's important to note that this procedure exclusively imports the following:

Expand Down Expand Up @@ -66,4 +65,85 @@ and then we extend it with some additiona statements (triples) passed as text to
CALL n10s.onto.import.inline("<http://www.nsmntx.org/2019/10/clothingMaterials#Leather> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://www.nsmntx.org/customCats#AnimalBasedMaterial2> .","N-Triples");
----

Check xref:reference.adoc[Reference] for a complete list of available parameters.
Check xref:reference.adoc[Reference] for a complete list of available parameters.


== Importing SKOS concept schemes

https://www.w3.org/TR/skos-reference/[SKOS] (Simple Knowledge Organization System) provides a model for expressing the basic structure and
content of concept schemes such as thesauri, classification schemes, subject heading lists,
taxonomies, folksonomies, and other similar types of controlled vocabulary. Neosemantics also provides
methods (`skos.import`) to import SKOS concept schemes.

These methods follow the same structure and implement the same behavior as the ones for importing ontologies
here is an example of inline importing a skos fragment of a taxonomy:

[source,cypher]
----
call n10s.skos.import.inline('
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ex: <http://www.example.com/> .
ex:cat rdf:type skos:Concept;
skos:prefLabel "cat"@en;
skos:prefLabel "Katze"@de;
skos:altLabel "kitten"@en;
skos:narrower ex:wildcat;
skos:broader ex:animal .
ex:wildcat rdf:type skos:Concept;
skos:prefLabel "wildcat"@en;
skos:broader ex:cat.
ex:animal rdf:type skos:Concept;
skos:prefLabel "animal"@en .
','Turtle')
----

producing the following summary of execution:

[source,cypher]
----
╒═══════════════════╤═══════════════╤═══════════════╤════════════╤═══════════╤════════════════════════════╕
│"terminationStatus"│"triplesLoaded"│"triplesParsed"│"namespaces"│"extraInfo"│"callParams" │
╞═══════════════════╪═══════════════╪═══════════════╪════════════╪═══════════╪════════════════════════════╡
│"OK" │11 │11 │null │"" │{"handleVocabUris":"IGNORE"}│
└───────────────────┴───────────────┴───────────────┴────────────┴───────────┴────────────────────────────┘
----

and on running this cypher query: `MATCH p=(:Class)-[r:SCO]->() RETURN p` produces the following result:

image::skos_inline.png[Small concept hierarchy imported in SKOS, scaledwidth="100%"]

Similarly, the `.fetch` version of the method can be use to retrieve a larger dataset like in the
following example:

[source,cypher]
----
call n10s.skos.import.fetch("http://vocabularies.unesco.org/browser/rest/v1/thesaurus/data?format=text/turtle",
"Turtle", { languageFilter: "es" })
----

[source]
----
╒═══════════════════╤═══════════════╤═══════════════╤════════════╤═══════════╤════════════════════════════╕
│"terminationStatus"│"triplesLoaded"│"triplesParsed"│"namespaces"│"extraInfo"│"callParams" │
╞═══════════════════╪═══════════════╪═══════════════╪════════════╪═══════════╪════════════════════════════╡
│"OK" │68519 │87191 │null │"" │{"handleVocabUris":"IGNORE"}│
└───────────────────┴───────────────┴───────────────┴────────────┴───────────┴────────────────────────────┘
----

The resulting graph can be queried using cypher now. The following query shows
how to find the concepts related to
"Social Problems" (concept uri: `http://vocabularies.unesco.org/thesaurus/concept409`).

[source,cypher]
----
MATCH p = (:Resource { uri: "http://vocabularies.unesco.org/thesaurus/concept409"})-[*..5]->() RETURN p limit 80
----

image::skos_fetch.png[UNESCO Thesaurus in Spanish imported as SKOS, scaledwidth="100%"]
2 changes: 0 additions & 2 deletions docs/modules/ROOT/pages/previewing-rdf.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ CREATE (:Thing { uri: subject, prop: object });





The `n10s.rdf.stream.fetch` and `n10s.rdf.stream.inline` methods provide a convenient way to visualise in the Neo4j browser some RDF data before we go ahead with the actual import.
Like all methods in the xref:previewing-rdf.adoc[Preview] section, both `n10s.rdf.stream.fetch` and `n10s.rdf.stream.inline` are read only so will not persist anything in the graph.
The difference between them is that `previewRDF` takes a url (and optionally additional configuration settings as described in xref:import.adoc#advancedfetching[Advanced Fetching]) whereas `n10s.rdf.stream.inline` takes an RDF fragment as text instead.

0 comments on commit d9fba77

Please sign in to comment.