知识图谱 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
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

王清欢Randy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值