This repository has been archived by the owner on Oct 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
eu-vocabularies.js
51 lines (46 loc) · 1.64 KB
/
eu-vocabularies.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* Query vocabulary metadata from EU Publications Office.
*/
const fs = require('fs')
const SparqlClient = require('sparql-http-client')
const endpointUrl = ' http://publications.europa.eu/webapi/rdf/sparql'
const client = new SparqlClient({ endpointUrl })
const query = fs.readFileSync('./eu-vocabularies.rq', {encoding:'utf8', flag:'r'})
const staticFields = {
publisher: [
{
uri: "http://viaf.org/viaf/229069752",
prefLabel: { en: "Publications Office of the European Union" }
}
],
// will be moved to publisher, see <https://github.com/gbv/bartoc.org/issues/96>
ADDRESS: {
country: "Luxembourg",
locality: "Luxembourg",
code: "L-2985",
street: "2 rue Mercier",
},
CONTACT: "[email protected]",
/*
# Hard coded fields
BIND("EN" as ?lng )
BIND("Free" as ?field_access )
BIND("General works, Computer science and Information" as ?field_subject_area )
BIND("001 Knowledge" as ?field_ddc )
BIND("government" as ?field_topic )
BIND("CC0: Creative Commons Zero (Public Domain)" as ?field_license )
BIND("V: general class" as ?field_ilc )
BIND("Publications Office of the European Union" as ?field_autor )
*/
}
client.query.select(query).then(stream => {
stream.on('data', row => {
const scheme = { ...staticFields }
scheme.uri = row.sameAsWork.value
scheme.title = { en: row.title.value } // TODO: add something like "EU"?
scheme.description = { en: [row.description.value] } // TODO: strip HTML
// TODO
console.log(JSON.stringify(scheme,null,2))
})
stream.on('error', err => { console.error(err) })
})