我在Protege中创建了我的本体。我已经使用owlread包将其导入Python中。
from owlready2 import *
onto = get_ontology("file:////home/PathToOWlfile/file.owl").load()
generator_list = list(onto.classes())
print(generator_list) #To display all classes
base = get_namespace("http://www.URI.org/namespace1#")
obj = base.Dataset('file1') #Assuming Dataset is one of the class in the ontology
obj.hasTitle1.append('fillll') #hasTitle1 and hasTitle2 are two data properties.
obj.hasTitle2.append('FSA1')如何将这些添加的个人存储到文件中?我正在使用不同的函数在python中处理这些单独的值。
提前谢谢。
发布于 2022-09-25 15:41:16
with onto:
obj = base.Dataset('file1')
obj.hasTitle1.append('fillll')
obj.hasTitle2.append('FSA1')
onto.save(file = "temp", format = "ntriples")当我添加带有“with onto”的对象时,我能够存储三元组。
https://stackoverflow.com/questions/73842893
复制相似问题