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",
"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,
"A concept collection"@en ;
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.10.12
% pyenv install 3.11.9
% pyenv install 3.12.7
% pyenv local 3.10.12 3.11.9 3.12.7
% 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().
Metadata
Release files for concepttordf 3.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| concepttordf-3.1.5.tar.gz | 16.1 kB | Without provenance | Details for concepttordf-3.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| concepttordf-3.1.5-py3-none-any.whl | Python 3 | none | any | Details for concepttordf-3.1.5-py3-none-any.whl |
Total release size: 38.3 kB
Release files / concepttordf-3.1.5.tar.gz
| Download URL | concepttordf-3.1.5.tar.gz |
|---|---|
| Size | 16.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
326dd0c7ae745e507ac5a4306e4a903a38cc4d08674e3eb1489ef2c551473d5c
|
|
BLAKE2b-256 checksum How to use checksums |
a7fdf4804aaf83b3ae330af653b545d33c4a18880bb12b6fb67aba498dc457e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1020-azure
|
Release files / concepttordf-3.1.5-py3-none-any.whl
| Download URL | concepttordf-3.1.5-py3-none-any.whl |
|---|---|
| Size | 22.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b05cccd48ff03a54550177a13bc1daf54bafe1b3ce0b23d1d8b7d81005050165
|
|
BLAKE2b-256 checksum How to use checksums |
5167bc74b91f629e9aedde1289dcfacf2c78258648f50c2803d53e25e1df3a0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1020-azure
|
Security for concepttordf 3.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.