../../_images/ontologies_with_python.png
Jean-Baptiste Lamy
Apress Editions, 350 pages

../../_images/python_et_les_ontologies.jpeg
Jean-Baptiste Lamy
ENI Éditions, 310 pages

Owlready2 is a module for ontology-oriented programming in Python 3.

documentation download stats

Owlready2 can:

  • Import OWL 2.0 ontologies in NTriples, RDF/XML or OWL/XML format.

  • Export OWL 2.0 ontologies to NTriples or RDF/XML.

  • Manipulates ontology classes, instances and properties transparently, as if they were normal Python objects.

  • Add Python methods to ontology classes.

  • Perform automatic classification of classes and instances, using the HermiT or Pellet reasoner (included)

  • Load DBpedia or UMLS (for medical terminology, using the integrated PyMedTermino2 submodule)

  • Tested up to 1 billion of RDF triples (but can potentially support more).

  • In addition, the quadstore is compatible with the RDFlib Pyton module, which can be used to perform SPARQL queries.

  • Finally, Owlready2 can also be used as an ORM (Object-Relational mapper) -- as a graph/object database, it beats Neo4J, MongoDB, SQLObject and SQLAlchemy in terms of performances (see Benchmark)

Owlready2 has been created by Jean-Baptiste Lamy (my email is on the left) at the LIMICS reseach lab, University Paris 13, Sorbonne Paris Cité, INSERM UMRS 1142, Paris 6 University. It is available under the GNU LGPL licence v3.

If you use Owlready2, please cite the following article:

Lamy JB. Owlready: Ontology-oriented programming in Python with automatic classification and high level constructs for biomedical ontologies. Artificial Intelligence In Medicine 2017;80:11-28

Owlready2 0.34 has been released!

Owlready is a Python module for ontology-oriented programming. It can load OWL 2.0 ontologies and manipulate them transparently in Python.

Here are the changes:

  • NEW FORUM ADDRESS: http://owlready.306.s1.nabble.com

  • Support SPARQL property path expressions with parentheses without sequences, repeats or negative property set nested inside repeats

  • Add define_datatype_in_ontology() global function for defining a new user-defined datatype in an ontology

  • Class.instances() now takes into account equivalent classes (like other class methods such as .descendants())

  • Add the LOADED(iri) SPARQL function

  • Support Thing.is_a.append(...)

  • Faster loading of very large quadstores

  • list(onto.metadata) now lists the annotations present on the ontology

  • Add OntologyClass and NamespaceClass argument to get_ontology() and get_namespace(), allowing the use of custom classes

  • Bugfixes: - Accept UTF8 and latin encoding from reasoners (thanks Francesco Compagno) - Fix SPARQL query with a UNION without variables - Fix semantic type support in UMLS

The new version be downloaded from PyPI (Python Package Index): https://pypi.python.org/pypi/Owlready2

Owlready2 0.33 has been released!

Owlready is a Python module for ontology-oriented programming. It can load OWL 2.0 ontologies and manipulate them transparently in Python.

Here are the changes:

  • Bugfixes: - Fix 'sqlite3.OperationalError: no such table: sqlite_schema' with SQLite3 < 0.33

The new version be downloaded from PyPI (Python Package Index): https://pypi.python.org/pypi/Owlready2

Owlready2 0.32 has been released!

Owlready is a Python module for ontology-oriented programming. It can load OWL 2.0 ontologies and manipulate them transparently in Python.

Here are the changes:

  • Add scripts to import OMOP-CDM as an ontology (see directory pymedtermino2/omop_cdm/)

  • SPARQL engine optimization

  • Bugfixes: - Fix name clash when creating individuals from classes whose names end with a number, e.g. "c1" + "1" vs "c" + "11" - Fix block with only a FILTER in SPARQL

The new version be downloaded from PyPI (Python Package Index): https://pypi.python.org/pypi/Owlready2

Owlready2 0.31 has been released!

Owlready is a Python module for ontology-oriented programming. It can load OWL 2.0 ontologies and manipulate them transparently in Python.

This version can open SPARQL endpoints, with the new SPARQL engine, and fixes several bogues, in particular in the SPARQL engine.

Here are the changes:

  • Can open SPARQL endpoints (see module owlready2.sparql.endpoint and doc)

  • Support ClaML file format in PyMedTermino2 for French ICD10

  • Bugfixes: - Fix prefix in SPARQL that does not correspond to an existing ontology - Fix ! in SPARQL FILTER - Fix Thing.subclasses() so as it now returns classes that have parent constructs but no parent named classes - Fix metaclass of FusionClass when creating individuals belonging to several classes, including one from PyMedTermino - Fix Prop[individual] for functional properties with no relation for the given individual

