Skip to main content

A library for mapping a concept collection to rdf

Project description

Tests codecov PyPI Read the Docs

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

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

Install

% git clone https://github.com/Informasjonsforvaltning/concepttordf.git
% cd concepttordf
% pyenv install 3.8.2
% pyenv install 3.7.6
% pyenv local 3.8.2 3.7.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


Download files

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

Source Distribution

concepttordf-1.0.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

concepttordf-1.0.0-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: concepttordf-1.0.0.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.2 Linux/5.0.0-1035-azure

File hashes

Hashes for concepttordf-1.0.0.tar.gz
Algorithm Hash digest
SHA256 033e94f42572d1f4f3a4623569857a357ff073027bd0898b11ef2a57aed95b66
MD5 dc5bdf99be4be59db0bb429432bf6e56
BLAKE2b-256 80be70e950abb6f680a725834a8c6a349844a3c40d322bbdc2fa0dc584970289

See more details on using hashes here.

File details

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

File metadata

  • Download URL: concepttordf-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.2 Linux/5.0.0-1035-azure

File hashes

Hashes for concepttordf-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f4cb8c8b309701bd9c64a344dcf560c6406c21a2b75818154e215e53af02bf85
MD5 599cf6a96d9d169986c1068906a81c0d
BLAKE2b-256 d9b78e94b7a96197a42785e5f954480a58677a572f96c5207eb617dcb13763b5

See more details on using hashes here.

Supported by

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