Accessing Property Chains

classic Classic list List threaded Threaded
3 messages Options
msf
Reply | Threaded
Open this post in threaded view
|

Accessing Property Chains

msf
I have defined, using Protégé, an object property along with a property chain (SuperProperty Of). I then load the ontology into Python/OWLReady2.

How can I access/retrieve the set of property chains defined for an object property?

Thank-you. - Mark
msf
Reply | Threaded
Open this post in threaded view
|

Re: Accessing Property Chains

msf
Resorted to accessing RDFLib to get the property chain.  Here is the code. Note that it works for a single property chain.  Will have to generalize for multiple property chains for the same property.

"""
prop: the property for which a property chain is defined
w: the world object in which the data is stored

returns a list of properties comprising the property chain
"""

def getPropertyChain(prop, w=default_world) :
        chain = []
        rdfGraph = w.as_rdflib_graph()
        obj = rdfGraph.value(URIRef(prop.iri), OWL.propertyChainAxiom)
        while obj != RDF.nil :
                chain.append(IRIS[str(rdfGraph.value(obj, RDF.first))])
                obj = rdfGraph.value(obj, RDF.rest)
        return(chain)
Reply | Threaded
Open this post in threaded view
|

Re: Accessing Property Chains

Jiba
Administrator
In reply to this post by msf
Hi,

You can use Prop.get_property_chain() to obtain the list of property chain.

Jiba