mowl.ontology

Ontology creation

mowl.ontology.create.create_from_triples(triples_file, out_file, relation_name=None, bidirectional=False, head_prefix='', tail_prefix='')[source]

Method to create an ontology from a .tsv file with triples.

Parameters:
  • triples_file (str) – Path for the file containing the triples. This file must be a .tsv file and each row must be of the form (head, relation, tail). It is also supported .tsv files with rows of the form (head, tail); in that case the field relation_name must be specified.

  • out_file (str) – Path for the output ontology file.

  • relation_name (str, optional) – Name for relation in case the .tsv input file has only two columns. Defaults to None.

  • bidirectional (bool, optional) – If True, the triples will be considered undirected. Defaults to False

  • head_prefix (str, optional) – Prefix to be assigned to the head of each triple. Default is "".

  • tail_prefix (str, optional) – Prefix to be assigned to the tail of each triple. Default is "".

Ontology extension

mowl.ontology.extend.insert_annotations(ontology_file, annotations, out_file=None, verbose=False)[source]

Method to build dataset given an ontology file and the annotations to be inserted to the ontology. Annotation files must be in .tsv format, with no header. Per each row, the first element is the annotated entity and the rest of the elements are the annotating entities (which are the entities in the ontology).

Parameters:
  • ontology_file (str) – Ontology file in .owl format

  • annotations (List of (str, str, bool) corresponding to (annotation file path, relation name, directed or undirected graph)) – Annotations to be included in the ontology. There can be more than one annotation file.

  • out_file (str, optional) – Path for the new ontology. Defaults to ontology_file

  • verbose (bool) – If true, information is shown.”

EL Normalization

class mowl.ontology.normalize.ELNormalizer[source]

Bases: object

This class wraps the normalization functionality found in the Java library Jcel. The normalization process transforms an ontology into 7 normal forms in the description logic EL language.

normalize(ontology)[source]

Performs the normalization. :param ontology: Input ontology :type ontology: org.semanticweb.owlapi.model.OWLOntology

Return type:

Dictionary where the keys are labels for each normal form and the values are a list of axioms of each normal form.

preprocess_ontology(ontology)[source]

Preprocesses the ontology to remove axioms that are not supported by the normalization process.

Parameters:

ontology (org.semanticweb.owlapi.model.OWLOntology) – Input ontology

Return type:

org.semanticweb.owlapi.model.OWLOntology

class mowl.ontology.normalize.GCI(axiom)[source]

Bases: object

Base class for all GCI types in the \(\mathcal{EL}\) language

property owl_subclass

Returns the subclass of the GCI

Return type:

org.semanticweb.owlapi.model.OWLClassExpression

property owl_superclass

Returns the superclass of the GCI

Return type:

org.semanticweb.owlapi.model.OWLClassExpression

property owl_axiom

Returns the axiom of the GCI

Return type:

org.semanticweb.owlapi.model.OWLAxiom

static get_entities(gcis)[source]

Returns all the classes and object properties that appear in the GCIs

Parameters:

gcis (list) – List of GCIs

Return type:

tuple(set, set)

class mowl.ontology.normalize.GCI0(axiom)[source]

Bases: GCI

GCI of the form \(C \sqsubseteq D\)

Parameters:

axiom (org.semanticweb.owlapi.model.OWLAxiom) – Axiom of the form \(C \sqsubseteq D\)

property subclass

Returns the subclass of the GCI: \(C\)

Return type:

org.semanticweb.owlapi.model.OWLClass

property superclass

” Returns the superclass of the GCI: \(D\) or \(\bot\)

Return type:

org.semanticweb.owlapi.model.OWLClass

get_entities()[source]

Returns all the classes and object properties that appear in the GCIs

Parameters:

gcis (list) – List of GCIs

Return type:

tuple(set, set)

class mowl.ontology.normalize.GCI0_BOT(axiom)[source]

Bases: GCI0

GCI of the form \(C \sqsubseteq \bot\)

Parameters:

axiom (org.semanticweb.owlapi.model.OWLAxiom) – Axiom of the form \(C \sqsubseteq \bot\)

class mowl.ontology.normalize.GCI1(axiom)[source]

Bases: GCI

GCI of the form \(C \sqcap D \sqsubseteq E\)

Parameters:

axiom (org.semanticweb.owlapi.model.OWLAxiom) – Axiom of the form \(C \sqcap D \sqsubseteq E\)

property left_subclass

” Returns the left operand of the subclass of the GCI: \(C\)

Return type:

org.semanticweb.owlapi.model.OWLClass

property right_subclass

Returns the right operand of the subclass of the GCI: \(D\)

Return type:

org.semanticweb.owlapi.model.OWLClass

property superclass

Returns the superclass of the GCI: \(E\) or \(\bot\)

Return type:

org.semanticweb.owlapi.model.OWLClass

get_entities()[source]

Returns all the classes and object properties that appear in the GCIs

Parameters:

gcis (list) – List of GCIs

Return type:

tuple(set, set)

class mowl.ontology.normalize.GCI1_BOT(axiom)[source]

Bases: GCI1

GCI of the form \(C \sqcap D \sqsubseteq \bot\)

Parameters:

axiom (org.semanticweb.owlapi.model.OWLAxiom) – Axiom of the form \(C \sqcap D \sqsubseteq \bot\)

class mowl.ontology.normalize.GCI2(axiom)[source]

Bases: GCI

GCI of the form \(C \sqsubseteq \exists R.D\)

Parameters:

axiom (org.semanticweb.owlapi.model.OWLAxiom) – Axiom of the form \(C \sqsubseteq \exists R.D\)

property subclass

Returns the subclass of the GCI: \(C\)

Return type:

org.semanticweb.owlapi.model.OWLClass

property object_property

Returns the object property of the GCI: \(R\)

Return type:

org.semanticweb.owlapi.model.OWLObjectProperty

property filler

Returns the filler of the GCI: \(D\)

Return type:

org.semanticweb.owlapi.model.OWLClass

get_entities()[source]

Returns all the classes and object properties that appear in the GCIs

Parameters:

gcis (list) – List of GCIs

Return type:

tuple(set, set)

class mowl.ontology.normalize.GCI3(axiom)[source]

Bases: GCI

GCI of the form \(\exists R.C \sqsubseteq D\)

Parameters:

axiom (org.semanticweb.owlapi.model.OWLAxiom) – Axiom of the form \(\exists R.C \sqsubseteq D\)

property object_property

Returns the object property of the GCI: \(R\)

Return type:

org.semanticweb.owlapi.model.OWLObjectProperty

property filler

Returns the filler of the GCI: \(C\)

Return type:

org.semanticweb.owlapi.model.OWLClass

property superclass

Returns the superclass of the GCI: \(D\) or \(\bot\)

Return type:

org.semanticweb.owlapi.model.OWLClass

get_entities()[source]

Returns all the classes and object properties that appear in the GCIs

Parameters:

gcis (list) – List of GCIs

Return type:

tuple(set, set)

class mowl.ontology.normalize.GCI3_BOT(axiom)[source]

Bases: GCI3

GCI of the form \(\exists R.C \sqsubseteq \bot\)

Parameters:

axiom (org.semanticweb.owlapi.model.OWLAxiom) – Axiom of the form \(\exists R.C \sqsubseteq \bot\)