AttributeError:owlready库中“ NoneType”对象没有属性“ some”

时间:2019-12-13 20:20:46

标签: python owl owlready

我正在尝试使用owlready库在pizza_onto本体中创建一个名为Pizza的类。但出现以下错误。是什么原因?

可用代码:(pizza.py)

from owlready2 import *
onto_path.append("C:/Users/BAUM-PC/Desktop/izmir/pizza_onto.owl")
onto = get_ontology("C:/Users/BAUM-PC/Desktop/izmir/pizza_onto.owl")
onto.load()

with onto:
    class NonVegetarianPizza(onto.Pizza):
        equivalent_to = [
            onto.Pizza
            & ( onto.has_topping.some(onto.MeatTopping)
            | onto.has_topping.some(onto.FishTopping)
            ) ]
        def eat(self): print("Beurk! I'm vegetarian!")

错误:

* Owlready2 * Warning: optimized Cython parser module 'owlready2_optimized' is not available, defaulting to slower Python implementation
Traceback (most recent call last):
  File "c:/Users/BAUM-PC/Desktop/izmir/pizza.py", line 7, in <module>
    class NonVegetarianPizza(onto.Pizza):
  File "c:/Users/BAUM-PC/Desktop/izmir/pizza.py", line 10, in NonVegetarianPizza
    & ( onto.has_topping.some(onto.MeatTopping)
AttributeError: 'NoneType' object has no attribute 'some'

0 个答案:

没有答案