A library for mapping a concept collection to rdf
Project description
concepttordf
A small Python library for mapping a concept collection to the skos-ap-no specification.
Usage
Install
% pip install concepttordf
Getting started
To create a SKOS-AP-NO concept collection:
from concepttordf import Collection, Concept, Definition
# Create collection object
collection = Collection()
collection.identifier = "http://example.com/collections/1"
collection.name = {"en": "A concept collection"}
collection.name = {"nb": "En begrepssamling"}
collection.publisher = "https://example.com/publishers/1"
# Create a concept:
c = Concept()
c.identifier = "http://example.com/concepts/1"
c.term = {"name": {"nb": "inntekt", "en": "income"}}
definition = Definition()
definition.text = {"nb": "ting man skulle hatt mer av",
"en": "something you want more of"}
c.definition = definition
# Add concept to collection:
collection.members.append(c)
# get rdf representation in turtle (default)
rdf = collection.to_rdf()
print(rdf)
Will print the concept according to the specification:
@prefix dcat: <http://www.w3.org/ns/dcat#> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix ns1: <https://data.norge.no/vocabulary/skosno#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix skosno: <http://difi.no/skosno> .
@prefix skosxl: <http://www.w3.org/2008/05/skos-xl#> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://example.com/collections/1> a skos:Collection ;
rdfs:label "En begrepssamling"@nb ;
dct:publisher <https://example.com/publishers/1> ;
skos:member <http://example.com/concepts/1> .
<http://example.com/concepts/1> a skos:Concept ;
ns1:betydningsbeskrivelse [ a ns1:Definisjon ;
rdfs:label "something you want more of"@en,
"ting man skulle hatt mer av"@nb ] ;
skosxl:prefLabel [ a skosxl:Label ;
skosxl:literalForm "income"@en,
"inntekt"@nb ] .
Development
Requirements
% pipx install poetry
% pipx install nox
% pipx inject nox nox-poetry
Install dev tools
% git clone https://github.com/Informasjonsforvaltning/concepttordf.git
% cd concepttordf
% pyenv install 3.8.2
% pyenv install 3.9.6
% pyenv local 3.8.2 3.9.6
% poetry install
Run all tests
% nox
Run all tests with coverage reporting
% nox -rs tests
Debugging
You can enter into Pdb by passing --pdb
to pytest:
nox -rs tests -- --pdb
You can set breakpoints directly in code by using the function breakpoint()
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
concepttordf-2.0.1.tar.gz
(16.2 kB
view details)
Built Distribution
File details
Details for the file concepttordf-2.0.1.tar.gz
.
File metadata
- Download URL: concepttordf-2.0.1.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.13.0-1023-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 894d4713cc1329724e01b40a2b38fab018ac0253d98bb75ac690dee3af64e426 |
|
MD5 | d7967d5eb7637334df1b0acb5cdfc917 |
|
BLAKE2b-256 | 21ea8cb5d4181274e34a273ee82cac5f5bb5ca3c36322e177e911a875e426e2c |
File details
Details for the file concepttordf-2.0.1-py3-none-any.whl
.
File metadata
- Download URL: concepttordf-2.0.1-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.13.0-1023-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f0bb257b5c0f9f201bfb89bc81cb93c01d210fa1cb4fc47182171247317c6c0 |
|
MD5 | ea0cee88e77efba212f6cd030f3da4ca |
|
BLAKE2b-256 | de0ac62c06168f7cbe9bd74f587b60e669e2b85e4e411f9de1c887937e23188e |