The new version be downloaded from PyPI (Python Package Index): https://pypi.python.org/pypi/Owlready2

Owlready2 0.30 has been released!

Owlready is a Python module for ontology-oriented programming. It can load OWL 2.0 ontologies and manipulate them transparently in Python.

This version brings two new features:

  • a SPARQL engine which translates the queries into SQL. This engine is much faster than RDFlib (around 60x), it has no dependencies and a shorter loading time. It currently supports a subset of SPARQL: SELECT, INSERT and DELETE queries, sub-queries, UNION, OPTIONAL, FILTER, BIND, FILTER EXISTS, FILTER NOT EXISTS, all functions of SPARQL, blank node notation with square brackets, e.g. ‘[a XXX]’, and property path expressions except those with parentheses.

    This new SPARQL engine can be used as follows (see documentation):

    list(default_world.sparql("""<query>"""))
  • Dublin Core support via integrated OWL translation. It is possible to load Dublin Core directly as follows:

    dc = get_ontology("http://purl.org/dc/elements/1.1").load()

Here are the changes:

  • New native SPARQL engine that translates SPARQL queries to SQL

  • Direct support for Dublin Core via the integration of an OWL translation

  • Bugfixes: - Fix RecursionError when saving very deep ontologies to RDF/XML - Fix IRI of the form 'urn:uuid:...' - Fix loading ontologies that modify an imported property

The new version be downloaded from PyPI (Python Package Index): https://pypi.python.org/pypi/Owlready2

Owlready2 0.29 has been released!

Owlready is a Python module for ontology-oriented programming. It can load OWL 2.0 ontologies and manipulate them transparently in Python.

Here are the changes:

  • Bugfixes: - Fix installation as a requirement of another Python module

The new version be downloaded from PyPI (Python Package Index): https://pypi.python.org/pypi/Owlready2

Owlready2 0.28 has been released!

Owlready is a Python module for ontology-oriented programming. It can load OWL 2.0 ontologies and manipulate them transparently in Python.

This version fix an installation problem under Windows, and also improve the execution of reasoners under Windows (no more DOS windows).

Here are the changes:

  • Fix installation under Windows (contributed by CVK)

  • Under Windows, run the reasoners without opening a DOS windows

The new version be downloaded from PyPI (Python Package Index): https://pypi.python.org/pypi/Owlready2

Owlready2 0.27 has been released!

Owlready is a Python module for ontology-oriented programming. It can load OWL 2.0 ontologies and manipulate them transparently in Python.

Here are the changes:

  • When Pellet is called with debug >= 2 on an inconsistent ontology, Pellet explain output is displayed (contributed by Carsten Knoll)

  • Update doc theme (contributed by Carsten Knoll)

  • Adapt setup.py to allow 'python setup.py develop' and 'pip install -e .' (contributed by Carsten Knoll)

  • Add 'url' argument to Ontology.load() method

  • Add 'read_only' argument to World.set_backend() method

  • Bugfixes: - Fix XML/RDF file parsing/writing for entity having ':' in their name - Fix destroy_entity(), was leaking some RDF triples when class contructs or equivalent_to were involved - Fix 'Class1(entityname); Class2(entityname)' (was changing the individual namespace) - Fix annotation request on RDF annotation properties, e.g. label.label

The new version be downloaded from PyPI (Python Package Index): https://pypi.python.org/pypi/Owlready2

English book "Ontologies with Python"

Ontologies with Python, Jean-Baptiste Lamy, Apress Éditions, 350 pages

My book "Ontologies with Python" has just been published by Apress editions.

This 350-pages book describes how to use OWL 2.0 ontologies in Python 3.x, with the Owlready2 Python module for ontology-oriented programming.

Use ontologies in Python, with the Owlready2 module developed for ontology-oriented programming. You will start with an introduction and refresher on Python and OWL ontologies. Then, you will dive straight into how to access, create, and modify ontologies in Python. Next, you will move on to an overview of semantic constructs and class properties followed by how to perform automatic reasoning. You will also learn about annotations, multilingual texts, and how to add Python methods to OWL classes and ontologies. Using medical terminologies as well as direct access to RDF triples is also covered.

Python is one of the most used programming languages, especially in the biomedical field, and formal ontologies are also widely used. However, there are limited resources for the use of ontologies in Python. Owlready2, downloaded more than 60,000 times, is a response to this problem, and this book is the first one on the topic of using ontologies with Python.

What You Will Learn:

  • Use Owlready2 to access and modify OWL ontologies in Python

  • Publish ontologies on dynamic websites

  • Perform automatic reasoning in Python

  • Use well-known ontologies, including DBpedia and Gene Ontology, and terminological resources, such as UMLS (Unified Medical Language System)

  • Integrate Python methods in OWL ontologies

