Skip to content

Instantly share code, notes, and snippets.

View phochste's full-sized avatar

Patrick Hochstenbach phochste

View GitHub Profile
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix : <http://example.org/ns#>.
# beetle is a car
:beetle a :Car.
# bob is a person
:bob a :Person.
# grannysmith apple is green
@phochste
phochste / example.js
Last active November 16, 2022 10:41
Example how to transform RDF from one serialisation to another
// npm install rdf-parse rdf-serialize stream-to-string streamify-string'
// node example.js
const rdfParser = require("rdf-parse").default;
const rdfSerializer = require("rdf-serialize").default;
const stringifyStream = require('stream-to-string');
const streamifyString = require('streamify-string');
doit(`
{
"@context": "http://schema.org/",
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
# Syntax:
# <> a vcard:Group;
# vcard:hasMember <webID1> ;
# vcard:hasMember <webID2> ;
# (etc)
# vcard:hasMember <webIDN> .
<> a vcard:Group;
vcard:hasMember <https://patrickhochstenbach.net/profile/card#me> .
{
"@context": "https://www.w3.org/ns/activitystreams",
"id": "urn:uuid:28142b78-af0b-40bf-9e1c-d579a7135fe3",
"type": "Announce",
"actor": {
"id": "https://scholexplorer.openaire.eu/#about",
"type": "Organization",
"inbox": "https://scholexplorer.openaire.eu/inbox/",
"name": "OpenAIRE ScholeXplorer"
},
@prefix : <urn:example:> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
@prefix string: <http://www.w3.org/2000/10/swap/string#> .
:Let :string "hello world" .
(_:X _:Y) log:negativeSurface {
:Let :string _:X .
# _:X string:upperCase _:Y .
@prefix ui: <http://www.w3.org/ns/ui#>.
@prefix schema: <http://schema.org/>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix : <#>.
:this
a ui:Form;
ui:parts (
:NameField
@phochste
phochste / marc_rdf_dct.fix
Created May 7, 2022 07:26
Catmandu mapping from MARC21 to RDF
# Copyright 2022 Patrick.Hochstenbach@UGent.be
# License CC BY-SA 4.0 https://creativecommons.org/licenses/by-sa/4.0/
# id
move_field(_id,'_r._id')
# DC - http://www.loc.gov/marc/marc2dc.html
# {See also http://www.bl.uk/bibliographic/pdfs/mappingmarc2basicrdf.pdf for alternative}
# Language
marc_map(008/35-37,lang)
@prefix as: <https://www.w3.org/ns/activitystreams#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix ldp: <http://www.w3.org/ns/ldp#> .
<urn:uuid:28142b78-af0b-40bf-9e1c-d579a7135fe3>
a as:Announce ;
as:actor <https://scholexplorer.openaire.eu/#about> ;
as:context <https://biblio.ugent.be/publication/8646849> ;
as:object <urn:uuid:240c0091-b271-4e44-87f7-5598da5b24ad> ;
as:origin <https://mellonscholarlycommunication.github.io/about#us> ;
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"http://purl.org/coar/notify"
],
"id": "urn:uuid:94ecae35-dcfd-4182-8550-22c7164fe23f",
"type": "Announce",
"actor": {
"id": "https://generic-service.com",
"name": "Generic Service",
{
"@context": [
"https://www.w3.org/ns/activitystreams",
{
"ietf": "http://www.iana.org/assignments/relation/",
"ldp": "http://www.w3.org/ns/ldp#"
}
],
"actor": {
"id": "https://orcid.org/0000-0002-1825-0097",