ontolearn.tentris

Tentris representations.

Attributes

logger

Classes

EncodedPosNegLPStandardTentris

Encoded Abstract learning problem following pos-neg lp standard.

TentrisOntology

TentrisReasoner

EvaluatedConceptTentris

Explicitly declare the attributes that should be returned by the evaluate_concept method of a KnowledgeBase.

TentrisKnowledgeBase

Representation of an OWL knowledge base in Ontolearn.

Module Contents

ontolearn.tentris.logger
class ontolearn.tentris.EncodedPosNegLPStandardTentris(id)

Bases: ontolearn.abstracts.EncodedPosNegLPStandardKind

Encoded Abstract learning problem following pos-neg lp standard.

__slots__ = 'id'
id
__repr__()
class ontolearn.tentris.TentrisOntology(path: str, endpoint_url: str, timeout: float)

Bases: owlapy.owl_ontology.OWLOntology

__slots__ = ('_path', '_endpoint_url', '_backing_mgr', '_backing_onto', '_endpoint_timeout')
classes_in_signature() Iterable[owlapy.class_expression.OWLClass]
data_properties_in_signature() Iterable[owlapy.owl_property.OWLDataProperty]
object_properties_in_signature() Iterable[owlapy.owl_property.OWLObjectProperty]
individuals_in_signature() Iterable[owlapy.owl_individual.OWLNamedIndividual]
abstract data_property_range_axioms(property: owlapy.owl_property.OWLDataProperty) Iterable[owlapy.owl_axiom.OWLDataPropertyRangeAxiom]
data_property_domain_axioms(property: owlapy.owl_property.OWLDataProperty) Iterable[owlapy.owl_axiom.OWLDataPropertyDomainAxiom]
object_property_domain_axioms(property: owlapy.owl_property.OWLObjectProperty) Iterable[owlapy.owl_axiom.OWLObjectPropertyDomainAxiom]
object_property_range_axioms(property: owlapy.owl_property.OWLObjectProperty) Iterable[owlapy.owl_axiom.OWLObjectPropertyRangeAxiom]
abstract get_owl_ontology_manager() owlapy.owl_ontology._M
abstract get_ontology_id() owlapy.owl_ontology.OWLOntologyID
__eq__(other)
__hash__()
__repr__()
class ontolearn.tentris.TentrisReasoner(ontology: TentrisOntology)

Bases: ontolearn.base.ext.OWLReasonerEx

__slots__ = ('_ontology', '_backing_reasoner')
abstract data_property_domains(pe: owlapy.owl_property.OWLDataProperty, direct: bool = False) Iterable[owlapy.class_expression.OWLClass]
object_property_domains(pe: owlapy.owl_property.OWLObjectProperty, direct: bool = False) Iterable[owlapy.class_expression.OWLClass]
object_property_ranges(pe: owlapy.owl_property.OWLObjectProperty, direct: bool = False) Iterable[owlapy.class_expression.OWLClass]
abstract equivalent_classes(ce: owlapy.class_expression.OWLClassExpression, only_named: bool = True) Iterable[owlapy.class_expression.OWLClassExpression]
abstract data_property_values(ind: owlapy.owl_individual.OWLNamedIndividual, pe: owlapy.owl_property.OWLDataProperty) Iterable[owlapy.owl_literal.OWLLiteral]
abstract object_property_values(ind: owlapy.owl_individual.OWLNamedIndividual, pe: owlapy.owl_property.OWLObjectPropertyExpression) Iterable[owlapy.owl_individual.OWLNamedIndividual]
abstract flush() None
instances(ce: owlapy.class_expression.OWLClassExpression, direct: bool = False) Iterable[owlapy.owl_individual.OWLNamedIndividual]
sub_classes(ce: owlapy.class_expression.OWLClassExpression, direct: bool = False, only_named: bool = True) Iterable[owlapy.class_expression.OWLClassExpression]
sub_data_properties(dp: owlapy.owl_property.OWLDataProperty, direct: bool = False) Iterable[owlapy.owl_property.OWLDataProperty]
sub_object_properties(op: owlapy.owl_property.OWLObjectPropertyExpression, direct: bool = False) Iterable[owlapy.owl_property.OWLObjectPropertyExpression]
abstract types(ind: owlapy.owl_individual.OWLNamedIndividual, direct: bool = False) Iterable[owlapy.class_expression.OWLClass]
get_root_ontology() TentrisOntology
abstract super_classes(ce: owlapy.class_expression.OWLClassExpression, direct: bool = False, only_named: bool = True) Iterable[owlapy.class_expression.OWLClassExpression]
class ontolearn.tentris.EvaluatedConceptTentris

