emmontopy

Library for representing and working with ontologies in Python

https://github.com/emmo-repo/EMMOntoPy

Science Score: 46.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    2 of 19 committers (10.5%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.4%) to scientific vocabulary

Keywords

emmo-python emmontopy ontologies python rdf

Keywords from Contributors

interactive serializer packaging materials-discovery network-simulation shellcodes hacking autograding observability genomics
Last synced: 6 months ago · JSON representation

Repository

Library for representing and working with ontologies in Python

Basic Info
Statistics
  • Stars: 54
  • Watchers: 4
  • Forks: 13
  • Open Issues: 74
  • Releases: 50
Topics
emmo-python emmontopy ontologies python rdf
Created over 6 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog License

README.md

EMMOntoPy

Library for representing and working with ontologies in Python.

CI tests PyPI version DOI

EMMOntoPy is a Python package based on the excellent Owlready2, which provides a natural and intuitive representation of ontologies in Python. EMMOntoPy extends Owlready2 and adds additional functionality, like accessing entities by label, reasoning with FaCT++ and parsing logical expressions in Manchester syntax. It also includes a set of tools, like creating an ontology from an Excel sheet, generation of reference documentation of ontologies and visualisation of ontologies graphically. EMMOntoPy is freely available for on GitHub and on PyPI under the permissive open source BSD 3-Clause license.

EMMOntoPy was originally developed to work effectively with the Elemental Multiperspective Material Ontology (EMMO) and EMMO-based domain ontologies.
It has now two sub-packages, ontopy and emmopy, where ontopy is a general package to work with any OWL ontology, while emmopy provides extra features that are specific to EMMO.

Owlready2, and thereby also EMMOntoPy, represents OWL classes and individuals in Python as classes and instances. OWL properties are represented as Python attributes. Hence, it provides a new dot notation for representing ontologies as valid Python code. The notation is simple and easy to understand and write for people with some knowledge of OWL and Python. Since Python is a versatile programming language, Owlready2 does not only allow for representation of OWL ontologies, but also to work with them programmatically, including interpretation, modification and generation. Some of the additional features provided by EMMOntoPy are are listed below:

Access by label

In Owlready2 ontological entities, like classes, properties and individuals are accessed by the name-part of their IRI (i.e. everything that follows after the final slash or hash in the IRI). This is very inconvenient for ontologies like EMMO or Wikidata, that identify ontological entities by long numerical names. For instance, the name-part of the IRI of the Atom class in EMMO is ‘EMMOeb77076ba10442aca065_798b2d2809ad’, which is neither human readable nor easy to write. EMMOntoPy allows to access the entity via its label (or rather skos:prefLabel) ‘Atom’, which is much more user friendly.

Turtle serialisation/deserialisation

The Terse RDF Triple Language (Turtle) is a common syntax and file format for representing ontologies. EMMOntoPy adds support for reading and writing ontologies in turtle format.

FaCT++ reasoning

Owlready2 has only support for reasoning with HermiT and Pellet. EMMOntoPy adds additional support for the fast tableaux-based [FaCT++ reasoner] for description logics.

Manchester syntax

Even though the Owlready2 dot notation is clear and easy to read and understand for people who know Python, it is a new syntax that may look foreign for people that are used to working with Protégé. EMMOntoPy provides support to parse and serialise logical expressions in Manchester syntax, making it possible to create tools that will be much more familiar to work with for people used to working with Protégé.

Visualisation

EMMOntoPy provides a Python module for graphical visualisation of ontologies. This module allows to graphically represent not only the taxonomy, but also restrictions and logical constructs. The classes to include in the graph, can either be specified manually or inferred from the taxonomy (like all subclasses of a give class that are not a subclass of any class in a set of other classes).

Tools

EMMOntoPy includes a small set of command-line tools implemented as Python scripts: - ontoconvert: Converts ontologies between different file formats. It also supports some additional transformation during conversion, like running a reasoner, merging several ontological modules together (squashing), rename IRIs, generate catalogue file and automatic annotation of entities with their source IRI. - ontograph: Vertasile tool for visualising (parts of) an ontology, utilising the visualisation features mention above. - ontodoc: Documents an ontology. - excel2onto: Generate an EMMO-based ontology from an excel file. It is useful for domain experts with limited knowledge of ontologies and that are not used to tools like Protégé. - ontoversion: Prints ontology version number. - emmocheck: A small test framework for checking the consistency of EMMO and EMMO-based domain ontologies and whether they confirm to the EMMO conventions.

Some examples of what you can do with EMMOntoPy includes:

  • Access and query RDF-based ontologies from your application. This includes several different flavors of RDF (OWL, Turtle (ttl), and more).
  • Access and query EMMO-based ontologies from your application.
  • Extend EMMO with new domain or application ontologies. This can be done both statically with easy readable Python code or dynamically within your application.
  • Generate graphs and documentation of your ontologies. EMMOntoPy includes ontodoc: A dedicated command line tool for this. You find it in the tools/ sub directory.
  • Check that an EMMO-based domain or application ontology adhere to the conventions of EMMO.
  • Interactively explore an ontology in any Python interpreter, e.g., IPython. Tab-completion makes exploration easy and fast. Below is an example of an IPython session where we check the relations of Matter in EMMO utilizing the emmopy.get_emmo function:

