当前位置:   article > 正文

知识图谱 Protege 本体构建_protege本体构建

protege本体构建

知识图谱 Protege 本体构建

Protege 相关资源

  • Protege OWL Tutorial 官方教程 : http://owl.cs.manchester.ac.uk/publications/talks-and-tutorials/protg-owl-tutorial/
  • Protege Wiki 相关说明:https://protegewiki.stanford.edu/wiki/Main_Page

Protege 使用 Manchester syntax

描述逻辑 (DL, Description Logic)

逻辑连接词:用于将多个原子命题组合成复合命题

在这里插入图片描述
量词:表示个体数量属性的词

在这里插入图片描述

网络本体语言 (OWL, Web Ontology Language)

​ OWL 是 W3C 开发的一种网络本体语言,用于对本体进行语义描述。OWL 通过提供更多具有形式语义的词汇,使之在Web内容的机器可理解性方面要强于XML、RDF和RDF Schema(RDF-S)。OWL 可以当作是 RDFS 的一个扩展,添加了额外的预定义词汇,提供快速、灵活的数据建模能力,高效的自动推理。

OWL 描述属性特征的词汇

在这里插入图片描述
OWL 本体映射词汇

在这里插入图片描述

Protege 使用 Manchester syntax

​ DL OWL 和 Manchester 语法对应关系如下表:

在这里插入图片描述

Protege 本体构建实践

​ 针对一个游戏信息关系构建实体,具体设计的游戏名称、类型、难度和关系等内容如下表所示:
在这里插入图片描述

定义本体 IRI 前缀

​ 在 Ontology IRI 定义本体的前缀,如图中被选中内容所示

在这里插入图片描述

创建类

​ 创建的所有类都是 Thing 的子类,所以先选中 Thing 类,然后在菜单栏中找到 Tools 下的 Create class ... 进行批量类的创建。
在这里插入图片描述

​ 输入类的层次和属性,使用 tabs 缩进表示层级关系。

在这里插入图片描述

​ 通过上面编码的方式可以批量创建具有层级关系的类,创建完成结果如下图所示,Entity 页面中包含了初始化类的层次结构、同层级类的关系以及单个类的具体描述。
在这里插入图片描述

增加类的关系

​ 属性(property) 是知识图谱中的边:

  • Object property:对象属性连接的节点都有唯一的标志

  • Data property:数据类型属性的主语是具有唯一标志的节点,而连接的另外一个节点是XML的一些基础数据类型

​ 创建对象属性的过程和创建类的方式相似,也可以批量创建如下图所示:

在这里插入图片描述

​ 在对象属性的描述 (Description) 中可以定义:描述是公理,对象属性的取值范围

  • Domains:对象属性的主语的类型
  • Ranges:对象属性的宾语的类型

在这里插入图片描述

​ 另外,对象属性也可以设置特性 (Characteristics) : 特性是一些推理机制Functional, Inverse functional, Transitive, Symmetric, Asymmetric, Reflexive, Irreflexive

添加公理

​ 除了直接在对象属性中定义公理,也可以在类上添加一些公理。如下图示例中,在subclass 中定义 Chess 可以在 Linux WindowsPlatform 上运行,还可以进行 MultiPlayerGenre

在这里插入图片描述
在这里插入图片描述

本体保存

Save as 可以将本体保存,可以选择 Turtle Syntax 格式保存,保存后的owl 文件是一个 RDF 格式的文件。

在这里插入图片描述

使用构建的本体进行推理

​ 在菜单栏中找打 Reasoner 选择一个推理器,并点击 Configure 确定如下图所示:

在这里插入图片描述

​ 然后,再在 Reasoner 中开始推理,如下图所示,最终可以看到 MultiPlayerGame 多出一级 Chess 说明推理出了 Chess 是多人游戏。

在这里插入图片描述

本体保存RDF源码

@prefix : <http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1> .

<http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1> rdf:type owl:Ontology .

#################################################################
#    Object Properties
#################################################################

###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#hasDifficulty
:hasDifficulty rdf:type owl:ObjectProperty ;
               rdfs:subPropertyOf owl:topObjectProperty ;
               rdfs:domain :Game ;
               rdfs:range :DifficultyValuePartition .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#hasGenre
:hasGenre rdf:type owl:ObjectProperty ;
          rdfs:subPropertyOf owl:topObjectProperty ;
          rdfs:domain :Game ;
          rdfs:range :Genre .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#hasPlatform
