How the scripts work

LIFT features a set of five transformation scripts written in Python 2.7. LIFT leverages two libraries:

  • lxml to find and select the relevant TEI constructs from the input XML document;

  • RDFLib to create the RDF triples forming the knowledge graph.

Any of the scripts can be applied to your TEI document. If you use the scripts as is, make sure to read LIFT’s encoding guidelines at Prepare your TEI document and update your input TEI document accordingly.

A Jupyter notebook walking through LIFT’s TEI to RDF transformation line-by-line

The section The RDF graph displays the input TEI constructs next to the output RDF statements. A Jupyter notebook, available at this link, walks you through the scripts line-by-line.

You can read a non-interactive preview of the notebook by following the link above, or you can install Jupyer to access the notebook interactively. The second option requires a minimum familiarity with the command line (the Programming Historian provides excellent introductory tutorials for Windows as well as Mac/Linux users).

In order to access the notebook interactively

  1. open Terminal or Prompt. If Python is already installed on your machine, run pip install notebook (visit https://jupyter.org/install for further help);

  2. download the notebook;

  3. in Terminal or Prompt navigate to the folder where the notebook was saved;

  4. run juptyter notebook to open Jupyter on your browser;

  5. from the browser, click on TEItoRDF.ipynb to access the notebook.

Modify the scripts and/or run them locally

After reading the notebook, you should be able to modify LIFT’s scripts to meet the needs of your project. You can, for example, change how LIFT extracts information from the input file to avoid modifying your original TEI encoding, or you can enrich the knowledge graph with new RDF triples.

To modify LIFT the scripts and/or run them locally

  1. go to LIFT’s repository on Github and download the scripts;

  2. open and change the scripts with an editor of your choice (remeber to update the path to the input TEI document (modify the line tree = etree.parse('input.xml') at the very beginning of the script);

  3. to run the transformation locally
    1. open your Terminal or Prompt;

    2. navigate to the folder where the scripts are;

    3. run python [name-of-your-script].py.