Skip to content

Commit

Permalink
Merge pull request #61 from dice-group/develop
Browse files Browse the repository at this point in the history
New Release 1.2.1
  • Loading branch information
Demirrr authored Aug 22, 2024
2 parents f988897 + e3c2663 commit 3f6f75e
Show file tree
Hide file tree
Showing 27 changed files with 1,418 additions and 378 deletions.
18 changes: 18 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[run]
omit =
tests/*

[report]
exclude_lines =
pragma: no cover
def __repr__
if self.debug:
if settings.DEBUG
raise AssertionError
raise NotImplementedError
if 0:
if __name__ == .__main__.:
if TYPE_CHECKING:
class .*\bProtocol\):
@(abc\.)?abstractmethod
pass
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ jobs:
wget https://files.dice-research.org/projects/Ontolearn/KGs.zip
unzip KGs.zip
python -m pytest -p no:warnings -x
- name: Coverage report
run: |
pip install coverage
coverage run -m pytest
coverage report -m
71 changes: 64 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# OWLAPY
[![Coverage](https://img.shields.io/badge/coverage-78%25-green)](https://dice-group.github.io/owlapy/usage/further_resources.html#coverage-report)
[![Pypi](https://img.shields.io/badge/pypi-1.2.0-blue)](https://pypi.org/project/owlapy/1.2.0/)
[![Docs](https://img.shields.io/badge/documentation-1.2.0-yellow)](https://dice-group.github.io/owlapy/usage/main.html)

![OWLAPY](docs/_static/images/owlapy_logo.png)

OWLAPY is a Python Framework for creating and manipulating OWL Ontologies.

Expand All @@ -17,10 +22,17 @@ pip3 install owlapy
```


```shell
# To download RDF knowledge graphs
wget https://files.dice-research.org/projects/Ontolearn/KGs.zip -O ./KGs.zip && unzip KGs.zip
pytest -p no:warnings -x # Running 103 tests takes ~ 30 mins
```

## Usage

In this example we start with a simple atomic class expression and move to some more complex
ones and finally render and print the last of them in description logics syntax.

### Creating OWL Class Expressions
<details><summary> Click me! </summary>

```python
from owlapy.class_expression import OWLClass, OWLObjectIntersectionOf, OWLObjectSomeValuesFrom
Expand All @@ -29,17 +41,13 @@ from owlapy import owl_expression_to_sparql, owl_expression_to_dl

# Create the male class
male = OWLClass("http://example.com/society#male")

# Create an object property using the iri as a string for 'hasChild' property.
hasChild = OWLObjectProperty("http://example.com/society#hasChild")

# Create an existential restrictions
hasChild_male = OWLObjectSomeValuesFrom(hasChild, male)

# Let's make it more complex by intersecting with another class
teacher = OWLClass("http://example.com/society#teacher")
teacher_that_hasChild_male = OWLObjectIntersectionOf([hasChild_male, teacher])

# You can render and print owl class expressions in description logics syntax (and vice-versa)
print(owl_expression_to_dl(teacher_that_hasChild_male))
# (∃ hasChild.male) ⊓ teacher
Expand All @@ -57,7 +65,56 @@ class. In the above examples we have introduced 3 types of class expressions:
Like we showed in this example, you can create all kinds of class expressions using the
OWL objects in [owlapy api](https://dice-group.github.io/owlapy/autoapi/owlapy/index.html).

Check also the [examples](https://github.com/dice-group/owlapy/tree/develop/examples) folder.
</details>

### Logical Inference

<details><summary> Click me! </summary>

```python
from owlapy.owl_ontology_manager import OntologyManager
from owlapy.owlapi_adaptor import OWLAPIAdaptor

ontology_path = "KGs/Family/family-benchmark_rich_background.owl"
# Available OWL Reasoners: 'HermiT', 'Pellet', 'JFact', 'Openllet'
owlapi_adaptor = OWLAPIAdaptor(path=ontology_path, name_reasoner="Pellet")
onto = OntologyManager().load_ontology(ontology_path)
# Iterate over defined owl Classes in the signature
for i in onto.classes_in_signature():
# Performing type inference with Pellet
instances=owlapi_adaptor.instances(i,direct=False)
print(f"Class:{i}\t Num instances:{len(instances)}")
owlapi_adaptor.stopJVM()
```

</details>

### Ontology Enrichment

<details><summary> Click me! </summary>

An Ontology can be enriched by inferring many different axioms.
```python
from owlapy.owlapi_adaptor import OWLAPIAdaptor

adaptor = OWLAPIAdaptor(path="KGs/Family/family-benchmark_rich_background.owl", name_reasoner="Pellet")
# Infer missing class assertions
adaptor.infer_axioms_and_save(output_path="KGs/Family/inferred_family-benchmark_rich_background.ttl",
output_format="ttl",
inference_types=[
"InferredClassAssertionAxiomGenerator",
"InferredEquivalentClassAxiomGenerator",
"InferredDisjointClassesAxiomGenerator",
"InferredSubClassAxiomGenerator",
"InferredInverseObjectPropertiesAxiomGenerator",
"InferredEquivalentClassAxiomGenerator"])
adaptor.stopJVM()
```

</details>


Check also the [examples](https://github.com/dice-group/owlapy/tree/develop/examples) and [tests](https://github.com/dice-group/owlapy/tree/develop/tests) folders.

## How to cite
Currently, we are working on our manuscript describing our framework.
Binary file added docs/_static/images/favicon.ico
Binary file not shown.
Binary file added docs/_static/images/owlapy_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

project = 'OWLAPY'
author = 'Ontolearn Team'
release = '1.1.1'
release = '1.2.0'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down Expand Up @@ -66,6 +66,12 @@

html_static_path = ['_static']

html_logo = '_static/images/owlapy_logo.png'

html_favicon = '_static/images/favicon.ico'

html_extra_path = ["googlec4c425077889c69c.html"]

if stanford_theme_mod:
html_theme = 'sphinx_rtd_theme'

Expand Down
1 change: 1 addition & 0 deletions docs/googlec4c425077889c69c.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
google-site-verification: googlec4c425077889c69c.html
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ Welcome to OWLAPY!
usage/usage_examples
usage/ontologies
usage/reasoner
usage/reasoning_details
usage/owlapi_adaptor
usage/further_resources
autoapi/owlapy/index
59 changes: 59 additions & 0 deletions docs/usage/further_resources.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Further Resources

Currently, we are working on our manuscript describing our framework.
If you want to attribute our library, please use our
[GitHub page](https://github.com/dice-group/owlapy) for reference.

## More Inside the Project

Examples and test cases provide a good starting point to get to know
the project better. Find them in the folders
[examples](https://github.com/dice-group/owlapy/tree/develop/examples) and [tests](https://github.com/dice-group/owlapy/tree/develop/tests).

## Contribution

Feel free to create a pull request and we will take a look on it.
Your commitment is well appreciated!

## Questions

In case you have any question, please contact: `caglardemir8@gmail.com`
or open an issue on our [GitHub issues page](https://github.com/dice-group/owlapy/issues).

## Coverage Report
The coverage report is generated using [coverage.py](https://coverage.readthedocs.io/en/7.6.1/).

```
Name Stmts Miss Cover Missing
----------------------------------------------------------------------------------
owlapy/__init__.py 4 0 100%
owlapy/class_expression/__init__.py 8 0 100%
owlapy/class_expression/class_expression.py 34 2 94% 58, 62
owlapy/class_expression/nary_boolean_expression.py 24 0 100%
owlapy/class_expression/owl_class.py 33 1 97% 44
owlapy/class_expression/restriction.py 313 26 92% 41, 49, 68, 71, 89, 170, 245-246, 302, 305, 335, 340, 343, 426, 451, 499, 502, 579-580, 616, 659, 662, 700, 703, 751, 823
owlapy/converter.py 397 189 52% 52-68, 75-76, 79, 82, 152, 157, 169, 176, 184, 246-257, 264-282, 294, 304-307, 313-359, 366-387, 394-401, 417-420, 431, 451, 460-481, 489-491, 498-511, 515-521, 525-548, 552-555, 559-560, 564-576, 580-587, 591-592, 620, 624-628
owlapy/iri.py 79 7 91% 54, 69, 82, 97, 128, 133, 150
owlapy/meta_classes.py 11 0 100%
owlapy/namespaces.py 27 3 89% 36, 40, 43
owlapy/owl_annotation.py 17 4 76% 17, 25, 43, 51
owlapy/owl_axiom.py 518 157 70% 36, 39, 42, 45, 59, 111-113, 116, 136-138, 141, 144, 147-150, 153, 182-184, 187, 190, 193, 196-200, 203, 253-256, 259-261, 264, 288, 291, 294, 332-335, 338-340, 343, 398-401, 404-406, 409, 533-536, 539, 561-563, 566, 569, 572, 575, 578-581, 584, 620-623, 626, 645-648, 652, 656, 674-675, 683, 692, 695-697, 700, 711, 733-737, 745, 753, 761, 764-766, 769, 786-788, 791, 794, 797-800, 803, 822-824, 827, 830, 833-836, 839, 858-860, 863, 866, 869-872, 875, 905-908, 911, 982-985, 988, 1018, 1044, 1071-1073, 1076, 1091, 1103, 1116, 1129, 1142, 1157, 1172, 1185-1187, 1190, 1208, 1227-1230, 1233, 1254-1257, 1260
owlapy/owl_data_ranges.py 40 1 98% 46
owlapy/owl_datatype.py 20 2 90% 33-34
owlapy/owl_individual.py 20 1 95% 37
owlapy/owl_literal.py 286 73 74% 49, 77, 86, 90, 99, 103, 112, 116, 125, 129, 138, 142, 151, 155, 164, 169, 173, 203, 208, 217, 221, 244, 247-249, 252, 258, 262, 288, 293, 302, 306, 311, 323, 329, 332-334, 337, 340, 346, 350, 355, 373, 376-378, 381, 387, 391, 415, 418-420, 423, 429, 433, 454, 459, 462-464, 467, 473, 477, 489-491, 494, 497-499, 502
owlapy/owl_object.py 27 4 85% 24, 79-81
owlapy/owl_ontology.py 391 40 90% 86, 97-100, 103, 109-111, 249, 292-295, 304, 312, 329, 341, 345, 358, 371, 376, 379-381, 384, 423, 433, 449-450, 473-474, 553-554, 595, 599, 603, 629, 736, 742, 750
owlapy/owl_ontology_manager.py 568 167 71% 48, 140, 151, 155, 168-169, 177, 200, 208-211, 312-318, 341-350, 355-376, 396, 466, 469, 474-496, 501-511, 521-527, 539, 542-543, 583, 588-593, 603, 608, 625, 634-645, 650-665, 676, 681, 691, 703, 707, 743, 749, 760, 766, 771-795, 800-807, 825-831, 850, 853, 859-862, 888
owlapy/owl_property.py 69 11 84% 17, 24, 32, 40, 67, 76, 126, 158, 162, 174, 193
owlapy/owl_reasoner.py 841 175 79% 452-455, 572, 584-586, 591-597, 604, 653-659, 665-669, 727-734, 760, 795-799, 825-828, 856-858, 860-862, 871, 884-886, 888-890, 897, 902-904, 924, 928-929, 942-944, 965, 1010-1012, 1113, 1121, 1124, 1127, 1130, 1133, 1136, 1139, 1142, 1145, 1160-1162, 1168, 1172, 1175, 1178, 1181, 1184, 1187, 1193, 1196, 1210, 1240-1243, 1251-1290, 1305, 1318-1328, 1353-1356, 1372, 1386, 1456-1460, 1488, 1498-1502, 1510-1514, 1555-1561, 1573, 1632, 1635, 1638, 1641, 1644, 1647, 1650, 1653, 1657, 1661, 1665, 1668, 1671, 1674, 1677, 1680, 1683, 1687, 1691, 1694, 1697
owlapy/owlapi_adaptor.py 130 65 50% 18, 74-76, 91-96, 110-115, 151-152, 164-165, 179-180, 195-196, 214, 232, 251, 271, 287, 305, 320, 333, 346, 361, 376, 390, 404, 419, 434, 450, 454-483, 511
owlapy/owlapi_mapper.py 103 14 86% 35, 51, 72, 76, 80, 84, 88, 133-136, 141, 145, 149
owlapy/parser.py 371 16 96% 316, 327, 400-401, 416, 577, 618, 656, 667, 721, 723, 751-752, 763, 779-780
owlapy/providers.py 38 3 92% 41, 54, 56
owlapy/render.py 290 46 84% 79-114, 143-158, 176, 180, 186, 206, 222, 231, 236, 241, 375, 379, 386, 405, 421, 430, 435, 440
owlapy/utils.py 766 227 70% 164, 168, 172, 178, 184-188, 192-196, 200, 204, 208, 214, 218, 222, 226, 230, 236, 242, 248, 252, 256, 260, 264-267, 271-274, 278, 285, 300-302, 305-314, 317, 320, 323, 326, 329, 333-339, 343, 354, 358, 362, 366, 370, 374-378, 382-386, 390-394, 398-402, 406, 410, 414-419, 423-428, 432-437, 441, 445, 449-453, 457-461, 465-469, 473-477, 481-485, 489, 493-497, 501, 505-510, 514-519, 523-528, 532, 536-540, 545, 554, 558, 562, 566, 570, 574, 578, 582-587, 591-597, 601, 605, 609, 614, 619, 624, 628, 632, 636, 640, 644-647, 651-654, 658, 662, 666, 671, 676, 681, 685, 736, 740, 746, 748, 751, 753, 796, 852, 866-868, 877, 919-920, 940, 1039, 1044, 1049, 1071, 1075, 1083, 1087, 1092, 1164-1182, 1195-1197, 1202-1206
owlapy/vocab.py 92 4 96% 32, 35, 113-114
----------------------------------------------------------------------------------
TOTAL 5517 1238 78%
```
2 changes: 1 addition & 1 deletion docs/usage/main.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# About owlapy

**Version:** owlapy 1.1.1
**Version:** owlapy 1.2.0

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

Expand Down
6 changes: 3 additions & 3 deletions docs/usage/ontologies.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ When an _OWLOntologyManager_ object is created, a new world is also created as a
By calling the method `load_ontology(iri)` the ontology is loaded to this world.

It possible to create several isolated “worlds”, sometimes
called “universe of speech”. This makes it possible in particular to load
called “universe of speech”. This makes it possible, in particular, to load
the same ontology several times, independently, that is to say, without
the modifications made on one copy affecting the other copy. Sometimes the need to [isolate an ontology](reasoning_details.md#isolated-world)
arise. What that means is that you can have multiple reference of the same ontology in different
the modifications made on one copy affecting the other copy. Sometimes the need to isolate
an ontology arise. What that means is that you can have multiple reference of the same ontology in different
worlds.

-------------------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions docs/usage/owlapi_adaptor.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ Isn't that awesome!
`OWLAPIAdaptor` uses HermiT reasoner by default. You can choose between:
"HermiT", "Pellet", "JFact" and "Openllet".

You can use the reasoning method directly from the adaptor but
for classes that require an [OWLReasoner](owlapi.owl_reasoner.OWLReasoner)
you can use [SyncReasoner](https://dice-group.github.io/owlapy/autoapi/owlapy/owl_reasoner/index.html#owlapy.owl_reasoner.SyncReasoner).

_**owlapi version**: 5.1.9_

## Examples
Expand Down
Loading

0 comments on commit 3f6f75e

Please sign in to comment.