:hasPlatform rdf:type owl:ObjectProperty ;
             rdfs:subPropertyOf owl:topObjectProperty ;
             rdfs:domain :Game ;
             rdfs:range :Platform .


#################################################################
#    Classes
#################################################################

###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#Chess
:Chess rdf:type owl:Class ;
       rdfs:subClassOf :NameGame ,
                       [ rdf:type owl:Restriction ;
                         owl:onProperty :hasGenre ;
                         owl:someValuesFrom :MultiPlayer
                       ] ,
                       [ rdf:type owl:Restriction ;
                         owl:onProperty :hasPlatform ;
                         owl:someValuesFrom :Linux
                       ] ,
                       [ rdf:type owl:Restriction ;
                         owl:onProperty :hasPlatform ;
                         owl:someValuesFrom :Windows
                       ] .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#DifficultyValuePartition
:DifficultyValuePartition rdf:type owl:Class ;
                          owl:equivalentClass [ rdf:type owl:Class ;
                                                owl:unionOf ( :Easy
                                                              :Hard
                                                              :Normal
                                                            )
                                              ] ;
                          rdfs:subClassOf :ValuePartition .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#Easy
:Easy rdf:type owl:Class ;
      rdfs:subClassOf :DifficultyValuePartition .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#Game
:Game rdf:type owl:Class .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#Genre
:Genre rdf:type owl:Class .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#Hard
:Hard rdf:type owl:Class ;
      rdfs:subClassOf :DifficultyValuePartition .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#Linux
:Linux rdf:type owl:Class ;
       rdfs:subClassOf :Platform .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#LoL
:LoL rdf:type owl:Class ;
     rdfs:subClassOf :NameGame .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#MacOSX
:MacOSX rdf:type owl:Class ;
        rdfs:subClassOf :Platform .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#MultiPlayer
:MultiPlayer rdf:type owl:Class ;
             rdfs:subClassOf :Genre .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#MultiPlayerGame
:MultiPlayerGame rdf:type owl:Class ;
                 owl:equivalentClass [ owl:intersectionOf ( :Game
                                                            [ rdf:type owl:Restriction ;
                                                              owl:onProperty :hasGenre ;
                                                              owl:someValuesFrom :MultiPlayer
                                                            ]
                                                          ) ;
                                       rdf:type owl:Class
                                     ] .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#NameGame
:NameGame rdf:type owl:Class ;
          rdfs:subClassOf :Game .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#Normal
:Normal rdf:type owl:Class ;
        rdfs:subClassOf :DifficultyValuePartition .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#Online
:Online rdf:type owl:Class ;
        rdfs:subClassOf :Genre .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#Platform
:Platform rdf:type owl:Class .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#Puzzle
:Puzzle rdf:type owl:Class ;
        rdfs:subClassOf :Genre .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#RolePlayGame
:RolePlayGame rdf:type owl:Class ;
              rdfs:subClassOf :Genre .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#SinglePlayer
:SinglePlayer rdf:type owl:Class ;
              rdfs:subClassOf :Genre .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#Sudoku
:Sudoku rdf:type owl:Class ;
        rdfs:subClassOf :NameGame .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#ValuePartition
:ValuePartition rdf:type owl:Class .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#Windows
:Windows rdf:type owl:Class ;
         rdfs:subClassOf :Platform .


###  http://www.semanticweb.org/kg/ontologies/2021/2/ganme-ontology-1#WoW
:WoW rdf:type owl:Class ;
     rdfs:subClassOf :NameGame .


#################################################################
#    General axioms
#################################################################

[ rdf:type owl:AllDisjointClasses ;
  owl:members ( :Chess
                :LoL
                :Sudoku
                :WoW
              )
] .


[ rdf:type owl:AllDisjointClasses ;
  owl:members ( :Easy
                :Hard
                :Normal
              )
] .


[ rdf:type owl:AllDisjointClasses ;
  owl:members ( :Game
                :Genre
                :Platform
                :ValuePartition
              )
] .


[ rdf:type owl:AllDisjointClasses ;
  owl:members ( :Linux
                :MacOSX
                :Windows
              )
] .


[ rdf:type owl:AllDisjointClasses ;
  owl:members ( :MultiPlayer
                :Online
                :Puzzle
                :RolePlayGame
                :SinglePlayer
              )
] .


###  Generated by the OWL API (version 4.5.9.2019-02-01T07:24:44Z) https://github.com/owlcs/owlapi
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号