```ipython In [1]: from emmopy import get_emmo

In [2]: emmo = get_emmo()

In [3]: emmo.Matter Out[3]: physicalistic.Matter

In [4]: emmo.Matter.is_a Out[4]: [physicalistic.Physicalistic, physical.Physical, mereotopology.hasPart.some(physicalistic.Massive), physical.hasTemporalPart.only(physicalistic.Matter)] ```

Documentation and examples

The Owlready2 documentation is a good starting point. The EMMOntoPy package also has its own dedicated documentation.

This includes a few examples and demos:

  • demo/vertical shows an example of how EMMO may be used to achieve vertical interoperability. The file define-ontology.py provides a good example for how an EMMO-based application ontology can be defined in Python.

  • demo/horizontal shows an example of how EMMO may be used to achieve horizontal interoperability. This demo also shows how you can use EMMOntoPy to represent your ontology with the low-level metadata framework DLite. In addition to achieve interoperability, as shown in the demo, DLite also allow you to automatically generate C or Fortran code base on your ontology.

  • examples/emmodoc shows how the documentation of EMMO is generated using the ontodoc tool.

Installation

Install with:

console pip install EMMOntoPy

If you want to install with extras:

console pip install EMMOntoPy[excel] # This for installing dependencies relevant for using excel-template for ontology creation

Required Dependencies

  • Python 3.9 or later. Python pacakges:
    • Owlready2 v0.28 or later. EMMOntoPy is builds on top of owlready2.
    • blessings: Clean output for emmocheck.
    • rdflib: Extend parsing functionality.
    • packaging: Only for serialising in turtle and to make sure that this is not done with rdflib<6.6.
    • Pygments: Coloured output for emmocheck.
    • pyparsing: Used for parsing Manchester syntax.
    • [requests]: Used for redirection checks.
    • PyYAML: Redirection checks

Optional Dependencies

For the excel2onto functionality: - Python pacakges (see requirements_excel.txt). - numpy - openpypxl: read excelfiles - pandas: handle tables

For the ontodoc and graph generation tools: - Graphviz: Needed for graph generation. With support for generation pdf, png and svg figures for tests and generation of documentation automatically (ontodoc). - pandoc: Only used for generated documentation from markdown to nicely formatted html or pdf. Tested with v2.1.2. - pdfLaTeX or XeLaTeX and the upgreek LaTeX package (included in texlive-was on RetHat-based distributions and texlive-latex-extra on Ubuntu) for generation of pdf documentation. If your ontology contains exotic unicode characters, we recommend XeLaTeX. - Python packages (see requirements_ontodoc.txt): - graphviz: Generation of documentation and graphs. - PyYAML: Required for generating documentation with pandoc. - blessings: Clean output for emmocheck.

  • Pygments: Coloured output for emmocheck.
  • pyparsing: Used for parsing Manchester syntax

For the reasoning tool. - Java.

See docs/docker-instructions.md for how to build a docker image.

Known issues

  • Invalid serialising to turtle: Due to rdflib issue #1043 ontoconvert may produce invalid turtle output (if your ontology contains real literals using scientific notation without a dot in the mantissa). This issue was fixed after the release of rdflib 5.0.0. Hence, install the latest rdflib from PyPI (pip install --upgrade rdflib) or directly from the source code repository: GitHub if you need to serialise to turtle.

Attributions and credits

EMMOntoPy is maintained by EMMC-ASBL. It has mainly been developed by SINTEF, specifically:

Contributing projects

  • EMMC-CSA; Grant Agreement No: 723867

The EMMC-ASBL organization takes on the efforts of continuing and expanding on the efforts of the CSA. - MarketPlace; Grant Agreement No: 760173 - OntoTrans; Grant Agreement No: 862136 - BIG-MAP; Grant Agreement No: 957189 - OpenModel; Grant Agreement No: 953167

Owner

  • Name: Elementary Multiperspective Material Ontology (EMMO)
  • Login: emmo-repo
  • Kind: organization

A top-level ontology for applied sciences

GitHub Events

Total
  • Create event: 100
  • Issues event: 23
  • Release event: 4
  • Watch event: 13
  • Delete event: 128
  • Issue comment event: 87
  • Push event: 305
  • Pull request review comment event: 60
  • Pull request review event: 99
  • Pull request event: 119
  • Fork event: 3
Last Year
  • Create event: 100
  • Issues event: 23
  • Release event: 4
  • Watch event: 13
  • Delete event: 128
  • Issue comment event: 87
  • Push event: 305
  • Pull request review comment event: 60
  • Pull request review event: 99
  • Pull request event: 119
  • Fork event: 3

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 1,054
  • Total Committers: 19
  • Avg Commits per committer: 55.474
  • Development Distribution Score (DDS): 0.579
