Skip to main content

A library for mapping a concept collection to rdf

Project description

concepttordf

!Tests codecov PyPI Read the Docs

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().

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

concepttordf-3.0.1.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

concepttordf-3.0.1-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file concepttordf-3.0.1.tar.gz.

File metadata

  • Download URL: concepttordf-3.0.1.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.12 Linux/6.11.0-1018-azure

File hashes

Hashes for concepttordf-3.0.1.tar.gz
Algorithm Hash digest
SHA256 e4b0e65707e1796a3723fcba5202f8d2538dfe92192d0d7bd65ad2a37f53e603
MD5 b4a5047d6c97d60831f63e2ca4fae516
BLAKE2b-256 142cc9c9ab098b9e24b05597d344a80f318d84d0ab90f960a97181e4b43e5787

See more details on using hashes here.

File details

Details for the file concepttordf-3.0.1-py3-none-any.whl.

File metadata

  • Download URL: concepttordf-3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.12 Linux/6.11.0-1018-azure

File hashes

Hashes for concepttordf-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dd7b5e1333dda1c0827a37d4441300000bf97fd224cd22a6c5b2df0c0faf6567
MD5 3b5d9e4f3f6c09de6a12ed9000a26de4
BLAKE2b-256 155ae57ddca1b629f40964b79f35cb4f002a6ded2dd49510740d12bc82c159f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page