Getting Started
The basic idea of a TVD (Tabular Vocabulary Definition) is that it allows the definition terms used in an RDF vocabulary in a tabular format. These can be generated in spreadsheets or anything that can export a csv file. Each row comprises the definition of a single RDF term. Each column contains information about one aspect of the term, the column header is used to identify which aspect. A YAML config file defines how each column is processed. TVD2RDF allows a TVD saved as a CSV file to be converted into RDF encoded vocabulary definitions in a variety of serialization formats.
Installation
TVD2RDF can be installed from its git repository on codeberg.org. You must have installed Python version 3.12 or higher, including pip, and software to clone git repositories.
First, clone the git repository into a local folder:
$ git clone https://codeberg.org/philbarker/TabularVocabDef.git
$ cd TabularVocabDef
It is recommended to use a virtual environment for TVD2RDF:
$ python -m venv venv
$ source venv/bin/activate
Install and check version:
(venv) $ pip install .
(venv) $ tvd -v
tvd 0.5.3
Optional: install dependencies used in development only:
(venv) $ pip install .[dev]
Basic Usage
You will need a CSV file containing the Tabular Vocabulary Definition, and a YAML config file that describes how to interpret this file.
The TVD can be edited any tool that exports CSV files, such as spreadsheet
software. The first row of the CSV will be treated as column headings. The
only required headings are Type and URI which map to the type of term
being described and ther term’s URI. Other common headings in the CSV stand
for the name and definition of the term.
An example of a very simple TVD:
Type |
URI |
Label |
Comment |
Property |
dct:title |
Title |
A name given to the resource. |
TVD2RDF comes with a default config file which is used if no other file is specified. For the simple example above the default is sufficient. So if the tabular definition above is entered into a suitable tool, exported as a CSV file and saved as ex-tvd.csv in the TabularVocabDef directory where we installed TVD2RDF, the following will convert it to RDF:
(venv) $ tvd convert ex-tvd.csv
# RDF generated by TVD2RDF Converter v0.5.2.
@prefix dct: <http://purl.org/dc/terms/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
dct:title a rdf:Property ;
rdfs:label "Title" ;
rdfs:comment "A name given to the resource." .
The help for the tvd convert command provides information on further options
for conversion, such as different serialization formats and writing the RDF to
a file:
(venv) $ tvd convert -h
usage: tvd convert [-h] [-ns <namespace filename>]
[-of <output format, e.g. turtle, n3, xml>] [-c config filename]
<tvd filename> [<output filename>]
Convert a tvd from CSV to RDF.
positional arguments:
<tvd filename>
<output filename>
options:
-h, --help show this help message and exit
-ns <namespace filename>, --namespace_fn <namespace filename>
-of <output format, e.g. turtle, n3, xml>, --output_fmt <output format, e.g. turtle, n3, xml>
-c config filename, --config_fn config filename
Further Usage
Basic information about terms can be encoded in a TVD without modifying the default configuration.
Types of term that are covered
Definitions of OWL Ontologies, RDF Classes, RDFS Properties, SKOS Concept Schemes,
and SKOS Concepts. Use one of the following key words in the Type column of
the TVD: Ontology, Class, Property, Concept Scheme, Concept.
Note
It is not intended that a TVD be used to define complex OWL Ontologies with defined axioms and named instances such as would be better managed with a tool such as protege.
The inclusion of Ontology in the type of “term” that may be defined in a TVD allows for sets of RDF definitions that can be processed with tools such as pyLode that look for information for an owl:Ontology.
Attributes of terms that may be defined
In all cases the coverage of term attributes that may be defined is somewhat limited, but includes a label or title, a definition or description, a note about the term, classes in the range and domain of a property and relationships between concepts using various SKOS terms.
Note
The domain and range of a property are indicated using schema.org domainIncludes and rangeIncludes by default.
This gives behaviour that is more intuitive to general users who are not familiar with rdf:domain and range when there is more than one class specified.
Default mapping from column headings to RDF properties
Entries under the column headings URI and Type are required and provide the URI and Type for the term being defined.
The column headings Related Term and Relationship are used to express relationships between terms, see below.
By default, for under following column headings will be mapped as shown for all types of term:
- Comment:
maps to
rdfs:comment- Date:
maps to
dcterms:date- Notation:
maps to
skos:notation- Usage:
maps to
skos:scopeNote
For Properties only:
- domainIncludes:
maps to
schema:domainIncludes- rangeIncludes:
maps to
schema:rangeIncludes
Entries under other column headings will be mapped according to the type of term being defined:
- Label:
maps to
rdfs:labelfor Ontologies, Classes and Propertiesdct:titlefor Concept Schemesskos:prefLabelfor Concepts
- Definition:
maps to
dct:descriptionfor Concept Schemesskos:definitionfor Concepts
Warning
The default coverage may change in future versions.
Multiple object values
Where the value of an attribute may be multiple URIs, for example with domain and
range includes, several values may be entered in a cell in the TVD is separated
by one of the following characters: ,, ;, \n (new line), or combinations
thereof. This does not apply to literal values such as the label or definition
of a term.
Relationships between terms
A pair of columns headed Related Term and Relationship may be used to specify relationships between terms. Currently the default config covers the following relationships that may be entered in the Relatinoship column:
broadMatchforskos:broadMatchbroaderforskos:broadercloseMatchforskos:closeMatchhasTopConceptforskos:hasTopConceptinSchemeforskos:inSchemenarrowMatchforskos:narrowMatchnarrowerforskos:narrowertopConceptOfforskos:topConceptOf
Further information on configuring Tabular Vocabulary Definitions is provided in the following section.
Example TVDs
The following is an example of a small vocabulary comprising an RDF classes and Properties defined by a TVD using only the default column headings.
Type |
URI |
Label |
Comment |
Usage |
Domain Includes |
Range Includes |
|---|---|---|---|---|---|---|
Ontology |
ex: |
Test Terms |
A test RDF vocabulary. |
Used for testing VocabDef |
||
Class |
ex:Document |
Document |
A written resource. |
Documents may be in physical or digital media. |
||
Property |
ex:createdDateTime |
Created Date Time |
The date and Time stamp when the Resource was created. |
xsd:dateTime |
||
Property |
ex:description |
Description |
A short account of the resource. |
|||
Property |
ex:author |
Author |
The organization or person who created the document. |
ex:Document ex:File |
sdo:Person sdo:Organization |
which is processed to
1# RDF generated by TVD2RDF Converter v0.5.2.
2@prefix ex: <https://example.org/terms#> .
3@prefix owl: <http://www.w3.org/2002/07/owl#> .
4@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
5@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
6@prefix sdo: <https://schema.org/> .
7@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
8@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
9
10ex: a owl:Ontology ;
11 rdfs:label "Test Terms" ;
12 rdfs:comment "A test RDF vocabulary." ;
13 skos:scopeNote "Used for testing VocabDef" .
14
15ex:Document a rdfs:Class ;
16 rdfs:label "Document" ;
17 rdfs:comment "A written resource." ;
18 skos:scopeNote "Documents may be in physical or digital media." .
19
20ex:author a rdf:Property ;
21 rdfs:label "Author" ;
22 rdfs:comment "The organization or person who created the document." ;
23 sdo:domainIncludes ex:Document,
24 ex:File ;
25 sdo:rangeIncludes sdo:Organization,
26 sdo:Person .
27
28ex:createdDateTime a rdf:Property ;
29 rdfs:label "Created Date Time" ;
30 rdfs:comment "The date and Time stamp when the Resource was created." ;
31 sdo:rangeIncludes xsd:dateTime .
32
33ex:description a rdf:Property ;
34 rdfs:label "Description" ;
35 rdfs:comment "A short account of the resource." .
This second example is of a TVD which defines a small Concept Scheme:
Type |
URI |
Label |
Definition |
Notation |
Related term |
Relationship |
date |
|
|---|---|---|---|---|---|---|---|---|
Concept Scheme |
ex:colours |
Colours |
An example concept scheme for some colours. |
ex:red ex:green ex:blue |
hasTopConcept |
2026-01-16 |
||
Concept |
ex:red |
Red |
The primary colour wavelength 625–750nm. |
r |
ex:colours |
inScheme |
||
Concept |
ex:red |
FF0000 |
ex:colours |
topConceptOf |
||||
Concept |
ex:green |
Green |
The primary colour wavelength 500-565nm. |
g, 00FF00 |
ex:colours |
inScheme topConceptOf |
||
Concept |
ex:blue |
Blue |
The primary colour wavelength 450-485nm. |
b, 0000FF |
||||
Concept |
ex:pink |
Pink |
A lighter shade of red. |
660000 |
ex:red |
broader |
||
Concept |
ex:pink |
ex2:rose |
closeMatch |
which is processed to:
1# RDF generated by TVD2RDF Converter v0.5.0b2.
2@prefix dcterms: <http://purl.org/dc/terms/> .
3@prefix ex: <https://example.org/terms#> .
4@prefix ex2: <https://example.org/moreterms#> .
5@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
6
7ex:colours a skos:ConceptScheme ;
8 dcterms:date "2026-01-16" ;
9 dcterms:description "An example concept scheme for some colours." ;
10 dcterms:title "Colours" ;
11 skos:hasTopConcept ex:blue,
12 ex:green,
13 ex:red .
14
15ex:blue a skos:Concept ;
16 skos:definition "The primary colour wavelength 450-485nm." ;
17 skos:notation "b, 0000FF" ;
18 skos:prefLabel "Blue" .
19
20ex:green a skos:Concept ;
21 skos:definition "The primary colour wavelength 500-565nm." ;
22 skos:inScheme ex:colours ;
23 skos:notation "g, 00FF00" ;
24 skos:prefLabel "Green" ;
25 skos:topConceptOf ex:colours .
26
27ex:pink a skos:Concept ;
28 skos:broader ex:red ;
29 skos:closeMatch ex2:rose ;
30 skos:definition "A lighter shade of red." ;
31 skos:notation "660000" ;
32 skos:prefLabel "Pink" .
33
34ex:red a skos:Concept ;
35 skos:definition "The primary colour wavelength 625–750nm." ;
36 skos:inScheme ex:colours ;
37 skos:notation "FF0000",
38 "r" ;
39 skos:prefLabel "Red" ;
40 skos:topConceptOf ex:colours .