Past Year
  • Commits: 175
  • Committers: 9
  • Avg Commits per committer: 19.444
  • Development Distribution Score (DDS): 0.697
Top Committers
Name Email Commits
Jesper Friis j****s@s****o 444
francescalb f****n@s****o 242
Casper Welzel Andersen c****n@s****o 114
Francesca L. Bleken 4****b 68
TEAM 4.0[bot] T****0@S****o 45
Casper Welzel Andersen c****n@e****h 35
dependabot[bot] 4****] 29
Jesper Friis j****s 25
Casper Welzel Andersen 4****A 19
TEAM 4.0[bot] T****0@S****m 7
EMMOntoPy Developers E****y@e****o 5
Sylvain Gouttebroze s****e@s****o 5
emanueleghedini e****i@u****t 4
Sylvain Gouttebroze 3****t 3
Lukas Koschmieder l****r@r****e 3
Emanuele Ghedini e****i@g****m 2
Evgeny Blokhin eb@t****o 2
Bjorn Tore Lovfall b****v@s****o 1
Mostafa Abdollahi Sarvi a****m@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 79
  • Total pull requests: 404
  • Average time to close issues: 4 months
  • Average time to close pull requests: 17 days
  • Total issue authors: 9
  • Total pull request authors: 6
  • Average comments per issue: 0.51
  • Average comments per pull request: 1.01
  • Merged pull requests: 310
  • Bot issues: 1
  • Bot pull requests: 170
Past Year
  • Issues: 15
  • Pull requests: 133
  • Average time to close issues: 14 days
  • Average time to close pull requests: 10 days
  • Issue authors: 6
  • Pull request authors: 4
  • Average comments per issue: 0.13
  • Average comments per pull request: 0.88
  • Merged pull requests: 92
  • Bot issues: 1
  • Bot pull requests: 64
Top Authors
Issue Authors
  • francescalb (45)
  • jesper-friis (18)
  • CasperWA (9)
  • markdoerr (2)
  • andrea-petrocchi (1)
  • LorenaH84 (1)
  • JoanaFMorgado (1)
  • jsimonclark (1)
  • dependabot[bot] (1)
Pull Request Authors
  • dependabot[bot] (170)
  • jesper-friis (85)
  • francescalb (77)
  • TEAM4-0 (66)
  • CasperWA (5)
  • blokhin (1)
Top Labels
Issue Labels
bug (6) github_actions (3) question (3) BLOCKING (2) dependencies (2)
Pull Request Labels
dependencies (197) github_actions (105)

Packages

  • Total packages: 3
  • Total downloads:
    • pypi 3,815 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 65
  • Total maintainers: 4
proxy.golang.org: github.com/emmo-repo/EMMOntoPy
  • Versions: 23
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.5%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
proxy.golang.org: github.com/emmo-repo/emmontopy
  • Versions: 23
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.5%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
pypi.org: emmontopy

Python reference API for the Elementary MultiperspectiveMaterial Ontology.

  • Versions: 19
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 3,815 Last month
Rankings
Downloads: 9.3%
Dependent packages count: 10.1%
Stargazers count: 12.3%
Forks count: 12.6%
Average: 13.2%
Dependent repos count: 21.5%
Last synced: 6 months ago

Dependencies

.github/workflows/ci_workflow.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • codecov/codecov-action v3 composite
Dockerfile docker
  • continuumio/miniconda3 latest build
.github/workflows/cd_publish.yml actions
.github/workflows/ci_automerge_dependabot.yml actions
.github/workflows/ci_cd_updated_master.yml actions
.github/workflows/ci_dependabot.yml actions
ontopy/factpluspluswrapper/java/pom.xml maven
  • edu.stanford.protege:org.protege.xmlcatalog 1.0.4
  • net.sourceforge.owlapi:owlapi-distribution 4.5.15
  • uk.ac.manchester.cs:factplusplus 1.6.5
  • junit:junit 4.13.1 test
pyproject.toml pypi
requirements.txt pypi
  • Cython >=0.29.21,<3.1
  • Owlready2 >=0.28,
  • PyYAML >=5.4.1,<7
  • Pygments >=2.7.4,<3
  • blessings >=1.7,<2
  • defusedxml >=0.7.1,<1
  • graphviz >=0.16,<0.21
  • numpy >=1.19.5,<2
  • openpyxl >=3.0.9,<3.2
  • packaging >=21.0,<24
  • pandas >=1.2,<2.2
  • pyparsing >=2.4.7
  • rdflib >=4.2.1,<8
  • semver >=2.8.1,<4
requirements_dev.txt pypi
  • pre-commit >=2.21.0,<3 development
  • pre-commit * development
  • pylint * development
  • pytest * development
  • pytest-cov * development
requirements_docs.txt pypi
  • mike *
  • mkdocs *
  • mkdocs-awesome-pages-plugin *
  • mkdocs-material *
  • mkdocstrings *
setup.py pypi