Skip to content

Commit

Permalink
Docs update and version increase
Browse files Browse the repository at this point in the history
  • Loading branch information
alkidbaci committed Feb 24, 2025
1 parent 5b9e506 commit 248bc3a
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 107 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[![Downloads](https://static.pepy.tech/badge/ontolearn)](https://pepy.tech/project/ontolearn)
[![Downloads](https://img.shields.io/pypi/dm/ontolearn)](https://pypi.org/project/ontolearn/)
[![Coverage](https://img.shields.io/badge/coverage-86%25-green)](https://ontolearn-docs-dice-group.netlify.app/usage/09_further_resources#code-coverage)
[![Pypi](https://img.shields.io/badge/pypi-0.8.1-blue)](https://pypi.org/project/ontolearn/0.8.1/)
[![Docs](https://img.shields.io/badge/documentation-0.8.1-yellow)](https://ontolearn-docs-dice-group.netlify.app/usage/01_introduction)
[![Pypi](https://img.shields.io/badge/pypi-0.9.0-blue)](https://pypi.org/project/ontolearn/0.9.0/)
[![Docs](https://img.shields.io/badge/documentation-0.9.0-yellow)](https://ontolearn-docs-dice-group.netlify.app/usage/01_introduction)
[![Python](https://img.shields.io/badge/python-3.10.13+-4584b6)](https://www.python.org/downloads/release/python-31013/)
 

Expand All @@ -18,6 +18,7 @@ $E^+$ and $E^-$, learning [OWL Class expression](https://www.w3.org/TR/owl2-synt
$$\forall p \in E^+\ \mathcal{K} \models H(p) \wedge \forall n \in E^-\ \mathcal{K} \not \models H(n).$$

To tackle this supervised learning problem, ontolearn offers many symbolic, neuro-symbolic and deep learning based Learning algorithms:
- **TDL** → Tree-based OWL Class Expression Learner for Large Graphs
- **Drill** → [Neuro-Symbolic Class Expression Learning](https://www.ijcai.org/proceedings/2023/0403.pdf)
- **EvoLearner** → [EvoLearner: Learning Description Logics with Evolutionary Algorithms](https://dl.acm.org/doi/abs/10.1145/3485447.3511925)
- **NCES2** → [Neural Class Expression Synthesis in ALCHIQ(D)](https://papers.dice-research.org/2023/ECML_NCES2/NCES2_public.pdf)
Expand Down Expand Up @@ -121,7 +122,7 @@ print(owl_expression_to_sparql(expression=h))
save_owl_class_expressions(expressions=h,path="#owl_prediction")
```

Fore more please refer to the [examples](https://github.com/dice-group/Ontolearn/tree/develop/examples) folder.
Fore more please refer to the [examples](https://github.com/dice-group/Ontolearn/tree/develop/examples) folder.

## ontolearn-webservice

Expand Down
40 changes: 19 additions & 21 deletions docs/usage/01_introduction.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,44 @@
# About Ontolearn

**Version:** ontolearn 0.8.1
**Version:** ontolearn 0.9.0

**GitHub repository:** [https://github.com/dice-group/Ontolearn](https://github.com/dice-group/Ontolearn)

**Publisher and maintainer:** [DICE](https://dice-research.org/) - data science research group of [Paderborn University](https://www.uni-paderborn.de/en/university).

**Contact**: [onto-learn@lists.uni-paderborn.de](mailto:onto-learn@lists.uni-paderborn.de)
**Contact**: [cdemir@mail.uni-paderborn.de](mailto:cdemir@mail.uni-paderborn.de), [alkid@mail.uni-paderborn.de](mailto:alkid@mail.uni-paderborn.de)

**License:** MIT License

--------------------------------------------------------------------------------------------

Ontolearn is an open-source software library for explainable structured machine learning in Python.
OntoLearn is an open-source software library designed for explainable structured machine learning in OWL 2.0 ontologies.
Our primary objective is to leverage structured learning techniques within the OWL framework, providing a robust and
interpretable approach to ontology-based machine learning.

Ontolearn started with the goal of using _Explainable Structured Machine Learning_
in OWL 2.0 ontologies and this
exactly what our library offers. The main contribution are the exclusive concept learning
algorithms that are part of this library. Currently, we have 6 fully functioning algorithms that
learn concept in description logics. Papers can be found [here](09_further_resources.md).
One of OntoLearn’s key contributions is its exclusive concept learning algorithms, specifically tailored for Description
Logics (DL). The library currently includes nine fully functional algorithms capable of learning complex concepts in DL.
For further details and references, relevant research papers can be found [here](09_further_resources.md).

For the base (core) module of Ontolearn we use [owlapy](https://github.com/dice-group/owlapy). _Owlapy_ is a python package
based on owlapi (the java counterpart), and implemented by us, the Ontolearn team.
For the sake of modularization we have moved it in a separate repository.
The modularization aspect helps us to increase readability and reduce complexity.
So now we use owlapy not only for OWL 2 entities representation but
for ontology manipulation and reasoning as well.
At the core of OntoLearn lies [Owlapy]((https://github.com/dice-group/owlapy)), a Python package inspired by the OWL API (its Java counterpart) and developed by
the OntoLearn team. To enhance modularity, readability, and maintainability, we have separated Owlapy from Ontolearn into an
independent repository. This modular approach allows Owlapy to serve not only as a framework for representing OWL 2
entities, but also as a tool for ontology manipulation and reasoning.

---------------------------------------

**Ontolearn (including owlapy and ontosample) can do the following:**

- Load/save ontologies in RDF/XML, OWL/XML.
- **Use concept learning algorithms to generate hypotheses for classifying positive examples in a learning problem**.
- **Use local datasets or datasets that are hosted on a triplestore server, for the learning task.**
- Construct/Generate class expressions and evaluate them using different metrics.
- Define learning problems.
- Load/create/save ontologies in RDF/XML, OWL/XML.
- Modify ontologies by adding/removing axioms.
- Access individuals/classes/properties of an ontology (and a lot more).
- Define learning problems.
- Sample ontologies.
- Construct class expressions.
- Use concept learning algorithms to classify positive examples in a learning problem.
- Use local datasets or datasets that are hosted on a triplestore server, for the learning task.
- Reason over an ontology.
- Other convenient functionalities like converting OWL class expressions to SPARQL or DL syntax.
- Convenient functionalities like converting OWL class expressions to SPARQL or DL syntax.
- Sample ontologies.

------------------------------------

Expand Down
18 changes: 8 additions & 10 deletions docs/usage/02_installation.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Installation

Since Ontolearn is a Python library, you will need to have Python on
your system. Python comes in various versions and with different,
sometimes conflicting dependencies. Hence, most guides will recommend
to set up a "virtual environment" to work in.
Since Ontolearn is a Python library, you will need to have Python installed on
your system (currently supporting version 3.10.13 or higher). Since python comes in various
versions and with different, sometimes conflicting dependencies, most guides will
recommend to set up a "virtual environment" to work in and so do we.

One such system for virtual python environments is
[conda](https://conda.io/projects/conda/en/latest/index.html).
To create a virtual python environments you can consider using the builtin python module
[venv](https://docs.python.org/3/library/venv.html) or [conda](https://conda.io/projects/conda/en/latest/index.html).

## Installation via _pip_

Expand Down Expand Up @@ -71,10 +71,8 @@ to successfully pass all the tests:
```shell
pytest
```
Note: Since Unix and Windows reference files differently, the test are set to work on Linux
but in Widows the filepaths throughout test cases should be changed which is something that
is not very convenient to do. If you really want to run the tests in Windows, you can
make use of the replace all functionality to change them.
Note: The tests are designed to run successfully on Linux machines since we also use them in
GitHub Action. Therefore, trying to run them on a Windows machine can lead to some issues.

## Download External Files

Expand Down
42 changes: 24 additions & 18 deletions docs/usage/04_knowledge_base.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and a reasoner of type [AbstractOWLReasoner](https://dice-group.github.io/owlapy
are not compatible with each other. For example, you can not use [TripleStore](ontolearn.triple_store.TripleStore)
knowledge base with
[StructuralReasoner](https://dice-group.github.io/owlapy/autoapi/owlapy/owl_reasoner/index.html#owlapy.owl_reasoner.StructuralReasoner),
but you can use _TripleStore_ KB with [TripleStoreReasoner](ontolearn.triple_store.TripleStoreReasoner).
but you can use [TripleStore](ontolearn.triple_store.TripleStore) knowledge base with [TripleStoreReasoner](ontolearn.triple_store.TripleStoreReasoner).
_AbstractKnowledgeBase_ contains the necessary methods to facilitate _Structured Machine Learning_.

Currently, there are two implementation of _AbstractKnowledgeBase_:
Expand All @@ -20,9 +20,10 @@ Currently, there are two implementation of _AbstractKnowledgeBase_:
These terms may be used interchangeably sometimes but in Ontolearn they are not the same thing,
although they share a lot of similarities. An ontology in owlapy, as explained
[here](https://dice-group.github.io/owlapy/usage/ontologies.html) is the object where we load
the OWL 2.0 ontologies from a _.owl_ file containing the ontology in an RDF/XML or OWL/XML format.
On the other side a knowledge base combines an ontology and a reasoner together.
Therefore, differently from the ontology you can use methods that require reasoning. You can check
the OWL 2.0 ontologies (supporting different formats OWL/XML, RDF/XML, Triples etc.)
On the other side a knowledge base combines an ontology and a reasoner together and is main purpose
is to ease the process of concept learning serving as both a storing entity and a data retrieval entity.
Therefore, differently from the ontology object you can use reasoning methods. You can check
the methods for each in the links below:

- [AbstractKnowledgeBase](ontolearn.knowledge_base.AbstractKnowledgeBase)
Expand All @@ -37,16 +38,13 @@ is required to run a learning algorithm.
can retrieve information from signature of this ontology. In case of a local the ontology, it can be modified and
saved.

- Although they have some similar functionalities, there are a lot of other distinct
functionalities that each of them has.



## Create an Instance of KnowledgeBase

Let us show how you can initialize an object of `KnowledgeBase`.
We consider that you have already an OWL 2.0 ontology (containing *.owl* extension).
Let us show how you can initialize an instance of `KnowledgeBase`.
We consider that you have already an OWL 2.0 ontology locally (for example a file ending with *.owl*).

The simplest way is to use the path of your _.owl_ file as follows:
The simplest way is to use the path of your local ontology as follows:

```python
from ontolearn.knowledge_base import KnowledgeBase
Expand All @@ -55,7 +53,10 @@ kb = KnowledgeBase(path="file://KGs/Family/father.owl")
```

What happens in the background is that the ontology located in this path will be loaded
in the `AbstractOWLOntology` object of `kb` as done [here](https://dice-group.github.io/owlapy/usage/ontologies.html#loading-an-ontology).
in the `AbstractOWLOntology` object of `kb` as well as a reasoner will be created using that
ontology during initialisation. You may as well initialise an instance of `KnowledgeBase` using
an instance of an ontology and reasoner. For this example we are using a minimalistic ontology
called the _father_ ontology which you can download as instructed [here](02_installation.md#download-external-files).


## Ignore Concepts
Expand Down Expand Up @@ -145,8 +146,8 @@ male_individuals = kb.individuals(male_concept)
Sometimes ontologies and therefore knowledge bases can get very large and our
concept learners become inefficient in terms of runtime. Sampling is an approach
to extract a portion of the whole knowledge base without changing its semantic and
still being expressive enough to yield results with as little loss of quality as
possible. [OntoSample](https://github.com/alkidbaci/OntoSample/tree/main) is
still being expressive enough to yield results (in the learning task) with as little
loss of quality as possible. [OntoSample](https://github.com/alkidbaci/OntoSample/tree/main) is
a library that we use to perform the sampling process. It offers different sampling
techniques which fall into the following categories:

Expand All @@ -164,7 +165,10 @@ You can check them [here](https://github.com/alkidbaci/OntoSample/tree/main).

When operated on its own, Ontosample uses a light version of Ontolearn (`ontolearn_light`)
to reason over ontologies, but when both packages are installed in the same environment
it will use `ontolearn` module instead. This is made for compatibility reasons.
it will use `ontolearn` module instead. This is made for compatibility reasons. However, since
the libraries are managed separately, you may encounter potential errors when installing them
in the same environment. In this case we recommend using Ontosample in another environment
to perform sampling.

Ontosample treats the knowledge base as a graph where nodes are individuals
and edges are object properties. However, Ontosample also offers support for
Expand Down Expand Up @@ -237,15 +241,17 @@ folder. You will find descriptive comments in that script that will help you und

For more details about OntoSample you can see [this paper](https://dl.acm.org/doi/10.1145/3583780.3615158).

Note: You cannot use sampling on a `TripleStore` knowledge base.

## TripleSore Knowledge Base

Instead of going through nodes using expensive computation resources why not just make use of the
Instead of querying knowledge graphs loaded locally using expensive computation resources why not just make use of the
efficient approach of querying a triplestore using SPARQL queries. We have brought this
functionality to Ontolearn for our learning algorithms, and we take care of the conversion part behind the scene.
functionality to Ontolearn for our learning algorithms.
Let's see what it takes to make use of it.

First of all you need a server which should host the triplestore for your ontology. If you don't
already have one, see [Loading and Launching a Triplestore](#loading-and-launching-a-triplestore) below.
already have one and just want to try things out, see [Loading and Launching a Triplestore](#loading-and-launching-a-triplestore) below.

Now you can simply initialize an instance of `TripleStore` class that will serve as an input for your desired
concept learner:
Expand Down
Loading

0 comments on commit 248bc3a

Please sign in to comment.