我对本体论和语义分析很陌生。目前,我有一个公共(public)本体来源,来自 BBC 网站。源文件的格式为“.ttl”。 我还使用 eclipse 加载 Jena 中的源代码。然而,当我看到代码时,我有点失落。
这是一些示例:
<http://www.bbc.co.uk/ontologies/bbc/Mobile>
a <http://www.bbc.co.uk/ontologies/bbc/Platform> ;
<http://www.w3.org/2000/01/rdf-schema#comment>
"Represents the web documents designed for a smaller, mobile screen."@en-gb ;
<http://www.w3.org/2000/01/rdf-schema#isDefinedBy>
<http://www.bbc.co.uk/ontologies/bbc> ;
<http://www.w3.org/2000/01/rdf-schema#label>
"Mobile"@en-gb .
<http://www.bbc.co.uk/ontologies/bbc/primaryContent>
a <http://www.w3.org/2002/07/owl#ObjectProperty> ;
<http://www.w3.org/2000/01/rdf-schema#comment>
"Represents the fact that a web document has as primary content the creative work (e.g., a news story about Tom Daley is the primary content of a webpage)."@en-gb ;
<http://www.w3.org/2000/01/rdf-schema#domain>
<http://www.bbc.co.uk/ontologies/bbc/WebDocument> ;
<http://www.w3.org/2000/01/rdf-schema#isDefinedBy>
<http://www.bbc.co.uk/ontologies/bbc> ;
<http://www.w3.org/2000/01/rdf-schema#label>
"primaryContent"@en-gb ;
<http://www.w3.org/2000/01/rdf-schema#range>
<http://www.bbc.co.uk/ontologies/creativework/CreativeWork> ;
<http://www.w3.org/2002/07/owl#inverseOf>
<http://www.bbc.co.uk/ontologies/bbc/primaryContentOf> .
那么如何获取所有类名称属性关系并将其保存在列表中? 用Python可以做到吗?因为我不确定 python 中的 rdflib 是否可以使用
最佳答案
for subj, pred, obj in g:
subname = subj.split("/")[-1]
这样你就可以获得主题的名称。
关于python - 如何通过获取所有类名称属性关系来创建领域本体词典并将其保存在列表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39366879/