Hello,
Just getting started with Owlready2. I love it in theory, but I'm getting hung up on something that I think should be easy.
Following the docs, this works:
In [3]: from owlready2 import *
...: onto = get_ontology("
http://www.lesfleursdunormal.fr/static/_downloads/pizza_onto.owl")
...: onto.load()
...:
Out[3]: get_ontology("
http://www.lesfleursdunormal.fr/static/_downloads/pizza_onto.owl#")
In [4]: list(onto.classes())
...:
Out[4]:
[pizza_onto.CheeseTopping,
pizza_onto.FishTopping,
pizza_onto.MeatTopping,
pizza_onto.Pizza,
pizza_onto.TomatoTopping,
pizza_onto.Topping]
In [5]: onto.CheeseTopping
Out[5]: pizza_onto.CheeseTopping
That is, I am able to list the classes, and to access any of the classes using dot notation. But when I try with any other ontologies, I get a NoneType when I try to access the class. For instance, with the pizza ontology at
https://github.com/owlcs/pizza-ontology/blob/master/pizza.owl, this is what the same procedure looks like:
In [6]: onto = get_ontology("/Users/ml/Sandbox/ontology_scratch/pizza_ontology.xml")
...: onto.load()
...:
Out[6]: get_ontology("
http://www.co-ode.org/ontologies/pizza/")
In [7]: list(onto.classes())[0:10]
Out[7]:
[pizza.Pizza,
pizza.PizzaBase,
pizza.Food,
pizza.Spiciness,
pizza.PizzaTopping,
pizza.American,
pizza.NamedPizza,
pizza.MozzarellaTopping,
pizza.PeperoniSausageTopping,
pizza.TomatoTopping]
In [8]: onto.Pizza
In [9]: type(onto.Pizza)
Out[9]: NoneType
This is happening for any ontology I try, other than the example provided in the docs, so I'm pretty certain I'm doing something wrong or misunderstanding how this should work. How could the classes be NoneType if they are listed as classes in onto.classes?
Thank you!
Mark