Skip to content

Commit d9fba77

Browse files
committed
skos section
1 parent 8d1dde9 commit d9fba77

File tree

4 files changed

+82
-4
lines changed

4 files changed

+82
-4
lines changed
556 KB
Loading
85.3 KB
Loading

docs/modules/ROOT/pages/importing-ontologies.adoc

+82-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
= Importing Ontologies
33
:page-pagination:
44

5-
65
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.
76
It's important to note that this procedure exclusively imports the following:
87

@@ -66,4 +65,85 @@ and then we extend it with some additiona statements (triples) passed as text to
6665
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");
6766
----
6867

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%"]

docs/modules/ROOT/pages/previewing-rdf.adoc

-2
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ CREATE (:Thing { uri: subject, prop: object });
144144

145145

146146

147-
148-
149147
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.
150148
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.
151149
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 commit comments

Comments
 (0)