This repository is a collection of vocabulary and scheme definitions and mappings to external resources. These define the foundation of linked library data used by the National Library of Sweden.
Install the Python-based dependencies (preferably within a virtualenv):
$ pip install -r requirements.txt
Run the following script to build the full set of definition resources:
$ python datasets.py -l
You can also pass dataset names to generate the different parts in isolation.
Pass -h or --help to the script for details.
The source/ directory contains the main vocabulary mappings for linked data
at KB.
Here can also be found a bunch of common definitions and mappings, as well as
language labels more or less manually synced with various external origins. See
datasets.py for the details.
It also contains a hand-curated set of RDF types extracted from MARC fixed field definitions (006, 007 and 008 for bib, auth and hold).
The vocabulary is split into the formally deciced "vocab" terms, and the legacy "marc" (often unstable) terms stemming from MARC21 constructs not yet interpreted according to the new modelling principles (based on RDF and linked data (see source/doc/model.en.mkd)).
In these files are special:
-
source/vocab/bf-to-kbv-base.rqandsource/vocab/bf-map.ttlare used to automatically wire up the base BF2 mappings and term hierarchies. -
source/vocab/display.jsonlddefines lenses used to display data (as "cards" or "chips"). -
source/vocab/platform.ttlandsource/vocab/services.ttlmap various technical terms to public vocabularies. -
source/vocab/enums.ttl,source/vocab/construct-enum-restrictions.rq, andsource/marc/enums.ttldefine the terms (properties and classes) for controlled, "enumerable" values. A lot of these stem from controlled values for columns in fixed fields in MARC21. Some come from RDA, and some from cleaned up defintions in BibFrame 2, or our own vocabulary. (See links in the data for references.)These files also contain certain instances of these classes. Specifically, these correspond to the domain of the properties defined as
@type: @vocabinsource/vocab-overlay.jsonld. These are special values defined within the vocabulary (often because they are very "type-like"). A prime example isIssuanceType, whose values are kept together with the vocabulary itself. -
source/marc/construct-enums.rqcombine to create all other "enumerable" values, which may or may not become merged with other controlled lists in the future. (When that is done, the definition here must be removed and its URI be places in asameAsrelation in whatever term that is replacing it.
Note: the file source/vocab/check-bases.rq is used to check some sanity
in the generated structures. It is advised to heed any warnings by correcting
the relevant sources.
Tip: During vocab development. Regularly run just:
$ python datasets.py vocab
to generate a vocab build file. Look at it as Turtle by running:
$ rdfpipe -ijson-ld:context=build/vocab/context.jsonld build/vocab.jsonld
, and/or make a nice, digested tree view by running:
$ python scripts/misc/vocab-summary.py build/vocab.jsonld -c build/vocab/context.jsonld -v
By using utilities in the whelk-core repository; you can generate a SPARQL construct file from the marcframe.json mappings, from which you can i turn generate a basic vocab file:
$ cd ../whelk-core/ && gradle -q vocabFromMarcFrame #.rq
To generate RDF descriptions from legacy MARC definitions, use:
$ python scripts/marcframe-skeleton-from-marcmap.py scripts/marc/marcmap.json --enums
See that script for other options.
Pipe the output to rdfpipe -ijson-ld:base=source/ -oturtle - to get it as Turtle.