Bases: ontolearn.search.EvaluatedConcept

Explicitly declare the attributes that should be returned by the evaluate_concept method of a KnowledgeBase.

This way, Python uses a more efficient way to store the instance attributes, which can significantly reduce the memory usage.

__slots__ = ()
property inds
class ontolearn.tentris.TentrisKnowledgeBase(path: str, *, length_metric_factory: ontolearn.utils.Factory[[], ontolearn.base.owl.utils.OWLClassExpressionLengthMetric] | None = None, length_metric: ontolearn.base.owl.utils.OWLClassExpressionLengthMetric | None = None, individuals_cache_size=128)

Bases: ontolearn.knowledge_base.KnowledgeBase

Representation of an OWL knowledge base in Ontolearn.

Parameters:
  • path – Path to an ontology file that is to be loaded.

  • ontologymanager_factory – Factory that creates an ontology manager to be used to load the file.

  • ontology – OWL ontology object.

  • reasoner_factory – Factory that creates a reasoner to reason about the ontology.

  • reasoner – reasoner Over the ontology.

  • length_metric_factory – See length_metric.

  • length_metric – Length metric that is used in calculation of class expression lengths.

  • individuals_cache_size – How many individuals of class expressions to cache.

  • backend_store – Whether to sync the world to backend store. reasoner of this object, if you enter a reasoner using :arg:`reasoner_factory` or :arg:`reasoner` argument it will override this setting.

  • include_implicit_individuals – Whether to identify and consider instances which are not set as OWL Named Individuals (does not contain this type) as individuals.

generator

Instance of concept generator.

Type:

ConceptGenerator

path

Path of the ontology file.

Type:

str

use_individuals_cache

Whether to use individuals cache to store individuals for method efficiency.

Type:

bool

__slots__ = ('endpoint_url', 'endpoint_timeout', 'async_client', 'tasks', '_total_req', '_current_req')
endpoint_url: str
endpoint_timeout: float
path
tasks = 8
async_client
use_individuals_cache
abstract encode_learning_problem(lp: AbstractLearningProblem)

Provides the encoded learning problem (lp), i.e. the class containing the set of OWLNamedIndividuals as follows:

kb_pos –> the positive examples set, kb_neg –> the negative examples set, kb_all –> all lp individuals / all individuals set, kb_diff –> kb_all - (kb_pos + kb_neg).

Note

Simple access of the learning problem individuals divided in respective sets. You will need the encoded learning problem to use the method evaluate_concept of this class.

Parameters:

lp (PosNegLPStandard) – The learning problem.

Returns:

The encoded learning problem.

Return type:

EncodedPosNegLPStandard

evaluate_concept(concept: owlapy.class_expression.OWLClassExpression, quality_func: AbstractScorer, encoded_learning_problem: EncodedPosNegLPStandardTentris) EvaluatedConcept

Evaluates a concept by using the encoded learning problem examples, in terms of Accuracy or F1-score.

Note

This method is useful to tell the quality (e.q) of a generated concept by the concept learners, to get the set of individuals (e.inds) that are classified by this concept and the amount of them (e.ic).

Parameters:
  • concept – The concept to be evaluated.

  • quality_func – Quality measurement in terms of Accuracy or F1-score.

  • encoded_learning_problem – The encoded learning problem.

Returns:

The evaluated concept.

async evaluate_concept_async(concept: owlapy.class_expression.OWLClassExpression, quality_func: AbstractScorer, encoded_learning_problem: EncodedPosNegLPStandardTentris) EvaluatedConcept