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" . + . + . + "Ur- und Frühgeschichtliche Sammlung der FAU" . + . + . + "Paläontologischen Sammlung der FAU|Geowissenschaftliche Sammlung der FAU" . + . + . + "Graphische Sammlung der FAU" . + . + . + "Musikinstrumentensammlung der FAU" . + . + . + "Medizinische Sammlung der FAU" . + . + . + "Schulgeschichtliche Sammlung der FAU und Schulmuseum" . + . + . + "KENOM Virtuelles Münzportal" . + . + . + "Samian Research Database" . + . + . + "Linked Open Ogham" . + . + . + . + . + . + . + . + . + . + . + . + + "montan.dok" . + . + . + . + . + "IANUS Datenportal" . + . + . + . + . + . + "iDAI.objects" . + . + . + . + . + . + "Forschungsdatenbank so:fie" . + . + . + . + . + "Digitale Sammlungen der Museen der Klassikstiftung Weimar" . + . + . + . + . + "Objektkatalog des Germanischen Nationalmuseum" . + . + . + . + . + "Objekte im Netz" . + . + . + . + . + "KENOM" . + . + . + . + _:b0 . + . + "ADABweb" . + . + . + . + _:b3 . + "Münzkabinett" . + . + . + . + . + "Samian Research" . + . + . + . + _:b1 . + _:b2 . + . +_:b0 "https://www.kenom.de/oai/"^^ . +_:b1 "https://geo.rgzm.de/geoserver/ows"^^ . +_:b2 "http://www.rgzm.de/rest/samianresearch/"^^ . + diff --git a/n4o-sources.ttl b/n4o-sources.ttl new file mode 100644 index 0000000..5bad735 --- /dev/null +++ b/n4o-sources.ttl @@ -0,0 +1,116 @@ +@prefix dcat: . +@prefix fabio: . +@prefix foaf: . +@prefix nfdicore: . +@prefix owl: . +@prefix schema: . +@prefix wd: . +@prefix n4oc: . + +n4oc:10 a fabio:Database ; + schema:name "African Red Slip Ware" ; + foaf:homepage . + +n4oc:11 a fabio:Database ; + schema:name "Digitale Sammlungen der Museen der Klassikstiftung Weimar" ; + foaf:homepage . + +n4oc:12 a fabio:Database ; + schema:name "Graphische Sammlung des Germanisches National Museum" ; + foaf:homepage . + +n4oc:1 a fabio:Database ; + schema:name "Ur- und Frühgeschichtliche Sammlung der FAU" ; + foaf:homepage . + +n4oc:2 a fabio:Database ; + schema:name "Paläontologischen Sammlung der FAU|Geowissenschaftliche Sammlung der FAU" ; + foaf:homepage . + +n4oc:3 a fabio:Database ; + schema:name "Graphische Sammlung der FAU" ; + foaf:homepage . + +n4oc:4 a fabio:Database ; + schema:name "Musikinstrumentensammlung der FAU" ; + foaf:homepage . + +n4oc:5 a fabio:Database ; + schema:name "Medizinische Sammlung der FAU" ; + foaf:homepage . + +n4oc:6 a fabio:Database ; + schema:name "Schulgeschichtliche Sammlung der FAU und Schulmuseum" ; + foaf:homepage . + +n4oc:7 a fabio:Database ; + schema:name "KENOM Virtuelles Münzportal" ; + foaf:homepage . + +n4oc:8 a fabio:Database ; + schema:name "Samian Research Database" ; + foaf:homepage . + +n4oc:9 a fabio:Database ; + schema:name "Linked Open Ogham" ; + foaf:homepage . + +wd:Q124536091 a fabio:Database, dcat:Catalog, nfdicore:DataPortal ; + schema:name "Digitale Sammlungen der Museen der Klassikstiftung Weimar" ; + foaf:homepage ; + dcat:dataset n4oc:11 . + +wd:Q124695065 a fabio:Database, dcat:Catalog, nfdicore:DataPortal ; + schema:name "Objekte im Netz" ; + foaf:homepage ; + dcat:dataset n4oc:1, n4oc:2, n4oc:3, n4oc:4, n4oc:5, n4oc:6 . + +wd:Q21040628 a fabio:Database, dcat:Catalog, nfdicore:DataPortal ; + schema:name "KENOM" ; + foaf:homepage ; + dcat:dataset n4oc:7 ; + dcat:distribution [ + dcat:accessURL "https://www.kenom.de/oai/"^^ + ] . + +wd:Q478695 dcat:dataset n4oc:12 . + +wd:Q124504881 a fabio:Database, dcat:Catalog, nfdicore:DataPortal ; + schema:name "montan.dok" ; + foaf:homepage . + +wd:Q124529087 a fabio:Database, dcat:Catalog, nfdicore:DataPortal ; + schema:name "IANUS Datenportal" ; + foaf:homepage ; + owl:sameAs . + +wd:Q124530213 a fabio:Database, dcat:Catalog, nfdicore:DataPortal ; + schema:name "iDAI.objects" ; + foaf:homepage ; + owl:sameAs . + +wd:Q124535956 a fabio:Database, dcat:Catalog, nfdicore:DataPortal ; + schema:name "Forschungsdatenbank so:fie" ; + foaf:homepage . + +wd:Q124694998 a fabio:Database, dcat:Catalog, nfdicore:DataPortal ; + schema:name "Objektkatalog des Germanischen Nationalmuseum" ; + foaf:homepage . + +wd:Q289880 a fabio:Database, dcat:Catalog, nfdicore:DataPortal ; + schema:name "ADABweb" ; + dcat:distribution [] . + +wd:Q323169 a fabio:Database, dcat:Catalog, nfdicore:DataPortal ; + schema:name "Münzkabinett" ; + foaf:homepage . + +wd:Q90412636 a fabio:Database, dcat:Catalog, nfdicore:DataPortal ; + schema:name "Samian Research" ; + foaf:homepage ; + dcat:distribution [ + dcat:accessURL "https://geo.rgzm.de/geoserver/ows"^^ + ], [ + dcat:accessURL "http://www.rgzm.de/rest/samianresearch/"^^ + ] . + diff --git a/package-lock.json b/package-lock.json index 0cfaee9..41b0fb2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@rdfjs/parser-n3": "^2.0.2", "commander": "^12.1.0", "csv": "^6.3.6", - "get-stream": "^8.0.1", + "csv-parser": "^3.0.0", "jsonld": "^8.3.2", "pgraphs": "^0.5.1", "rdf-ext": "^2.5.2", @@ -737,6 +737,20 @@ "resolved": "https://registry.npmjs.org/csv-parse/-/csv-parse-5.5.3.tgz", "integrity": "sha512-v0KW6C0qlZzoGjk6u5tLmVfyZxNgPGXZsWTXshpAgKVGmGXzaVWGdlCFxNx5iuzcXT/oJN1HHM9DZKwtAtYa+A==" }, + "node_modules/csv-parser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/csv-parser/-/csv-parser-3.0.0.tgz", + "integrity": "sha512-s6OYSXAK3IdKqYO33y09jhypG/bSDHPuyCme/IdEHfWpLf/jKcpitVFyOC6UemgGk8v7Q5u2XE0vvwmanxhGlQ==", + "dependencies": { + "minimist": "^1.2.0" + }, + "bin": { + "csv-parser": "bin/csv-parser" + }, + "engines": { + "node": ">= 10" + } + }, "node_modules/csv-stringify": { "version": "6.4.5", "resolved": "https://registry.npmjs.org/csv-stringify/-/csv-stringify-6.4.5.tgz", @@ -819,17 +833,6 @@ "node": ">=12.20.0" } }, - "node_modules/get-stream": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", - "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/grapoi": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/grapoi/-/grapoi-1.1.2.tgz", @@ -1019,6 +1022,14 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/n3": { "version": "1.17.2", "resolved": "https://registry.npmjs.org/n3/-/n3-1.17.2.tgz", diff --git a/package.json b/package.json index 76a9494..ce47a1a 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "@rdfjs/parser-n3": "^2.0.2", "commander": "^12.1.0", "csv": "^6.3.6", + "csv-parser": "^3.0.0", "jsonld": "^8.3.2", "pgraphs": "^0.5.1", "rdf-ext": "^2.5.2", diff --git a/pg2rdf.js b/pg2rdf.js new file mode 100644 index 0000000..4ae2eaa --- /dev/null +++ b/pg2rdf.js @@ -0,0 +1,28 @@ +import fs from "fs" +import { pgformat, ParsingError } from "pgraphs" + +const graph = pgformat.pg.parse(fs.readFileSync("n4o-collections.pg").toString()) + +const nodes = {} + +for (let n of graph.nodes) { + var ld = { + id: n.id, + type: n.labels // TODO: how to convert to URI + } + for (let [key, values] of Object.entries(n.properties)) { + if (key !== "id" && key !== "type") { + ld[key] = values + } + } + nodes[n.id] = ld +} + +for (let e of graph.edges) { + const from = (nodes[e.from] ||= {}) + from [e.labels[0]] = e.to +} + +for (let nd of Object.values(nodes)) { + console.log(JSON.stringify(ld,null,2)) +} diff --git a/prefixes.json b/prefixes.json index 899941f..67890e8 100644 --- a/prefixes.json +++ b/prefixes.json @@ -5,9 +5,9 @@ "foaf": "http://xmlns.com/foaf/0.1/", "nfdicore": "https://nfdi.fiz-karlsruhe.de/ontology/", "owl": "http://www.w3.org/2002/07/owl#", - "rdfs": "http://www.w3.org/2000/01/rdf-schema#", "schema": "http://schema.org/", "skos": "http://www.w3.org/2004/02/skos/core#", "xsd": "http://www.w3.org/2001/XMLSchema#", - "wd": "http://www.wikidata.org/entity/" + "wd": "http://www.wikidata.org/entity/", + "n4oc": "http://data.nfdi4objects.net/collection/" } diff --git a/update.js b/update.js index 962410f..706eb59 100755 --- a/update.js +++ b/update.js @@ -1,7 +1,5 @@ import fs from 'fs' import { pgformat } from 'pgraphs' -import jsonld from 'jsonld' -import { TurtleSerializer } from '@rdfjs-elements/formats-pretty' import wdk from 'wikibase-sdk/wikidata.org' import { parse } from 'csv-parse/sync' @@ -10,7 +8,6 @@ const wdquery = async query => const csv = fs.readFileSync('n4o-databases.csv', 'utf-8') const dbs = parse(csv, { columns: true, trim: true }) -const context = JSON.parse(fs.readFileSync('context.json')) // get dabases with known Wikidata identifier var ids = dbs.map(db => db.wikidata).filter(Boolean) @@ -49,13 +46,14 @@ for (let item of items) { api.protocol = api.protocol.map(qid => known[qid] || qid) } item.publisher = item.publisher.map(qid => known[qid] || qid) - item.type = ['dcat:Catalog','nfdicore:DataPortal','fabio:Database'] + item.type = ['dcat:Catalog','nfdicore:DataPortal'] //,'fabio:DataRepository'? } // Serialize JSON const json = JSON.stringify(items, null, 2) fs.writeFileSync('n4o-databases.json',json) + // Serialize PG-JSON (TODO: simplify) const nodes = [], edges = [] for (let item of items) { @@ -87,8 +85,5 @@ for (let item of items) { } // TODO: include API } -const graph = { nodes, edges } -fs.writeFileSync('n4o-databases-pg.json', JSON.stringify(graph, null, 2)) -fs.writeFileSync('n4o-databases.pg', pgformat.pg.serialize(graph)) - +fs.writeFileSync('n4o-databases.pg', pgformat.pg.serialize({ nodes, edges }))