Skip to main content

A small Python library for mapping a concept collectionto the skos-ap-no specification

Project description

concepttordf

A small Python library for mapping a concept collection to the skos-ap-no specification.

Usage

Install

% pip install -i concepttordf

Getting started

To create a SKOS-AP-NO concept collection:

from concepttordf.collection import Collection
from concepttordf.concept import Concept
from concepttordf.definition import 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: <http://difi.no/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

  • python3
  • pipenv

Install

% git clone https://github.com/Informasjonsforvaltning/concepttordf.git
% cd concepttordf
% pipenv install
% pipenv shell
% pipenv install --dev -e .

Run all tests

% pytest -rA

With simple coverage-report in output:

% pytest -rA --cov-report term-missing --cov=concepttordf tests/

Wit coverage-report to html:

% pytest -rA --cov-report html --cov=concepttordf tests/

Debugging

You can enter into Pdb by passing --pdb to pytest:

pytest --pdb -rA --cov-report term-missing --cov=concepttordf tests/

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.0rc1.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: concepttordf-1.0.0rc1.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for concepttordf-1.0.0rc1.tar.gz
Algorithm Hash digest
SHA256 ef15575b49b4d1e8fb35e513739e99f159f3333b57980b5ca8af4b96d5b586cd
MD5 ddacbe46d70e03638682033f1366568f
BLAKE2b-256 1c66038a9d3cbad9cb9bbdb9755a271189521867c0541b35deabdc0e5a55399b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: concepttordf-1.0.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for concepttordf-1.0.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 66713db202bdba4641ceb0f156fec50a076e21e79a85691cb7a66ef41cde74c7
MD5 95ad767eb626373bbf384e3335045766
BLAKE2b-256 cea0af22dfcce33b57a7422a0a38c53e277c880914d0de613716bae11622f1c0

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