dice-group / Ontolearn

Ontolearn is an open-source software library for explainable structured machine learning in Python. It learns OWL class expressions from positive and negative examples.
https://ontolearn-docs-dice-group.netlify.app/index.html
MIT License
41 stars 9 forks source link

Definition of Classes in Signature #445

Closed Demirrr closed 1 month ago

Demirrr commented 1 month ago
kb=TripleStoreKnowledgeBase()
for i in kb.concepts:
     ...

Returns the results of self.ontology.classes_in_signature()

def classes_in_signature(self) -> Iterable[OWLClass]:
       query = owl_prefix + "SELECT DISTINCT ?x WHERE {?x a owl:Class.}"
       yield from get_results_from_ts(self.url, query, OWLClass)

Should we relaxed this assumption by returning things that are rdfs:Class ?

A user may set a flag to true (e.g. kb=TripleStoreKnowledgeBase(inferrence=True), we can very well find a better name :) )

alkidbaci commented 1 month ago

Ontolearn works with OWL classes and having to work with classes of type rdfs:Class would be very resctrictive. A class of type rdfs:Class is less expressive which would contradict the rest of the methods that work with classes of type owl:Class. Relations like owl:equivalentClass, owl:disjointWith are not supported by rdfs:Class as well as complex class constructors like owl:unionOf, owl:intersectionOf, owl:complementOf.

If we were to implement this change then there is a chain of other changes that need to be considered, like checking on each reasoner methods that works with classes whether we have to do with an owl:Class or a rdfs:Class so we avoid possible errors. Another solution is to implement another reasoner for simple ontologies which uses only RDFS classes. To me its a lot of trouble but its you who can decide if this is worth it (I'm not sure what you want to use this for).

Demirrr commented 1 month ago

Ontolearn works with OWL classes and having to work with classes of type rdfs:Class would be very resctrictive For each RDF class definition ( e.g. x type rdfs:Class), we will infer x type owl:Class. Why do you think that such inference be restrictive ?

Relations like owl:equivalentClass, owl:disjointWith are not supported by rdfs:Class as well as complex class constructors like owl:unionOf, owl:intersectionOf, owl:complementOf.

Since we make the owl:Class inference for each RDF classes, we can use all complex constructors.

Edit: I guess owl:Class definitions should be a job of user. So, we do not need to introduce this workaround