首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何实现python的owlready2中的类的子类列表?

如何实现python的owlready2中的类的子类列表?
EN

Stack Overflow用户
提问于 2022-04-11 15:40:18
回答 2查看 300关注 0票数 0

我希望获得本体中每个类的所有子类,这些类构建在protege上,并使用owlready2导入到python中。如何为该本体的集合类创建所有子类的列表?

EN

回答 2

Stack Overflow用户

发布于 2022-05-26 11:05:17

只需使用list(class_name.subclasses())

票数 1
EN

Stack Overflow用户

发布于 2022-06-09 12:09:06

代码语言:javascript
复制
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"])
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71830613

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档