Closed renespeck closed 5 days ago
Yes you can achieve that by searching for values of rdfs:label
data property:
from owlapy.class_expression import OWLClass
from owlapy.iri import IRI
from owlapy.owl_ontology_manager import OntologyManager
from owlapy.owl_property import OWLDataProperty
from owlapy.owl_reasoner import FastInstanceCheckerReasoner, OntologyReasoner
ontology = OntologyManager().load_ontology("path/to/some/ontology.owl")
reasoner = FastInstanceCheckerReasoner(ontology, OntologyReasoner(ontology))
c = OWLClass(IRI('http://your_ontology_namespace#', 'AAV'))
p = OWLDataProperty("http://www.w3.org/2000/01/rdf-schema#label")
[print(label.get_literal()) for label in reasoner.data_property_values(c, p)]
# ===Results===
# AA v
# Amphibious Assault Vehicle
Note: Reasoners that support this are only FastInstanceCheckerReasoner
and OntologyReasoner
.
Thank you very much also for your quick reply.
Hi, is it possible to get the labels of a class defined in an ontology?
Best and thanks.