Skip to content
Snippets Groups Projects

TENET - Tool for Extraction using Net Extension by (semantic) Transduction


TENET is a python library to construct logical representations (OWL ontology) from textual documents. Its development is based on the W3C Semantic Web standards (RDF, OWL, SPARQL). It requires, as input, a set of pivot structures representing the document to be analysed, and gives as output a set of RDF-OWL triples forming an ontology, composed of classes, properties, instances and logical relations between these elements.

This library is currently under development, and therefore in unstable state. Structures supported as input are AMR graphs (in AMR Linked Data Turtle format) or UNL graphs (in UNL-RDF Turtle format).

1 - Environment Setup

The python code has been tested under Python 3.7 and Linux Manjaro, but should be run on most common systems (Linux, Windows, Mac). All dependencies are listed in requirements.txt.

The test directory contains evaluation files with test corpus, and script showing usage examples.

2 - Library Usage for AMR Graphs

The script test_tenet_main.py (test directory) gives an example of using the library.

Two main methods are proposed to create an ontology from a file in amrlib format (AMR Linked Data Turtle format), or from a directory containing several amrlib files. These two methods take as parameters the path of the file or directory to be processed, and also some optional parameters.

The following code can be used to create an ontology from an AMR-Lib file:

import tenet

factoids = tenet.create_ontology_from_amrld_file(amrld_file_path, onto_prefix=<onto_prefix>, out_file_path=<out_file_path>, technical_dir_path=<technical_dir_path>)

The following code can be used to create an ontology from an AMR-Lib directory:

import tenet

factoids = tenet.create_ontology_from_amrld_dir(amrld_dir_path, onto_prefix=<onto_prefix>, out_file_path=<out_file_path>, technical_dir_path=<technical_dir_path>)

For more details on these methods, see the code in tenet/main.py.

3 - Library Usage for UNL Graphs

The addition of core methods for supporting UNL graphs is also planned. While waiting for the development of these methods, it is possible to analyze UNL graphs by positioning on an old version (label 0.2.1), or by adapting the existing scripts.

4 - Quick Execution Example to Test the Library

To quickly test the tenet library named, follow these steps:

  1. Clone the Git repository using the SSH link:

git clone gitlab@gitlab.tetras-libre.fr:tetras-mars/tenet.git

  1. Change into the project directory ('cd tenet')

  2. Create and activate a virtual environment (optional but recommended):

python3 -m venv tenet_env

source tenet_env/bin/activate

  1. Make sure you have Python 3 installed. Install the required dependencies.

pip3 install -r requirements.txt

  1. Run the test script located at tests/main_tests/test_main_owl_extraction.py. This script contains the tests for the main owl extraction functionality.

  2. Review the test results:

  • The test results will be displayed in the console output (logs).
  • Additionally, the test script may generate output files in the tests/main_tests/test_owl_output directory. Check this directory for any relevant files or logs generated during the test execution.

5 - Content

The library groups several packages in the tenet subdirectory. The main methods are defined in the main module (main.py). The extract.py file has also been developed for command line use (>> python3 extract.py --source_corpus input-data). The configuration of the library can be adapted by modifying the logging.conf file.