Who Is This Book For: Beginner to experienced readers from biomedical sciences and artificial intelligence fields would find the book useful.

The book is an updated translation of the French book "Python et les ontologies" published at ENI éditions last year.

More informations on the editor website:

https://www.apress.com/fr/book/9781484265512

Owlready2 0.26 has been released!

Owlready is a Python module for ontology-oriented programming. It can load OWL 2.0 ontologies and manipulate them transparently in Python.

This new release includes a new module for displaying entities in Description Logics (DL), and bugfixes.

Here are the changes:

  • Module owlready2.dl_render allows rendering entities to Description Logics (contributed by Simon Bin)

  • Bugfixes: - Adjustment in the comparison of strings from SameAs and DiferrentFrom, allowing equal comparison regardless of the case-sensitive (contributed by Thiago Feijó) - Fix transitive equivalent_to relations between classes and OWL constructs - Fix AnnotationProperty[entity] where entity is a predefined OWL entity (e.g. comment or Thing) - Fix entity.AnnotationProperty where entity is a predefined OWL entity (e.g. comment or Thing) - Fix HermiT when reasoning on several ontologies with imports statement - Ignore "A type A", with a warning

The new version be downloaded from PyPI (Python Package Index): https://pypi.python.org/pypi/Owlready2

Owlready2 0.25 has been released!

Owlready is a Python module for ontology-oriented programming. It can load OWL 2.0 ontologies and manipulate them transparently in Python.

This new release includes a few new features, and bugfixes.

Here are the changes:

  • Allow the declaration of custom datatypes with declare_datatype()

  • Support the annotation of annotations (e.g. a comment on a comment)

  • search() now support the "subproperty_of" argument

  • search() now support the "bm25" argument (for full-text searches)

  • Bugfixes: - Fix Concept.descendant_concepts() in PymedTermino2 - Update already loaded properties when new ontologies are loaded - Now accept %xx quoted characters in file:// URL - Improve error message on punned entities - Property.get_relations() now considers inverse properties - Fix "AttributeError: 'mappingproxy' object has no attribute 'pop'" error - Fix Thing.instances()

The new version be downloaded from PyPI (Python Package Index): https://pypi.python.org/pypi/Owlready2

Owlready2 0.24 has been released!

Owlready is a Python module for ontology-oriented programming. It can load OWL 2.0 ontologies and manipulate them transparently in Python.

This new release includes several small changes and bugfixes. It now uses the Git versionning system, instead of Mercurial.

Here are the changes:

  • Support intersection of searches (e.g. World.search(...) & World.search(...))

  • Add owlready2.reasoning.JAVA_MEMORY

  • Move development repository to Git

  • Bugfixes: - Fix parsing of NTriples files that do not end with a new line - Fix KeyError with Prop.python_name when several properties share the same name - Fix get_ontology() calls in Python module imported by ontologies in a World that is not default_world - Fix use of PyMedTermino2 in a World that is not default_world - Fix World.as_rdflib_graph().get_context(onto) for ontology added after the creation of the RDFLIB graph - Fix destroying SWRL rules - Fix disjoint with non-atomic classes

The new version be downloaded from PyPI (Python Package Index): https://pypi.python.org/pypi/Owlready2

Owlready2 0.23 has been released!

Owlready is a Python module for ontology-oriented programming. It can load OWL 2.0 ontologies and manipulate them transparently in Python.

This new release includes several small changes and bugfixes.

Here are the changes:

  • Add get_parents_of(), get_instances_of(), get_children_of() methods to ontology, for querying the hierarchical relations defined in a given ontology

  • Use Thing as default value for restrictions with number, instead of None

  • Add 'filter' parameter to save(), for filtering the entities saved (contributed by Javier de la Rosa)

  • Bugfixes: - Fix value restriction with the false value - Fix blank node loading from different ontologies - Fix constructs reused by several classes - Fix 'Class.is_a = []' was not turning the list into an Owlready list - Fix destroy_entity() - was not destroying the IRI of the entity - Improve setup.py: ignore Cython if Cython installation fails

The new version be downloaded from PyPI (Python Package Index): https://pypi.python.org/pypi/Owlready2

Owlready2 0.22 has been released!

Owlready is a Python module for ontology-oriented programming. It can load OWL 2.0 ontologies and manipulate them transparently in Python.

Here are the changes:

  • Add support for disjoint unions (Class.disjoint_unions)

  • Add deepcopy support on class constructs, and automatically deep-copy constructs when needed (i.e. no more OwlReadySharedBlankNodeError)

  • Support the creation of blank nodes with RDFlib

The new version be downloaded from PyPI (Python Package Index): https://pypi.python.org/pypi/Owlready2