pOTTR: Converting spreadsheets to knowledge graphs with tabOTTR
Table of Contents
Converting spreadsheets to knowledge graphs with tabOTTR

Convert spreadsheets to OTTR template instances
- Authors
- Martin G. Skjæveland
- Issues
- https://gitlab.com/ottr/language/pOTTR/issues
1 Introduction
This chapter introduces tabOTTR [1] by giving exercises on using tabOTTR to annotate spreadsheets for specifying OTTR template instances.
More examples and introductory text can be found in the tabOTTR specification [1].
1.1 Prefixes
The following prefixes are used throughout the document, and may be used in the text input areas of the interactive examples without declaration.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix dbp: <http://dbpedia.org/ontology/> . @prefix ex: <http://example.com/ns#> . @prefix ottr: <http://ns.ottr.xyz/0.4/> . @prefix ax: <http://tpl.ottr.xyz/owl/axiom/0.1/> . @prefix rstr: <http://tpl.ottr.xyz/owl/restriction/0.1/> .
2 Expanding instances
2.1 Exercise: Add prefix declaration and instance data
The spreadsheet types.xlsx contains one sheet with instances of
the ex:Type
template that expands to RDF on the following form:
<http://example.com/data#a11> a <http://example.com/schema#ClassA> .
Download the spreadsheet and do the following.
Add a new prefix declaration with the prefix test
and namespace
http://example.com/test#
to the already existing prefix
instruction in the first sheet of the spreadsheet file, and all
more instances to the existing template instruction:
instance data | type data |
---|---|
test:b12 | schema:ClassB |
test:b13 | schema:ClassB |
test:b14 | schema:ClassB |
Expand the spreadsheet.
2.2 Exercise: Add tabOTTR template instruction
The second sheet of the spreadsheet file types.xlsx contains data which is not annotated with tabOTTR instructions. Add the necessary tabOTTR instructions so that the row
c11 | ClassC |
expands to
<http://example.com/test#c11> a <http://example.com/schema#ClassC> .
Try to solve the exercise without altering the data, but rather
create new columns that use spreadsheet the formula CONCATENATE
to add the required prefixes to the data. (Note that not all
functions are supported by the external API that WebLutra/Lutra
uses, however CONCATENATE
is, (but CONCAT
is not).)
Use the indices of the template instruction to select the columns that should become instance arguments.
2.3 Exercise: Expand NamedPizza instances
The spreadsheet PizzaOntologyInstances.xlsx contains several instances of the NamedPizza template.
Download the spreadsheet and note how lists are defined, and how types are set. Expand the spreadsheet.
3 Adapting tabular data to template signatures
3.1 Exercise: Adapt and instantiate Organization
The spreadsheet organizations.xlsx contains data about
organisations. Add the neccesary tabOTTR instructions to the
spreadsheet so that the data can be expanded as instances of the
ex:Organization
template below. You may also make adjustments to
the template ex:Organization
if you wish.
Tips:
- Remember to add a prefix instruction, if you use prefixes.
- Try to use auto typing: https://spec.ottr.xyz/tabOTTR/0.3/#2.3.3_auto_typing
- Invent an IRI for each organization, use a blank node, or change
the signature of
ex:Organization
by setting a blank node as default value. - You can use the formula
=DATEDIF([cellref], TODAY(), "y")
to calculate the difference in years between[cellref]
and today. Note however, that this function is not supported by the external API that WebLutra/Lutra uses, therefore you must copy the contents of the column into a new column and remove the column containing the formulas.
3.2 Exercise: Adapt and instantiate Person
The spreadsheet persons.xlsx contains data about persons. Add the
neccesary tabOTTR instructions to the spreadsheet so that the data
can be expanded as instances of the ex:Person
template below.
Try to extend the template to include all the information in the
spreadsheet.
4 References
- Tabular OTTR template instances http://spec.ottr.xyz/tabOTTR/0.3/
5 Appendix
5.1 WebLutra
The web application that drives the interactive examples in this primer, called WebLutra, uses Lutra, the reference application for OTTR. Both applications are open source and available at http://gitlab.com/ottr/lutra/lutra. If you experience errors or have suggestions for improvements, please take a look at existing issues or file a new issue: http://gitlab.com/ottr/lutra/lutra/issues