Reference

concepttordf.collection

Concept module for mapping a concept to rdf.

This module contains methods for mapping a concept object to rdf according to the skos-ap-no standard

Example

>>> 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)
>>> bool(collection.to_rdf())
True
class concepttordf.collection.Collection

Bases: object

A class representing a concept collection.

property contactpoint: Contact

Contactpoint attribute.

Return type

Contact

property dct_identifier: str

Get for dct_identifier.

Return type

str

property description: dict

Description attribute.

Return type

dict

property identifier: str

Identifier attribute.

Return type

str

Returns

a string holding a valid uri

property members: List[Concept]

Members attribute.

Return type

List[Concept]

property name: dict

Name attribute.

Return type

dict

property publisher: str

Publisher attribute.

Return type

str

to_rdf(format='text/turtle', includeconcepts=True)

Maps the collection to rdf.

Parameters
  • format (str) – the format of the serialization

  • includeconcepts (bool) – if true details of concepts are included

Return type

str

Returns

serialization as a string according to format

concepttordf.concept

Concept module for mapping a concept to rdf.

This module contains methods for mapping a concept object to rdf according to the skos-ap-no standard

Example

>>> from concepttordf import Concept, Definition
>>>
>>> concept = Concept()
>>> concept.identifier = "http://example.com/concepts/1"
>>> concept.term = {"name": {"en": "concept"}}
>>>
>>> definition = Definition()
>>> definition.text = {"text": {"en": "abstract or generic idea"}}
>>> concept.definition = definition
>>>
>>> bool(concept.to_rdf())
True
class concepttordf.concept.Concept

Bases: object

A class representing a concept.

identifier

the uri identifying the concept

term

a dictionary describing the prefLabel

alternativeterm

a dictionary describing altLabel

hiddenterm

a dictionary describing the hiddenLabel

property alternativeterm: dict

Alternativeterm attribute.

Return type

dict

property alternativformulering: AlternativFormulering

Alternativformulering attribute.

Return type

AlternativFormulering

property bruksomrade: dict

Bruksomrade attribute.

Return type

dict

property contactpoint: Contact

Contacpoint attribute.

Return type

Contact

property datastrukturterm: dict

Datastrukturterm attribute.

Return type

dict

property dct_identifier: str

Get for dct_identifier.

Return type

str

property definition: Definition

Definition attribute.

Return type

Definition

property generalizes: GenericRelation

Generalizes attribute.

Return type

GenericRelation

property has_part: PartitiveRelation

Has part attribute.

Return type

PartitiveRelation

property hiddenterm: dict

Hiddenterm attribute.

Return type

dict

property identifier: str

Identifier attribute.

Return type

str

Returns

a string holding a valid uri

property is_part_of: PartitiveRelation

Is part of attribute.

Return type

PartitiveRelation

property modified: date

Modified attribute.

Return type

date

property publisher: str

Publisher attribute.

Return type

str

property related: AssociativeRelation

Related attribute.

Return type

AssociativeRelation

property replacedBy: List[Concept]

Replacedby attribute.

Return type

List[Concept]

property replaces: List[Concept]

Replaces attribute.

Return type

List[Concept]

property seeAlso: List[Concept]

Seealso attribute.

Return type

List[Concept]

property specializes: GenericRelation

Specializes attribute.

Return type

GenericRelation

property subject: dict

Subject attribute.

Return type

dict

property term: dict

Term attribute.

Return type

dict

to_rdf(format='text/turtle')

Maps the concept to rdf.

Parameters

format (str) – a valid serialization format.

Return type

str

Returns

a serialization of the RDF graph

property validinperiod: dict

Validinperiod attribute.

Return type

dict

concepttordf.contact

Contact module for mapping a dataService to rdf.

This module contains methods for mapping a contact object to rdf according to the vcard ontology

Example

>>> from concepttordf import Contact
>>>
>>> contact = Contact()
>>> contact.identifier = "http://example.com/contacts/1"
>>> contact.name = {'nb': 'Digitaliseringsdirektoratet'}
>>> bool(contact.to_rdf())
True
class concepttordf.contact.Contact

Bases: object

A class representing a vcard:Contact.

identifier

unique uri for contact

name

name of contact in various languages

email

email as a mailto link

telephone

telephone number

url

url to website

property email: str

Get/set for email.

Return type

str

property identifier: str

Identifier attribute.

Return type

str

Returns

a string holding a valid uri

property name: dict

Get/set for name.

Return type

dict

property telephone: str

Get/set for telephone.

Return type

str

to_rdf(format='text/turtle')

Maps the contact to rdf.

Available formats:
  • turtle (default)

  • xml

  • json-ld

Parameters

format (str) – a valid format.

Return type

str

Returns

a rdf serialization as a string according to format.

property url: str

Get/set for url.

Return type

str

concepttordf.betydningsbeskrivelse

Concept module for mapping abstract class Betydningsbeskrivelse to rdf.

