OWL简介

OWL

Ontology Web Language,以XML为语法基础,是RDF的扩展,可以表述更为复杂的关系。

OWL命名空间:

<rdf:RDF 
	xmlns:owl="http://www.w3.org/2002/07/owl#"
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
	xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
	xmlns:xsd="http://www.w3.org/2001/XLMSchema#">
</rdf:RDF>

OWL常用关键字:

owl:disjointWith:不相交
owl:equivalentClass:类之间的相等
owl:Thing:所有类的父类
owl:Nothing:空类

<owl:Class rdf:about="#associateProfessor">
	<owl:disjointWith rdf:resource ="#professor"/>
	<owl:disjointWith rdf:resource="assistantProfessor"/>
</owl:Class>

<owl:Class rdf:ID ="faculty">
	<owl:equivalentClass rdf:resource="#academicStaffMember">
</owl:Class>

两类Property:

owl:ObjectProperty:表明两个object之间的关系
owl:DatatypeProperty:表明object与type之间的关系
owl:InverseOf:表明两个Property之间是相反关系
owl:equivalentProperty :表明两个Property之间是相等关系

<owl:DatatypeProperty rdf:ID="age">
	<rdfs:range rdf:resource="http://www.w3.org/2001/XLMSchema#nonNegativeInteger"/>
</owl:DatatypeProperty>

<owl:ObjectProperty rdf:ID="isTaughtBy">
	<owl:domain rdf:resource="#course"/>
	<owl:range rdf:resource="#academicStaffMember"/>
	<rdfs:subPropertyOf rdf:resource="#involves"/>
</owl:ObjectProperty>

<owl:ObjectProperty rdf:ID="teaches">
	<rdfs:range rdf:resource="#course"/>
	<rdfs:domain rdf:resource="#academicStaffMember"/>
	<owl:inverseOf rdf:resource="#isTaughtBy"/>
</owl:ObjectProperty>

<owl:ObjectProperty rdf:ID="lecturesIn">
	<owl:equivalentProperty rdf:resource="#teaches"/>
</owl:ObjectProperty>

OWL中对Class的限制:

owl:Restriction:表明对类的限制,其中最少有一个限制类型,最多有三个限制类型。
owl:onProperty:被限制的Property
owl:allValuesFrom:所有
owl:hasValue:至少一个元素,存在
owl:someValuesFrom:存在
owl:minCardinality:最小值
owl:maxCardinality:最大值

<owl:Class rdf:about="#firstYearCourse">
	<rdfs:subClassOf>
		<owl:Restriction>
			<owl:onProperty rdf:resource="isTaughtBy"/>
			<owl:allValuesFrom rdf:resource="#Professor"/>
		</owl:Restriction>
	</rdfs:subClassOf>
</owl:Class>

特殊的OWL Property:
owl:TransitiveProperty:可传递的Property,例如大于。
owl:SymmetricProperty:对称Property,例如,相等。
owl:FunctionalProperty:表明一个资源的一个或几个value,例如年龄、身高
owl:InverseFunctionalProperty:owl:FunctionalProperty的反义词,例如 ageOf, heightOf.
owl:complementOf:表示互补关系
owl:unionOf:表示或关系,并集
owl:intersectionOf:表示与关系,交集

owl:oneOf:定义一个枚举类型

<owl:Class rdf:ID="weekdays">
	<owl:oneOf rdf:parseType="Collection">
		<owl:Thing rdf:about="#Monday"/>
		<owl:Thing rdf:about="#Tuesday"/>
		<owl:Thing rdf:about="#Wednesday"/>
		<owl:Thing rdf:about="#Thursday"/>
		<owl:Thing rdf:about="#Friday"/>
		<owl:Thing rdf:about="#Saturday"/>
		<owl:Thing rdf:about="#Sunday"/>
	</owl:oneOf>
</owl:Class>

在OWL中,不同的resource可以表示相同的资源,可以使用
owl:sameAs:来实现该功能
owl:differentFrom:表示两个resource不同
如果想要同时表示多个resource彼此不同,可以使用:
owl:allDifferent,owl:distinctMembers。

<rdf:Description rdf:about="#William_Jefferson_Clinton">
	<owl:sameAs rdf:resource="#BillClinton"/>
</rdf:Description>

<lecturer rdf:about="#949318">
	<owl:differentFrom rdf:resource="#949352"/>
</lecturer>

<owl:allDifferent>
	<owl:distinctMembers rdf:parseType="Collection">
		<lecturer rdf:about="#949318"/>
		<lecturer rdf:about="#949352"/>
		<lecturer rdf:about="#949111"/>
	</owl:distinctMembers>
</owl:allDifferent>

Open-world assumption(OWA):世界是未知的,如果我们不能确定一件事为真,那么也不能推断出他为假,而且一个事物可能有着多个定义。OWL使用的便是此种假设。
Closed-world assumption(OWA):世界是已知的,如果我们不能确定一件事情为真,那么就可以推断出他为假,而且一个事物只能有一个定义。数据库中通常使用该假设。

有时为了表达两个类之间的联系,可以使用匿名类作为中间值:
下面的例子表示叶子是树枝的一部分

<owl:Class rdf:ID="leaf">
	<rdfs:comment>Leaves are parts of branches. </rdfs:comment>
	<rdfs:subClassOf>
		<owl:Restriction>
			<owl:onProperty rdf:resource="#is-part-of"/>
			<owl:allValuesFrom rdf:resource="#branch"/>
		</owl:Restriction>
	</rdfs:subClassOf>
</owl:Class>
  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值