备注:
OWL本体中对象属性和数据属性都可以有进一步的注释属性,被称之为公理
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/bob/ontologies/2022/11/untitled-ontology-20#刘二菲">
<like rdf:resource="http://www.semanticweb.org/bob/ontologies/2022/11/untitled-ontology-20#山南"/>
</owl:NamedIndividual>
<owl:Axiom>
<owl:annotatedSource rdf:resource="http://www.semanticweb.org/bob/ontologies/2022/11/untitled-ontology-20#刘二菲"/>
<owl:annotatedProperty rdf:resource="http://www.semanticweb.org/bob/ontologies/2022/11/untitled-ontology-20#like"/>
<owl:annotatedTarget rdf:resource="http://www.semanticweb.org/bob/ontologies/2022/11/untitled-ontology-20#山南"/>
<Membership rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.98</Membership>
<rdfs:seeAlso rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://baike.baidu.com/item/%E5%88%98%E4%BA%A6%E8%8F%B2/136156</rdfs:seeAlso>
</owl:Axiom>
1、本体看做知识图谱的模式层(一部分学者认为知识图谱模式层的构建就是建立本体,也有学者利用protege建立包含数据的本体模型,也称为知识图谱),
本体的最大作用是明确专业术语、关系及其领域公理,并使其形式化共享复用
。
RDF、RDFS、OWL的异同:
(1)RDF资源描述框架
(Resource Description Framework)本质是一种数据模型,在形式上表现为三元组。
(2)RDF、RDFS、OWL在语义表达能力上,依次逐渐增强,都是在rdf上进行扩展。也就是增加了更多的描述属性特征的词汇和本体映射词汇等词汇
,如rdfs:subClassOf(子类). 、owl:inverseOf.(相反关系)owl:TransitiveProperty(关系的传递性).owl:sameAs. (同一一本体) 等。
(3)OWL,Web Ontology Language语言中的 OWL2 DL 被映射到描述逻辑(DL)上,才能借助各种推理机(Pellet、FaCT、RACER 和 HermiT)实现推理,这里所述的推理是针对OWL中已有的显示约束而开展的,如OWL中定义了相反关系,那么利用推理机就可以进行推理相反关系。这也就是部分学者使用protege 建模,再用推理机推理的关键所在,如果owl中没有定义相反关系,那么根本无法推理。所以这种推理有被称为基于本体的推理。另外,也可以自定义规则,要使用支持自定义规则推理的软件框架如jena。这些推理有被统称为演绎推理,是天然具备可解释性的。
强势插入一张知识图谱推理的内容,原文链接:知识图谱基础之RDF,RDFS与OWL
(4)RDF序列化方法:文件的后缀并不真的影响文件内容的识别,只是一种存储格式。如N-Triples (.nt)、Turtle (.ttl)、JSON-LD (.json) 、RDF/XML (. RDF)等。而从protege 中导出的文件均为OWL后缀。
这些都是以文件的形式存储,还可以数据库的形式进行存储,
如采用RDF图数据库(如Jena框架的TDB)、属性图数据库(如Neo4j)及其他分布式数据库等等。
更多关于知识存储的文章可见[KG笔记]三、知识图谱存储的问题
各种格式的序列化文件
protege的不同序列化方式表达的内容是一样的。
例如
owl/xml序列化关系及关系之间的相反性和传递性
<Declaration>
<ObjectProperty IRI="#hate"/>
</Declaration>
<Declaration>
<ObjectProperty IRI="#love"/>
</Declaration>
<InverseObjectProperties>
<ObjectProperty IRI="#hate"/>
<ObjectProperty IRI="#love"/>
</InverseObjectProperties>
<TransitiveObjectProperty>
<ObjectProperty IRI="#love"/>
</TransitiveObjectProperty>
rdf/xml序列化关系及关系之间的相反性和传递性
<owl:ObjectProperty rdf:about="http://www.co-ode.org/ontologies/pizza/pizza.owl#hate">
<owl:inverseOf rdf:resource="http://www.co-ode.org/ontologies/pizza/pizza.owl#love"/>
</owl:ObjectProperty>
<owl:ObjectProperty rdf:about="http://www.co-ode.org/ontologies/pizza/pizza.owl#love">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#TransitiveProperty"/>
</owl:ObjectProperty>
protege生成的RDF格式的文件中namespace中是用“#”隔开域名和实例或类等元素的,其实用“/”表示的文件也能被protege识别。且rdflib中的namespace就是用“/”表示的。
下文的文件就是用“/”,也能被protege正确识别。
<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.semanticweb.org/bob/ontologies/2021/10/BIontology#"
xml:base="http://www.semanticweb.org/bob/ontologies/2021/10/BIontology"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://www.semanticweb.org/bob/ontologies/2021/10/BIontology"/>
<!--
///
//
// Classes
//
///
-->
<!-- http://www.semanticweb.org/bob/ontologies/2021/10/BIontology/BridgeElement -->
<owl:Class rdf:about="http://www.semanticweb.org/bob/ontologies/2021/10/BIontology/BridgeElement"/>
<!--
///
//
// Individuals
//
///
-->
<!-- http://www.semanticweb.org/bob/ontologies/2021/10/BIontology/e3 -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/bob/ontologies/2021/10/BIontology/e3">
<rdf:type rdf:resource="http://www.semanticweb.org/bob/ontologies/2021/10/BIontology/BridgeElement"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/bob/ontologies/2021/10/BIontology/1&element -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/bob/ontologies/2021/10/BIontology/1&element">
<rdf:type rdf:resource="http://www.semanticweb.org/bob/ontologies/2021/10/BIontology/BridgeElement"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/bob/ontologies/2021/10/BIontology/2&element -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/bob/ontologies/2021/10/BIontology/2&element">
<rdf:type rdf:resource="http://www.semanticweb.org/bob/ontologies/2021/10/BIontology/BridgeElement"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/bob/ontologies/2021/10/BIontology/4ELEMENT -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/bob/ontologies/2021/10/BIontology/4ELEMENT">
<rdf:type rdf:resource="http://www.semanticweb.org/bob/ontologies/2021/10/BIontology/BridgeElement"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/bob/ontologies/2021/10/BIontology/5ELEMENT -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/bob/ontologies/2021/10/BIontology/5ELEMENT">
<rdf:type rdf:resource="http://www.semanticweb.org/bob/ontologies/2021/10/BIontology/BridgeElement"/>
</owl:NamedIndividual>
</rdf:RDF>
<!-- Generated by the OWL API (version 4.5.9.2019-02-01T07:24:44Z) https://github.com/owlcs/owlapi -->
知乎上的2个专栏:
知识图谱-给AI装个大脑
知识图谱的基础知识——从构建到应用
知识图谱问答系统案例
1、浙江大学.基于 REfO 的 KBQA 实现及示例
2、实践篇(五):KBQA Demo