Skip to content

maayan25/tp-ont

Repository files navigation

TP-ONT: A Task-Planning Ontology

License: CC BY 4.0 DOI HuggingFace Dataset Python 3.12+

TP-ONT is an ontology designed for task planning and knowledge representation. This repository provides:

  1. The current ontology definition
  2. Tools for Knowledge Graph (KG) and ontology construction from PDDL
  3. Scripts to align the ontology with general knowledge ontologies
  4. Scripts to run a planner on PDDL files to generate plans to be added to the KG.

Overview

Quick Start & Ontology Files

If you just want to view or query the ontology:

  • Ontology File: Find the TBox / ontology definitions in tp-ont.owl or ontologies/ for both the dynamic and static ontologies.
  • KG File: Find the raw ABox / knowledge graph definitions in knowledge_graphs for the raw and materialised knowledge graphs.
  • Sample SPARQL Queries: the examples folder contains sample SPARQL queries to explore the ontology and knowledge graph. They can be run with the run_queries.py script and a Jena Fuseki server.
  • Compatibility: Compatible with Protégé, rdflib, or any standard OWL/RDF reasoner.

Installation & Setup

Clone the repository with its submodules:

git clone --recursive git@github.com:maayan25/tp-ont.git
cd tp-ont

Environment Note: Tested on Ubuntu 24.04 with Python 3.12.3. We recommend using Python 3.12 for best compatibility.

Setup Python Environment

Choose either venv or Conda to set up your environment:

  1. Using venv:
python3 -m venv .venv
source .venv/bin/activate
  1. Using Conda (Recommended if on another Python version):
conda create -n tp-ont python=3.12
conda activate tp-ont

Install dependencies

Install the required packages

python3 -m pip install -r requirements.txt

For KG Construction

Install the libxcb-cursor-dev package for visualisation support:

sudo apt update && sudo apt install libxcb-cursor-dev

For OntoAligner

Download nltk required data:

python3 -m pip install nltk
python3 -c "import nltk; nltk.download('averaged_perceptron_tagger_eng')"

Running the Pipeline

KG Construction

  1. Single domain KG construction: You can run the PDDLKGConstructor.py script to create a knowledge graph for a single domain. The script takes the path to the PDDL domain and problem files as input, and outputs the corresponding knowledge graph in RDF format.
cd scripts/kg_construction
python3 PDDLKGConstructor.py --domain <path_to_domain_file> --problem <path_to_problem_file>
  1. Batch KG construction: You can use create_kg.sh to run multiple domains at once. The script takes a list of PDDL domain names as input, and outputs the corresponding knowledge graphs in RDF format. It uses the instance-1 problem file as the default problem file for each domain as the input, which can be changed in the script if needed. The output knowledge graphs are saved in the knowledge_graphs directory.
cd scripts/kg_construction
./create_kg.sh

Ontology Construction

Once you have created the KG, you can extraact the ontology schema (TBox) with extract_tbox_from_kg.py:

cd scripts/kg_construction
python3 extract_tbox_from_kg.py

Plan Generation & Simulation

Sample plan instances can be found in results/planner_outputs.

Prerequisites

To generate new plans and state simulations, make sure you have installed the following:

Running instructions
  1. Run the planner on a single problem file: You can run the RunFDPlanner.py script to generate a plan for a single problem file. The script takes the path to the PDDL domain and problem files as input, and outputs the corresponding plan in text format.
  2. Run the planner on multiple problem files: You can use run_planner.sh to run the planner on multiple problem files at once. Both scripts will output the generated plans and a corresponding state simulation of the plan execution. The files are saved in the results/planner_outputs directory.

License

This project is licensed under the Creative Commons Attribution 4.0 International License.

About

A Task-Planning Ontology

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors