owlapy.swrl

Attributes

BUILTINS

DATATYPES

SWRL

SWRLB

Classes

Variable

Represents a variable in SWRL syntax

DVariable

Represents a data variable in SWRL syntax

IVariable

Represents a individual variable in SWRL syntax

Atom

Represents an Atom in SWRL syntax

ClassAtom

Represents a class atom in SWRL syntax

DataRangeAtom

Represents a data range atom in SWRL syntax

PropertyAtom

Represents a property atom in SWRL syntax

ObjectPropertyAtom

Represents an object property atom in SWRL syntax

DataPropertyAtom

Represents a data property atom in SWRL syntax

SameAsAtom

Represents a 'same-as' atom in SWRL syntax

DifferentFromAtom

Represents a 'different-from' atom in SWRL syntax

BuiltInAtom

Represents a built-in atom in SWRL syntax

Rule

Represents a rule in SWRL syntax

Functions

r(argument)

Returns the right string format of a given argument depending on its type

t(argument)

Returns the representation for a given argument

Module Contents

owlapy.swrl.BUILTINS = ['add', 'subtract', 'multiply', 'divide', 'mod', 'pow', 'abs', 'round', 'floor', 'ceiling',...
owlapy.swrl.DATATYPES = ['decimal', 'integer', 'nonNegativeInteger', 'nonPositiveInteger', 'positiveInteger',...
owlapy.swrl.SWRL = 'http://www.w3.org/2003/11/swrl#'
owlapy.swrl.SWRLB = 'http://www.w3.org/2003/11/swrlb#'
class owlapy.swrl.Variable(iri: owlapy.iri.IRI | str)[source]

Represents a variable in SWRL syntax

iri: owlapy.iri.IRI
is_i_variable()[source]
is_d_variable()[source]
__repr__()[source]
__eq__(other)[source]
__str__()[source]
__hash__()[source]
class owlapy.swrl.DVariable(iri: owlapy.iri.IRI | str)[source]

Bases: Variable

Represents a data variable in SWRL syntax

__repr__()[source]
class owlapy.swrl.IVariable(iri: owlapy.iri.IRI | str)[source]

Bases: Variable

Represents a individual variable in SWRL syntax

__repr__()[source]
class owlapy.swrl.Atom[source]

Represents an Atom in SWRL syntax

__eq__(other)[source]
static from_string(atom_str: str, namespace: str, dp_predicates: List[str] = None)[source]

Parses a SWRL atom like ‘parent(?x, ?y)’ or ‘person(?x)’.

Returns:

An Atom object.

abstractmethod is_class_assertion()[source]
abstractmethod is_property_assertion()[source]
abstractmethod is_same_as()[source]
abstractmethod is_different_from()[source]
abstractmethod is_builtin()[source]
owlapy.swrl.r(argument)[source]

Returns the right string format of a given argument depending on its type

owlapy.swrl.t(argument)[source]

Returns the representation for a given argument

class owlapy.swrl.ClassAtom(cls: owlapy.class_expression.OWLClass, argument1: IVariable | owlapy.owl_individual.OWLNamedIndividual)[source]

Bases: Atom

Represents a class atom in SWRL syntax

argument1: IVariable | owlapy.owl_individual.OWLNamedIndividual
cls: owlapy.class_expression.OWLClass
is_class_assertion()[source]
is_property_assertion()[source]
is_same_as()[source]
is_different_from()[source]
is_builtin()[source]
__str__()[source]
__repr__()[source]
__hash__()[source]
__eq__(other)[source]
class owlapy.swrl.DataRangeAtom(datatype: owlapy.owl_datatype.OWLDatatype, argument1: DVariable)[source]

Bases: Atom

Represents a data range atom in SWRL syntax

argument1: DVariable
datatype: owlapy.owl_datatype.OWLDatatype
is_class_assertion()[source]
is_property_assertion()[source]
is_same_as()[source]
is_different_from()[source]
is_builtin()[source]
__str__()[source]
__repr__()[source]
__hash__()[source]
__eq__(other)[source]
class owlapy.swrl.PropertyAtom(prop: owlapy.owl_property.OWLObjectProperty | owlapy.owl_property.OWLDataProperty, argument1, argument2)[source]

Bases: Atom

Represents a property atom in SWRL syntax

argument1
argument2
prop
is_class_assertion()[source]
is_property_assertion()[source]
is_same_as()[source]
is_different_from()[source]
is_builtin()[source]
__str__()[source]
class owlapy.swrl.ObjectPropertyAtom(prop: owlapy.owl_property.OWLObjectProperty, argument1: owlapy.owl_individual.OWLNamedIndividual | IVariable, argument2: owlapy.owl_individual.OWLNamedIndividual | IVariable)[source]

Bases: PropertyAtom

Represents an object property atom in SWRL syntax

argument1: owlapy.owl_individual.OWLNamedIndividual | IVariable
argument2: owlapy.owl_individual.OWLNamedIndividual | IVariable
prop: owlapy.owl_property.OWLObjectProperty
__repr__()[source]
__hash__()[source]
__eq__(other)[source]
class owlapy.swrl.DataPropertyAtom(prop: owlapy.owl_property.OWLDataProperty, argument1: owlapy.owl_individual.OWLNamedIndividual | IVariable, argument2: owlapy.owl_literal.OWLLiteral | DVariable)[source]

Bases: PropertyAtom

Represents a data property atom in SWRL syntax

argument1: owlapy.owl_individual.OWLNamedIndividual | IVariable
argument2: owlapy.owl_literal.OWLLiteral | DVariable
prop: owlapy.owl_property.OWLDataProperty
__repr__()[source]
__hash__()[source]
__eq__(other)[source]
class owlapy.swrl.SameAsAtom(argument1: IVariable | owlapy.owl_individual.OWLNamedIndividual, argument2: IVariable | owlapy.owl_individual.OWLNamedIndividual)[source]

Bases: Atom

Represents a ‘same-as’ atom in SWRL syntax

argument1: IVariable | owlapy.owl_individual.OWLNamedIndividual
argument2: IVariable | owlapy.owl_individual.OWLNamedIndividual
is_class_assertion()[source]
is_property_assertion()[source]
is_same_as()[source]
is_different_from()[source]
is_builtin()[source]
__str__()[source]
__repr__()[source]
__hash__()[source]
__eq__(other)[source]
class owlapy.swrl.DifferentFromAtom(argument1: IVariable | owlapy.owl_individual.OWLNamedIndividual, argument2: IVariable | owlapy.owl_individual.OWLNamedIndividual)[source]

Bases: Atom

Represents a ‘different-from’ atom in SWRL syntax

argument1: IVariable | owlapy.owl_individual.OWLNamedIndividual
argument2: IVariable | owlapy.owl_individual.OWLNamedIndividual
is_class_assertion()[source]
is_property_assertion()[source]
is_same_as()[source]
is_different_from()[source]
is_builtin()[source]
__str__()[source]
__repr__()[source]
__hash__()[source]
__eq__(other)[source]
class owlapy.swrl.BuiltInAtom(predicate: owlapy.iri.IRI, arguments: List[DVariable | owlapy.owl_literal.OWLLiteral])[source]

Bases: Atom

Represents a built-in atom in SWRL syntax

predicate: owlapy.iri.IRI
arguments: List[DVariable | owlapy.owl_literal.OWLLiteral]
is_class_assertion()[source]
is_property_assertion()[source]
is_same_as()[source]
is_different_from()[source]
is_builtin()[source]
__str__()[source]
__repr__()[source]
__hash__()[source]
__eq__(other)[source]
class owlapy.swrl.Rule(body_atoms: Atom | List[Atom], head_atoms: Atom | List[Atom])[source]

Represents a rule in SWRL syntax

body_atoms: Atom | List[Atom]
head_atoms: Atom | List[Atom]
body
head
static from_string(rule: str, namespace: str, dp_predicates: List[str] = None)[source]

Parses a SWRL rule given as a string. Use ‘^’ for composition of atoms and ‘->’ for consequent implication. E.g. of a valid rule: ‘parent(?x,?y) ^ brother(?y,?z) -> uncle(?x,?z)’

Parameters:
  • rule – The SWRL rule in string format that is to be parsed

  • namespace – The namespace of the ontology

  • dp_predicates – (optional) List of data property predicates that will help in the correct mapping of property type (by default property atoms are considered as object property atoms except when specifying data property predicates in this argument)

Returns:

A SWRL Rule object.

__str__()[source]
__repr__()[source]
__eq__(other)[source]
__hash__()[source]