Getting Started
===============
.. contents::
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:
.. code-block:: console
$ git clone https://codeberg.org/philbarker/TabularVocabDef.git
$ cd TabularVocabDef
It is recommended to use a virtual environment for TVD2RDF:
.. code-block:: console
$ python -m venv venv
$ source venv/bin/activate
Install and check version:
.. code-block:: console
(venv) $ pip install .
(venv) $ tvd -v
tvd 0.5.3
Optional: install dependencies used in development only:
.. code-block:: console
(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:
.. code-block:: console
(venv) $ tvd convert ex-tvd.csv
# RDF generated by TVD2RDF Converter v0.5.2.
@prefix dct: .
@prefix rdf: .
@prefix rdfs: .
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:
.. code-block:: console
(venv) $ tvd convert -h
usage: tvd convert [-h] [-ns ]
[-of