class concepttordf.betydningsbeskrivelse.Betydningsbeskrivelse

Bases: ABC

A class representing a concept.

text
remark
scope
relationtosource
source
modified
example
property example: dict

Example attribute.

Return type

dict

Returns

a dict with key as language code (str) and value example (str)

property modified: date

Source attribute.

Return type

date

Returns

the date on which the item was last updated

property relationtosource: str

Relationtosource attribute.

Return type

str

Returns

a relationtype to source (str)

property remark: dict

Remark attribute.

Return type

dict

Returns

a dict with key as language code (str) and value remark (str)

property scope: dict

Scope attribute.

Return type

dict

Returns

a dict with key as language code (str) and value scope (str)

property source: dict

Source attribute.

Return type

dict

Returns

a dict with key as language code (str) and value remark (str)

property text: dict

Text attribute.

Return type

dict

Returns

a dict with key as language code (str) and value text (str)

class concepttordf.betydningsbeskrivelse.RelationToSource(value)

Bases: Enum

An enum representing relations to source.

concepttordf.alternativformulering

Module for helper class Definition.

class concepttordf.alternativformulering.AlternativFormulering

Bases: Betydningsbeskrivelse

A class representing a AlternativFormulering.

property example: dict

Example attribute.

Return type

dict

Returns

a dict with key as language code (str) and value example (str)

property modified: date

Source attribute.

Return type

date

Returns

the date on which the item was last updated

property relationtosource: str

Relationtosource attribute.

Return type

str

Returns

a relationtype to source (str)

property remark: dict

Remark attribute.

Return type

dict

Returns

a dict with key as language code (str) and value remark (str)

property scope: dict

Scope attribute.

Return type

dict

Returns

a dict with key as language code (str) and value scope (str)

property source: dict

Source attribute.

Return type

dict

Returns

a dict with key as language code (str) and value remark (str)

property text: dict

Text attribute.

Return type

dict

Returns

a dict with key as language code (str) and value text (str)

concepttordf.definition

Module for helper class Definition.

class concepttordf.definition.Definition

Bases: Betydningsbeskrivelse

A class representing a definition.

property example: dict

Example attribute.

Return type

dict

Returns

a dict with key as language code (str) and value example (str)

property modified: date

Source attribute.

Return type

date

Returns

the date on which the item was last updated

property relationtosource: str

Relationtosource attribute.

Return type

str

Returns

a relationtype to source (str)

property remark: dict

Remark attribute.

Return type

dict

Returns

a dict with key as language code (str) and value remark (str)

property scope: dict

Scope attribute.

Return type

dict

Returns

a dict with key as language code (str) and value scope (str)

property source: dict

Source attribute.

Return type

dict

Returns

a dict with key as language code (str) and value remark (str)

property text: dict

Text attribute.

Return type

dict

Returns

a dict with key as language code (str) and value text (str)

concepttordf.conceptrelation

Concept module for mapping abstract class ConceptRelation to rdf.

class concepttordf.conceptrelation.ConceptRelation

Bases: ABC

An abstract class representing a concept relation.

modified

date when relation was last modified

property modified: date

Modified attribute.

Return type

date

concepttordf.associativerelation

Concept module for mapping class associative relation to rdf.

class concepttordf.associativerelation.AssociativeRelation

Bases: ConceptRelation

A class representing a associative concept relation.

description

dictionary where key is language and value describing relation

associatedconcepts

list of related concepts

property associatedconcepts: List[Concept]

Associatedconcepts attributes.

Return type

List[Concept]

Returns

a list of related concepts

property description: dict

Description attribute.

Return type

dict

property modified: date

Modified attribute.

Return type

date

concepttordf.genericrelation

Concept module for mapping class GenericRelation to rdf.

class concepttordf.genericrelation.GenericRelation

Bases: ConceptRelation

A class representing a generic concept relation.

criterium

dictionary where key is language an value describing relation

genericconcepts

list of related concepts

property criterium: dict

Criterium attribute.

Return type

dict

property genericconcepts: List[Concept]

Generic concepts attributes.

Return type

List[Concept]

Returns

a list of generic concepts

property modified: date

Modified attribute.

Return type

date

property specialized_concepts: List[Concept]

Specialized concepts attributes.

Return type

List[Concept]

Returns

a list of specialized concepts

concepttordf.partitiverelation

Concept module for mapping class partitive relation to rdf.

class concepttordf.partitiverelation.PartitiveRelation

Bases: ConceptRelation

A class representing a partitive concept relation.

criterium

dictionary where key is language an value describing relation

partconcepts

list of related concepts

property criterium: dict

Criterium attribute.

Return type

dict

property is_part_of_concepts: List[Concept]

Is_part_of_concepts attributes.

Return type

List[Concept]

Returns

a list of concepts that this concept is part of

property modified: date

Modified attribute.

Return type

date

property partconcepts: List[Concept]

Partconcepts attributes.

Return type

List[Concept]

Returns

a list of related concepts