我需要动态创建本体。
对于类,我使用下面的方法创建它们。
with onto:
NewClass = types.new_class(class_name, tuple(SuperClasses))但是为了创建properties(object/data等等)我无法找到一种动态创建它们的方法。现在我能做的是:
with onto:
class has_grouping(Bacterium >> Grouping):
pass其中"has_grouping“是属性名。我希望能够创建属性,在该属性中可以从变量中导入属性名。
发布于 2022-05-04 10:58:51
OWL属性实际上是“关系类”。属性是通过定义继承自DataProperty、ObjectProperty或AnnotationProperty的类来创建的。此外,类FunctionalProperty、InverseFunctionalProperty、TransitiveProperty、SymmetricProperty、AsymmetricProperty、ReflexiveProperty和IrreflexiveProperty可以用作额外的超类(使用多重继承),以便创建函数、逆函数、传递和其他属性。
因此,您可以以类似于类的方式动态创建属性。
with onto:
NewProperty= types.new_class(property_name, (ObjectProperty, FunctionalProperty))https://stackoverflow.com/questions/72110035
复制相似问题