我想做同样的事情
with onto:
class Drug(Thing):
pass
但有类名
className = "Drug"
怎么做?
我已经用 protege 创建了本体,现在希望它打开,添加一些类并保存回来。我在很多方面都失败了。例如代码
from owlready2 import *
import types
ontology_name = "http://www.semanticweb.org/dimskraft/ontologies/2020/4/my"
file_name = "data/my.owl"
prefix = "file:///home/dimskraft/design/my_ontology/"
onto = get_ontology(prefix + file_name).load()
NewClass = types.new_class("NewClassName", (Thing,), kwds={"namespace": onto})
class Drug(Thing):
namespace = onto
onto.save(file=file_name, format="rdfxml")
给出以下错误
TypeError: __new__() got an unexpected keyword argument 'namespace'