我希望获得本体中每个类的所有子类,这些类构建在protege上,并使用owlready2导入到python中。如何为该本体的集合类创建所有子类的列表?
发布于 2022-05-26 11:05:17
只需使用list(class_name.subclasses())
发布于 2022-06-09 12:09:06
You can dynamically create classes or sub classes.
import types
class_name = "MyClass"
parent_class = [Thing]
with onto:
NewClass = types.new_class(class_name, tuple(parent_class))
Please note the new_class() function expects a tuple with the parent
classes and reference of parent class will be passed not string. If your parent class present inside the ontology you can access (onto["parent_class"])https://stackoverflow.com/questions/71830613
复制相似问题