From 7589dd41aba7dd3f31d8dd1d98e82dd281eff42d Mon Sep 17 00:00:00 2001
From: Jakob Voss
Date: Mon, 19 Aug 2024 21:41:11 +0200
Subject: [PATCH] Extend mapping to RDF
---
Makefile | 26 +++-
README.md | 6 +-
context.json | 12 +-
csv2json.js | 20 +++
index.html | 8 +-
jsonld2rdf.js | 24 +--
n4o-collections.json | 107 +++++++++++++
n4o-databases-pg.json | 339 ------------------------------------------
n4o-databases.nt | 88 -----------
n4o-sources.nt | 110 ++++++++++++++
n4o-sources.ttl | 116 +++++++++++++++
package-lock.json | 35 +++--
package.json | 1 +
pg2rdf.js | 28 ++++
prefixes.json | 4 +-
update.js | 11 +-
16 files changed, 456 insertions(+), 479 deletions(-)
create mode 100644 csv2json.js
create mode 100644 n4o-collections.json
delete mode 100644 n4o-databases-pg.json
delete mode 100644 n4o-databases.nt
create mode 100644 n4o-sources.nt
create mode 100644 n4o-sources.ttl
create mode 100644 pg2rdf.js
diff --git a/Makefile b/Makefile
index 706b5cd..337785e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,23 @@
-all: n4o-collections.pg n4o-databases.pg n4o-databases.nt
+all: rdf pg
-n4o-databases.nt: n4o-databases.json
- @npm run --silent jsonld2nt -- $< -c context.json > $@
- @wc -l $@
+rdf: n4o-sources.nt n4o-sources.ttl
+
+n4o-databases.json: n4o-databases.csv
+ ./update.js
+
+n4o-collections.json: n4o-collections.csv
+ @node csv2json.js < $< > $@
-n4o-collections.nt: n4o-collections.json
- @npm run --silent jsonld2nt -- $< -c context.json > $@
+n4o-sources.nt: n4o-collections.json n4o-databases.json
+ @npm run --silent jsonld2rdf -- $^ -c context.json > $@
@wc -l $@
+n4o-sources.ttl: n4o-collections.json n4o-databases.json
+ @npm run --silent jsonld2rdf -- $^ -c context.json -p prefixes.json > $@
+ @echo $@
+
+pg: n4o-collections.pg n4o-databases.pg
+
n4o-databases.pg: n4o-databases.csv
@npm run --silent update
@@ -15,5 +25,5 @@ n4o-collections.pg: n4o-collections.csv
@./pg.py > $@
@wc -l $@
-n4o-source.nt: n4o-collections.nt n4o-databases.nt
- cat $^ > $@
+n4o-sources-pg.json: n4o-sources.pg
+ @npm run pgraph -- $< $@
diff --git a/README.md b/README.md
index f74a29e..147542b 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@ verwendet mit folgenden Unterschieden:
- Zur Angabe einer Homepage wird `foaf:url` verwendet, da diese RDF Property bereits etabliert ist
- Es werden keinen eigenen URIs für Herausgeber, APIs und Dateiformate gebildet sondern Wikidata-URIs verwendet
-Darüber hinaus werden die Daten als Property Graph in den Dateien [`n4o-databases-pg.json`] und [`n4o-databases.pg`] als PG-JSON bzw. PG format gespeichert.
+Darüber hinaus werden die Daten als Property Graph in den Dateien [`n4o-sources-pg.json`] und [`n4o-sources.pg`] als PG-JSON bzw. PG format gespeichert.
### Collections
@@ -82,5 +82,5 @@ Alle Daten stehen als Public Domain (CC0) frei zur Verfügung.
[`n4o-databases.json`]: n4o-databases.json
[`n4o-databases.nt`]: n4o-databases.nt
[`n4o-databases.ttl`]: n4o-databases.ttl
-[`n4o-databases-pg.json`]: n4o-databases-pg.json
-[`n4o-databases.pg`]: n4o-databases.pg
+[`n4o-sources-pg.json`]: n4o-sources-pg.json
+[`n4o-sources.pg`]: n4o-sources.pg
diff --git a/context.json b/context.json
index e51e748..47578d0 100644
--- a/context.json
+++ b/context.json
@@ -9,9 +9,13 @@
"schema": "http://schema.org/",
"skos": "http://www.w3.org/2004/02/skos/core#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
-
- "@base": "http://www.wikidata.org/entity/",
+ "id": "@id",
"wikidata": "@id",
+ "db": {
+ "@context": { "@base": "http://www.wikidata.org/entity/" },
+ "@type": "@id",
+ "@reverse": "dcat:dataset"
+ },
"re3data": {
"@context": { "@base": "https://www.re3data.org/repository/" },
"@type": "@id",
@@ -20,11 +24,11 @@
"name": "schema:name",
"type": {
"@type": "@id",
- "@id": "rdfs:type"
+ "@id": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
},
"url": {
"@id": "foaf:homepage",
- "@type": "dcat:anyURI"
+ "@type": "@id"
},
"publisher": {
"@id": "dcterms:publisher"
diff --git a/csv2json.js b/csv2json.js
new file mode 100644
index 0000000..a8f04a0
--- /dev/null
+++ b/csv2json.js
@@ -0,0 +1,20 @@
+import fs from 'fs'
+import csv from 'csv-parser'
+
+const results = []
+process.stdin
+ .pipe(csv())
+ .on('data', (data) => {
+ for (let key in data) {
+ if (data[key] === "") delete data[key]
+ }
+ if ("id" in data) {
+ data.id = "http://data.nfdi4objects.net/collection/" + data.id
+ data.type = ["fabio:Database","dcat:Dataset"]
+ } else if ("wikidata" in data) {
+ data.id = "http://www.wikidata.org/entity/" + data.id
+ // TODO: type
+ }
+ results.push(data)
+ })
+ .on('end', () => console.log(JSON.stringify(results, null, 2)))
diff --git a/index.html b/index.html
index 7652df2..3ceab32 100644
--- a/index.html
+++ b/index.html
@@ -93,12 +93,12 @@ Forschungsdatenbanken im Rahmen von NFDI4Objects
eingetragen werden (Übernahme von Daten von dort ist geplant).
- Die zusammengeführten Daten stehen
- in JSON
+ Die zusammengeführten Daten stehen in JSON
+ (databases und collections)
und RDF
- (Turtle und NTriples)
+ (Turtle und NTriples)
sowie als property graph
- (PG-JSON und PG format)
+ (PG-JSON und PG format)
als Open Data zur freien Verfügung
(CC0).
diff --git a/jsonld2rdf.js b/jsonld2rdf.js
index 030e9c2..93aab87 100644
--- a/jsonld2rdf.js
+++ b/jsonld2rdf.js
@@ -9,28 +9,30 @@ const readJSON = file => JSON.parse(fs.readFileSync(file, 'utf-8'))
program
.name("jsonld2rdf")
- .argument("[file]","JSON-LD input file (- for stdin)")
+ .argument("[file...]","JSON-LD input file")
.option('-c, --context ', 'JSON-LD context document')
.option('-p, --prefixes ', 'RDF Prefix map (as JSON object) for Turtle output')
- .action(async (file, options) => {
- file = (!file || file == '-') ? process.stdin.fd : file
- const data = readJSON(file)
+ .action(async (files, options) => {
+
+ const input = files.length ? files.map(readJSON) : readJSON(process.stdin.fd)
if (options.context) {
const context = readJSON(options.context)
- if (Array.isArray(data)) {
- data.forEach(item => (item["@context"] = context))
- } else {
- data["@context"] = context
+ for (let data of input) {
+ if (Array.isArray(data)) {
+ data.forEach(item => (item["@context"] = context))
+ } else {
+ data["@context"] = context
+ }
}
}
- const nt = await jsonld.toRDF(data, {format: 'application/n-quads'})
+ const nt = (await Promise.all(input.map(
+ data => jsonld.toRDF(data, {format: 'application/n-quads'})
+ ))).join("\n")
- // pretty-print Turtle
if (options.prefixes) {
const prefixes = readJSON(options.prefixes)
-
const quads = []
const parserN3 = new ParserN3()
const output = parserN3.import(Readable.from(nt))
diff --git a/n4o-collections.json b/n4o-collections.json
new file mode 100644
index 0000000..9765563
--- /dev/null
+++ b/n4o-collections.json
@@ -0,0 +1,107 @@
+[
+ {
+ "id": "http://data.nfdi4objects.net/collection/1",
+ "name": "Ur- und Frühgeschichtliche Sammlung der FAU",
+ "url": "https://objekte-im-netz.fau.de/projekt/node/22",
+ "db": "Q124695065",
+ "type": [
+ "fabio:Database"
+ ]
+ },
+ {
+ "id": "http://data.nfdi4objects.net/collection/2",
+ "name": "Paläontologischen Sammlung der FAU|Geowissenschaftliche Sammlung der FAU",
+ "url": "https://objekte-im-netz.fau.de/projekt/node/20",
+ "db": "Q124695065",
+ "type": [
+ "fabio:Database"
+ ]
+ },
+ {
+ "id": "http://data.nfdi4objects.net/collection/3",
+ "name": "Graphische Sammlung der FAU",
+ "url": "https://objekte-im-netz.fau.de/projekt/node/17",
+ "db": "Q124695065",
+ "type": [
+ "fabio:Database"
+ ]
+ },
+ {
+ "id": "http://data.nfdi4objects.net/collection/4",
+ "name": "Musikinstrumentensammlung der FAU",
+ "url": "https://objekte-im-netz.fau.de/projekt/node/19",
+ "db": "Q124695065",
+ "type": [
+ "fabio:Database"
+ ]
+ },
+ {
+ "id": "http://data.nfdi4objects.net/collection/5",
+ "name": "Medizinische Sammlung der FAU",
+ "url": "https://objekte-im-netz.fau.de/projekt/node/18",
+ "db": "Q124695065",
+ "type": [
+ "fabio:Database"
+ ]
+ },
+ {
+ "id": "http://data.nfdi4objects.net/collection/6",
+ "name": "Schulgeschichtliche Sammlung der FAU und Schulmuseum",
+ "url": "https://objekte-im-netz.fau.de/projekt/node/21",
+ "db": "Q124695065",
+ "type": [
+ "fabio:Database"
+ ]
+ },
+ {
+ "id": "http://data.nfdi4objects.net/collection/7",
+ "name": "KENOM Virtuelles Münzportal",
+ "url": "http://www.kenom.de/",
+ "db": "Q21040628",
+ "type": [
+ "fabio:Database"
+ ]
+ },
+ {
+ "id": "http://data.nfdi4objects.net/collection/8",
+ "name": "Samian Research Database",
+ "url": "https://rgzm.github.io/samian-lod/",
+ "type": [
+ "fabio:Database"
+ ]
+ },
+ {
+ "id": "http://data.nfdi4objects.net/collection/9",
+ "name": "Linked Open Ogham",
+ "url": "https://doi.org/10.5281/zenodo.4765603",
+ "type": [
+ "fabio:Database"
+ ]
+ },
+ {
+ "id": "http://data.nfdi4objects.net/collection/10",
+ "name": "African Red Slip Ware",
+ "url": "https://doi.org/10.5281/zenodo.5642751",
+ "type": [
+ "fabio:Database"
+ ]
+ },
+ {
+ "id": "http://data.nfdi4objects.net/collection/11",
+ "name": "Digitale Sammlungen der Museen der Klassikstiftung Weimar",
+ "url": "https://ores.klassik-stiftung.de/ords/ksw_internet/r/300/home",
+ "db": "Q124536091",
+ "type": [
+ "fabio:Database"
+ ]
+ },
+ {
+ "id": "http://data.nfdi4objects.net/collection/12",
+ "name": "Graphische Sammlung des Germanisches National Museum",
+ "url": "https://www.gnm.de/sammlungen/sammlungen-a-z/graphische-sammlung",
+ "db": "Q478695",
+ "type": [
+ "fabio:Database"
+ ]
+ }
+]
diff --git a/n4o-databases-pg.json b/n4o-databases-pg.json
deleted file mode 100644
index b11a28d..0000000
--- a/n4o-databases-pg.json
+++ /dev/null
@@ -1,339 +0,0 @@
-{
- "nodes": [
- {
- "id": "http://www.wikidata.org/entity/Q21040628",
- "labels": [
- "Database"
- ],
- "properties": {
- "uri": [
- "http://www.wikidata.org/entity/http://www.wikidata.org/entity/Q21040628"
- ],
- "url": [
- "http://www.kenom.de"
- ]
- }
- },
- {
- "id": "Q27863572",
- "labels": [
- "Agent"
- ],
- "properties": {
- "label": [
- "Verbundzentrale des GBV"
- ]
- }
- },
- {
- "id": "http://www.wikidata.org/entity/Q90412636",
- "labels": [
- "Database"
- ],
- "properties": {
- "uri": [
- "http://www.wikidata.org/entity/http://www.wikidata.org/entity/Q90412636"
- ],
- "url": [
- "http://rgzm.de/samian"
- ]
- }
- },
- {
- "id": "Q88865971",
- "labels": [
- "Agent"
- ],
- "properties": {
- "label": [
- "Allard Wijnand Mees"
- ]
- }
- },
- {
- "id": "http://www.wikidata.org/entity/Q323169",
- "labels": [
- "Database"
- ],
- "properties": {
- "uri": [
- "http://www.wikidata.org/entity/http://www.wikidata.org/entity/Q323169"
- ],
- "url": [
- "https://www.smb.museum/mk"
- ]
- }
- },
- {
- "id": "Q685171",
- "labels": [
- "Agent"
- ],
- "properties": {
- "label": [
- "Stiftung Preußischer Kulturbesitz"
- ]
- }
- },
- {
- "id": "http://www.wikidata.org/entity/Q124504881",
- "labels": [
- "Database"
- ],
- "properties": {
- "uri": [
- "http://www.wikidata.org/entity/http://www.wikidata.org/entity/Q124504881"
- ],
- "url": [
- "https://www.montandok.de/"
- ]
- }
- },
- {
- "id": "Q896952",
- "labels": [
- "Agent"
- ],
- "properties": {
- "label": [
- "Deutsches Bergbau-Museum Bochum"
- ]
- }
- },
- {
- "id": "http://www.wikidata.org/entity/Q124529087",
- "labels": [
- "Database"
- ],
- "properties": {
- "uri": [
- "http://www.wikidata.org/entity/http://www.wikidata.org/entity/Q124529087",
- "https://www.re3data.org/repository/r3d100012361"
- ],
- "url": [
- "http://datenportal.ianus-fdz.de/"
- ]
- }
- },
- {
- "id": "Q695302",
- "labels": [
- "Agent"
- ],
- "properties": {
- "label": [
- "Deutsches Archäologisches Institut"
- ]
- }
- },
- {
- "id": "http://www.wikidata.org/entity/Q124530213",
- "labels": [
- "Database"
- ],
- "properties": {
- "uri": [
- "http://www.wikidata.org/entity/http://www.wikidata.org/entity/Q124530213",
- "https://www.re3data.org/repository/r3d100011407"
- ],
- "url": [
- "https://arachne.dainst.org/"
- ]
- }
- },
- {
- "id": "Q695302",
- "labels": [
- "Agent"
- ],
- "properties": {
- "label": [
- "Deutsches Archäologisches Institut"
- ]
- }
- },
- {
- "id": "http://www.wikidata.org/entity/Q289880",
- "labels": [
- "Database"
- ],
- "properties": {
- "uri": [
- "http://www.wikidata.org/entity/http://www.wikidata.org/entity/Q289880"
- ]
- }
- },
- {
- "id": "http://www.wikidata.org/entity/Q124535956",
- "labels": [
- "Database"
- ],
- "properties": {
- "uri": [
- "http://www.wikidata.org/entity/http://www.wikidata.org/entity/Q124535956"
- ],
- "url": [
- "http://www.klassik-stiftung.de/sofie"
- ]
- }
- },
- {
- "id": "Q315452",
- "labels": [
- "Agent"
- ],
- "properties": {
- "label": [
- "Klassik Stiftung Weimar"
- ]
- }
- },
- {
- "id": "http://www.wikidata.org/entity/Q124536091",
- "labels": [
- "Database"
- ],
- "properties": {
- "uri": [
- "http://www.wikidata.org/entity/http://www.wikidata.org/entity/Q124536091"
- ],
- "url": [
- "https://ores.klassik-stiftung.de/ords/ksw_internet/r/300/home"
- ]
- }
- },
- {
- "id": "Q315452",
- "labels": [
- "Agent"
- ],
- "properties": {
- "label": [
- "Klassik Stiftung Weimar"
- ]
- }
- },
- {
- "id": "http://www.wikidata.org/entity/Q124694998",
- "labels": [
- "Database"
- ],
- "properties": {
- "uri": [
- "http://www.wikidata.org/entity/http://www.wikidata.org/entity/Q124694998"
- ],
- "url": [
- "https://objektkatalog.gnm.de/"
- ]
- }
- },
- {
- "id": "Q478695",
- "labels": [
- "Agent"
- ],
- "properties": {
- "label": [
- "Germanisches Nationalmuseum"
- ]
- }
- },
- {
- "id": "http://www.wikidata.org/entity/Q124695065",
- "labels": [
- "Database"
- ],
- "properties": {
- "uri": [
- "http://www.wikidata.org/entity/http://www.wikidata.org/entity/Q124695065"
- ],
- "url": [
- "https://objekte-im-netz.fau.de/"
- ]
- }
- },
- {
- "id": "Q40025",
- "labels": [
- "Agent"
- ],
- "properties": {
- "label": [
- "Friedrich-Alexander-Universität Erlangen-Nürnberg"
- ]
- }
- }
- ],
- "edges": [
- {
- "from": "http://www.wikidata.org/entity/Q21040628",
- "to": "Q27863572",
- "labels": [
- "publisher"
- ]
- },
- {
- "from": "http://www.wikidata.org/entity/Q90412636",
- "to": "Q88865971",
- "labels": [
- "publisher"
- ]
- },
- {
- "from": "http://www.wikidata.org/entity/Q323169",
- "to": "Q685171",
- "labels": [
- "publisher"
- ]
- },
- {
- "from": "http://www.wikidata.org/entity/Q124504881",
- "to": "Q896952",
- "labels": [
- "publisher"
- ]
- },
- {
- "from": "http://www.wikidata.org/entity/Q124529087",
- "to": "Q695302",
- "labels": [
- "publisher"
- ]
- },
- {
- "from": "http://www.wikidata.org/entity/Q124530213",
- "to": "Q695302",
- "labels": [
- "publisher"
- ]
- },
- {
- "from": "http://www.wikidata.org/entity/Q124535956",
- "to": "Q315452",
- "labels": [
- "publisher"
- ]
- },
- {
- "from": "http://www.wikidata.org/entity/Q124536091",
- "to": "Q315452",
- "labels": [
- "publisher"
- ]
- },
- {
- "from": "http://www.wikidata.org/entity/Q124694998",
- "to": "Q478695",
- "labels": [
- "publisher"
- ]
- },
- {
- "from": "http://www.wikidata.org/entity/Q124695065",
- "to": "Q40025",
- "labels": [
- "publisher"
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/n4o-databases.nt b/n4o-databases.nt
deleted file mode 100644
index 5e7150f..0000000
--- a/n4o-databases.nt
+++ /dev/null
@@ -1,88 +0,0 @@
- .
- "montan.dok" .
- .
- .
- .
- "https://www.montandok.de/"^^ .
- .
- "IANUS Datenportal" .
- .
- .
- .
- .
- "http://datenportal.ianus-fdz.de/"^^ .
- .
- "iDAI.objects" .
- .
- .
- .
- .
- "https://arachne.dainst.org/"^^ .
- .
- "Forschungsdatenbank so:fie" .
- .
- .
- .
- "http://www.klassik-stiftung.de/sofie"^^ .
- .
- "Digitale Sammlungen der Museen der Klassikstiftung Weimar" .
- .
- .
- .
- "https://ores.klassik-stiftung.de/ords/ksw_internet/r/300/home"^^ .
- .
- "Objektkatalog des Germanischen Nationalmuseum" .
- .
- .
- .
- "https://objektkatalog.gnm.de/"^^ .
- .
- "Objekte im Netz" .
- .
- .
- .
- "https://objekte-im-netz.fau.de/"^^ .
- "Lightweight Information Describing Objects" .
- "SOAP" .
- .
- "KENOM" .
- .
- .
- .
- _:b0 .
- "http://www.kenom.de"^^ .
- "Open Archives Initiative Protocol for Metadata Harvesting" .
- "Verbundzentrale des GBV" .
- "ADABweb" .
- .
- .
- .
- _:b3 .
- "Klassik Stiftung Weimar" .
- .
- "Münzkabinett" .
- .
- .
- .
- "https://www.smb.museum/mk"^^ .
- "Friedrich-Alexander-Universität Erlangen-Nürnberg" .
- "Germanisches Nationalmuseum" .
- "Stiftung Preußischer Kulturbesitz" .
- "Deutsches Archäologisches Institut" .
- "Allard Wijnand Mees" .
- "Deutsches Bergbau-Museum Bochum" .
- .
- "Samian Research" .
- .
- .
- .
- _:b1 .
- _:b2 .
- "http://rgzm.de/samian"^^ .
-_:b0 .
-_:b0 "https://www.kenom.de/oai/"^^ .
-_:b0 .
-_:b1 "https://geo.rgzm.de/geoserver/ows"^^ .
-_:b2 "http://www.rgzm.de/rest/samianresearch/"^^ .
-_:b3 .
-
diff --git a/n4o-sources.nt b/n4o-sources.nt
new file mode 100644
index 0000000..81b7203
--- /dev/null
+++ b/n4o-sources.nt
@@ -0,0 +1,110 @@
+ "African Red Slip Ware" .
+ .
+ .
+ "Digitale Sammlungen der Museen der Klassikstiftung Weimar" .
+ .
+ .
+ "Graphische Sammlung des Germanisches National Museum" .
+ .
+