|
2 | 2 | = Importing Ontologies
|
3 | 3 | :page-pagination:
|
4 | 4 |
|
5 |
| - |
6 | 5 | 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.
|
7 | 6 | It's important to note that this procedure exclusively imports the following:
|
8 | 7 |
|
@@ -66,4 +65,85 @@ and then we extend it with some additiona statements (triples) passed as text to
|
66 | 65 | 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");
|
67 | 66 | ----
|
68 | 67 |
|
69 |
| -Check xref:reference.adoc[Reference] for a complete list of available parameters. |
| 68 | +Check xref:reference.adoc[Reference] for a complete list of available parameters. |
| 69 | + |
| 70 | + |
| 71 | +== Importing SKOS concept schemes |
| 72 | + |
| 73 | +https://www.w3.org/TR/skos-reference/[SKOS] (Simple Knowledge Organization System) provides a model for expressing the basic structure and |
| 74 | +content of concept schemes such as thesauri, classification schemes, subject heading lists, |
| 75 | +taxonomies, folksonomies, and other similar types of controlled vocabulary. Neosemantics also provides |
| 76 | +methods (`skos.import`) to import SKOS concept schemes. |
| 77 | + |
| 78 | +These methods follow the same structure and implement the same behavior as the ones for importing ontologies |
| 79 | +here is an example of inline importing a skos fragment of a taxonomy: |
| 80 | + |
| 81 | +[source,cypher] |
| 82 | +---- |
| 83 | +call n10s.skos.import.inline(' |
| 84 | +
|
| 85 | +@prefix skos: <http://www.w3.org/2004/02/skos/core#> . |
| 86 | +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . |
| 87 | +@prefix ex: <http://www.example.com/> . |
| 88 | +
|
| 89 | +ex:cat rdf:type skos:Concept; |
| 90 | +skos:prefLabel "cat"@en; |
| 91 | +skos:prefLabel "Katze"@de; |
| 92 | +skos:altLabel "kitten"@en; |
| 93 | +skos:narrower ex:wildcat; |
| 94 | +skos:broader ex:animal . |
| 95 | +
|
| 96 | +ex:wildcat rdf:type skos:Concept; |
| 97 | +skos:prefLabel "wildcat"@en; |
| 98 | +skos:broader ex:cat. |
| 99 | +
|
| 100 | +ex:animal rdf:type skos:Concept; |
| 101 | +skos:prefLabel "animal"@en . |
| 102 | +
|
| 103 | +','Turtle') |
| 104 | +
|
| 105 | +---- |
| 106 | + |
| 107 | +producing the following summary of execution: |
| 108 | + |
| 109 | +[source,cypher] |
| 110 | +---- |
| 111 | +╒═══════════════════╤═══════════════╤═══════════════╤════════════╤═══════════╤════════════════════════════╕ |
| 112 | +│"terminationStatus"│"triplesLoaded"│"triplesParsed"│"namespaces"│"extraInfo"│"callParams" │ |
| 113 | +╞═══════════════════╪═══════════════╪═══════════════╪════════════╪═══════════╪════════════════════════════╡ |
| 114 | +│"OK" │11 │11 │null │"" │{"handleVocabUris":"IGNORE"}│ |
| 115 | +└───────────────────┴───────────────┴───────────────┴────────────┴───────────┴────────────────────────────┘ |
| 116 | +---- |
| 117 | + |
| 118 | +and on running this cypher query: `MATCH p=(:Class)-[r:SCO]->() RETURN p` produces the following result: |
| 119 | + |
| 120 | +image::skos_inline.png[Small concept hierarchy imported in SKOS, scaledwidth="100%"] |
| 121 | + |
| 122 | +Similarly, the `.fetch` version of the method can be use to retrieve a larger dataset like in the |
| 123 | +following example: |
| 124 | + |
| 125 | +[source,cypher] |
| 126 | +---- |
| 127 | +call n10s.skos.import.fetch("http://vocabularies.unesco.org/browser/rest/v1/thesaurus/data?format=text/turtle", |
| 128 | + "Turtle", { languageFilter: "es" }) |
| 129 | +---- |
| 130 | + |
| 131 | +[source] |
| 132 | +---- |
| 133 | +╒═══════════════════╤═══════════════╤═══════════════╤════════════╤═══════════╤════════════════════════════╕ |
| 134 | +│"terminationStatus"│"triplesLoaded"│"triplesParsed"│"namespaces"│"extraInfo"│"callParams" │ |
| 135 | +╞═══════════════════╪═══════════════╪═══════════════╪════════════╪═══════════╪════════════════════════════╡ |
| 136 | +│"OK" │68519 │87191 │null │"" │{"handleVocabUris":"IGNORE"}│ |
| 137 | +└───────────────────┴───────────────┴───────────────┴────────────┴───────────┴────────────────────────────┘ |
| 138 | +---- |
| 139 | + |
| 140 | +The resulting graph can be queried using cypher now. The following query shows |
| 141 | +how to find the concepts related to |
| 142 | +"Social Problems" (concept uri: `http://vocabularies.unesco.org/thesaurus/concept409`). |
| 143 | + |
| 144 | +[source,cypher] |
| 145 | +---- |
| 146 | +MATCH p = (:Resource { uri: "http://vocabularies.unesco.org/thesaurus/concept409"})-[*..5]->() RETURN p limit 80 |
| 147 | +---- |
| 148 | + |
| 149 | +image::skos_fetch.png[UNESCO Thesaurus in Spanish imported as SKOS, scaledwidth="100%"] |
0 commit comments