pwin / owlready2

GNU Lesser General Public License v3.0
140 stars 23 forks source link

Owlready2

.. image:: https://readthedocs.org/projects/owlready2/badge/?version=latest :target: http://owlready2.readthedocs.io/en/latest/ :alt: documentation

.. image:: http://www.lesfleursdunormal.fr/static/_images/owlready_downloads.svg :target: http://www.lesfleursdunormal.fr/static/informatique/pymod_stat_en.html :alt: download stats

Owlready2 is a module for ontology-oriented programming in Python 3, including an optimized RDF quadstore.

Owlready2 can:

Owlready has been created by Jean-Baptiste Lamy at the LIMICS reseach lab. It is available under the GNU LGPL licence v3. If you use Owlready in scientific works, please cite the following article:

Lamy JB. Owlready: Ontology-oriented programming in Python with automatic classification and high level constructs for biomedical ontologies. <http://www.lesfleursdunormal.fr/_downloads/article_owlready_aim_2017.pdf>_ Artificial Intelligence In Medicine 2017;80:11-28

In case of troubles, questions or comments, please use this Forum/Mailing list: http://owlready.8326.n8.nabble.com

What can I do with Owlready2?

Load an ontology from a local repository, or from Internet:

::

from owlready2 import * onto_path.append("/path/to/your/local/ontology/repository") onto = get_ontology("http://www.lesfleursdunormal.fr/static/_downloads/pizza_onto.owl") onto.load()

Create new classes in the ontology, possibly mixing OWL constructs and Python methods:

::

with onto: ... class NonVegetarianPizza(onto.Pizza): ... equivalent_to = [ ... onto.Pizza ... & ( onto.has_topping.some(onto.MeatTopping) ... | onto.has_topping.some(onto.FishTopping) ... ) ] ... def eat(self): print("Beurk! I'm vegetarian!")

Access ontology class, and create new instances / individuals:

::

onto.Pizza pizza_onto.Pizza test_pizza = onto.Pizza("test_pizza_owl_identifier") test_pizza.has_topping = [ onto.CheeseTopping(), ... onto.TomatoTopping(), ... onto.MeatTopping () ]

Export to RDF/XML file:

::

test_onto.save()

Perform reasoning, and classify instances and classes:

::

test_pizza.class onto.Pizza

Execute HermiT and reparent instances and classes

sync_reasoner()

test_pizza.class onto.NonVegetarianPizza test_pizza.eat() Beurk! I'm vegetarian !

Access to medical terminologies from UMLS:

::

from owlready2 import from owlready2.pymedtermino2.umls import default_world.set_backend(filename = "pym.sqlite3") import_umls("umls-2018AB-full.zip", terminologies = ["ICD10", "SNOMEDCT_US", "CUI"]) default_world.save()

PYM = get_ontology("http://PYM/").load() ICD10 = PYM["ICD10"] SNOMEDCT_US = PYM["SNOMEDCT_US"]

SNOMEDCT_US[186675001] SNOMEDCT_US["186675001"] # Viral pharyngoconjunctivitis

SNOMEDCT_US[186675001] >> ICD10 # Map to ICD10 Concepts([ ICD10["B30.9"] # Viral conjunctivitis, unspecified ])

For more documentation, look at the doc/ directories in the source.

Changelog

version 1 - 0.2


version 1 - 0.3


version 2 - 0.1


version 2 - 0.2


version 2 - 0.3


version 2 - 0.4


version 2 - 0.5


version 2 - 0.6


version 2 - 0.7


version 2 - 0.8


version 2 - 0.9


version 2 - 0.10


version 2 - 0.11


version 2 - 0.12


version 2 - 0.13


version 2 - 0.14


version 2 - 0.15


version 2 - 0.16


version 2 - 0.17


version 2 - 0.18


version 2 - 0.19


version 2 - 0.20


version 2 - 0.21


version 2 - 0.22


version 2 - 0.23


version 2 - 0.24


version 2 - 0.25


version 2 - 0.26


Links

Owlready2 on BitBucket (Git development repository): https://bitbucket.org/jibalamy/owlready2

Owlready2 on PyPI (Python Package Index, stable release): https://pypi.python.org/pypi/Owlready2

Documentation: http://owlready2.readthedocs.io/

Forum/Mailing list: http://owlready.8326.n8.nabble.com

Contact "Jiba" Jean-Baptiste Lamy:

::

<jean-baptiste.lamy @ univ-paris13 . fr> LIMICS University Paris 13, Sorbonne Paris Cite Bureau 149 74 rue Marcel Cachin 93017 BOBIGNY FRANCE