Access the content of an ontology to create a graph

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

Access the content of an ontology to create a graph

andreAn
Hi guys, i need your help.
I'm trying to create a graph from an ontology where my nodes must be all that is in Declarition (class, individuals, object properties, data properties, annotation properties, properties).
I've done this point, i have a list with all this objects but now i need your help to find edges of the graph.
There is an arch from two object of the created list if they appear in an axiom in all the ontology. So i have to check all the axioms of the ontology (except DisjointClasses and AnnotationAssertion) and add an arch between the objects involved in the axiom.

Sorry for my confusion :(

I'll try to explain by an example:

Declaration(Class(pizza:American))
Declaration(Class(pizza:AmericanHot))
Declaration(Class(pizza:AnchoviesTopping))
Declaration(Class(pizza:ArtichokeTopping))
Declaration(Class(pizza:AsparagusTopping))
Declaration(Class(pizza:Cajun))
Declaration(Class(pizza:CajunSpiceTopping))
Declaration(Class(pizza:CaperTopping))
Declaration(Class(pizza:Capricciosa))
Declaration(Class(pizza:Caprina))
Declaration(Class(pizza:CheeseTopping))
Declaration(Class(pizza:CheeseyPizza))
Declaration(Class(pizza:CheeseyVegetableTopping))
Declaration(Class(pizza:ChickenTopping))
Declaration(Class(pizza:Country))
Declaration(Class(pizza:DeepPanBase))
Declaration(Class(pizza:DomainConcept))
Declaration(Class(pizza:Fiorentina))
Declaration(Class(pizza:FishTopping))
Declaration(Class(pizza:Food))
Declaration(Class(pizza:FourCheesesTopping))
Declaration(Class(pizza:FourSeasons))
Declaration(Class(pizza:FruitTopping))
Declaration(Class(pizza:FruttiDiMare))
Declaration(Class(pizza:GarlicTopping))
Declaration(Class(pizza:Giardiniera))
Declaration(Class(pizza:GoatsCheeseTopping))
Declaration(Class(pizza:GorgonzolaTopping))
Declaration(Class(pizza:GreenPepperTopping))
Declaration(Class(pizza:HamTopping))
Declaration(Class(pizza:HerbSpiceTopping))
Declaration(Class(pizza:Hot))
Declaration(Class(pizza:HotGreenPepperTopping))
Declaration(Class(pizza:HotSpicedBeefTopping))
Declaration(Class(pizza:IceCream))

# Object Property: pizza:hasBase (pizza:hasBase)

SubObjectPropertyOf(pizza:hasBase pizza:hasIngredient)
InverseObjectProperties(pizza:hasBase pizza:isBaseOf)
FunctionalObjectProperty(pizza:hasBase)
InverseFunctionalObjectProperty(pizza:hasBase)
ObjectPropertyDomain(pizza:hasBase pizza:Pizza)
ObjectPropertyRange(pizza:hasBase pizza:PizzaBase)

In this example i should add an arch from 'hasBase' and 'isBaseOf' (present in InverseObjectProperties(...))
the same with 'hasBase' and 'Pizza', 'hasBase' and 'PizzaBase'.

This should be the output:
source          target
hasBase       isBaseOf
hasBase      PizzaBase
....

I don't know how to access informations inside 'SubObjectPropertyOf','InverseObjectProperties',FunctionalObjectProperty' ecc

Sorry for my bad English, i need your help absolutely
Reply | Threaded
Open this post in threaded view
|

Re: Access the content of an ontology to create a graph

Jiba
Administrator
Hello,

Owlready does not work at the axiom level, so it does not expose any axiom. But you can either:

 * query the various Python objects, for example:

for prop in default_world.properties():
        if prop.inverse:
                print(prop.inverse, "inversePropertyOf", prop)


 * or directly query the quadstore, for example:

for (subject, predicate, object) in default_world.graph.get_triples(None, owl_inverse_property, None):
        print(subject, "inversePropertyOf", object)

etc...

owl_inverse_property is a constant provided by the owlready module.

Best regards,
Jean-Baptiste Lamy
MCF HDR, Laboratoire LIMICS, Université Paris 13