【发布时间】:2013-03-29 12:29:03
【问题描述】:
如何在 OWL 中声明属性必须具有一组有序值?
例如:一个节目必须有一个 rdf:Seq of Series,而一个 Series 必须有一个 rdf:Seq of Episodes?
http://purl.org/ontology/po/ 本体使用 http://purl.org/ontology/po/position 属性代替。
哪种方法更好?
【问题讨论】:
如何在 OWL 中声明属性必须具有一组有序值?
例如:一个节目必须有一个 rdf:Seq of Series,而一个 Series 必须有一个 rdf:Seq of Episodes?
http://purl.org/ontology/po/ 本体使用 http://purl.org/ontology/po/position 属性代替。
哪种方法更好?
【问题讨论】:
在 OWL(和 RDF)中很难表示序列,它更多的是关于无序的集合。我发现最好的方法是通过属性分配一个数字,然后跟踪该索引并在需要时使用它进行迭代。
表示您要捕获的内容的 OWL 本体可能是这样的(使用曼彻斯特语法 - 您可以保存为 .owl 文件并使用 Protege - # 是 cmets 打开):
Prefix: xsd: <http://www.w3.org/2001/XMLSchema#>
Prefix: owl: <http://www.w3.org/2002/07/owl#>
Prefix: : <brain#>
Prefix: xml: <http://www.w3.org/XML/1998/namespace>
Prefix: rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
Prefix: dc: <http://purl.org/dc/elements/1.1/>
Prefix: rdfs: <http://www.w3.org/2000/01/rdf-schema#>
Ontology: <brain.owl>
Datatype: xsd:int
ObjectProperty: has
Characteristics:
Transitive
# Property used to save the number in the sequence
DataProperty: episode-number
Range:
xsd:int
# Definition of a program: A program as at least a series
Class: Program
SubClassOf:
has some Series
Class: owl:Thing
# Definition of series: A series as at least one episode
Class: Series
SubClassOf:
has some Episode
Class: Episode
# Instance of episode
Individual: episode1
Types:
Episode
# Episode number
Facts:
episode-number "1"^^xsd:int
# Second instance of episode
Individual: episode2
Types:
Episode
Facts:
episode-number "2"^^xsd:int
假设您想要迭代剧集实例。这可以通过 OWL 查询 Episode and episode-number value 1 来实现。您必须自己更新号码。
【讨论】:
subClassOf),但也可以与 equivalentClass 一起使用(对本体进行分类时会产生更强的后果)。
我如何在 OWL 中声明一个属性必须有一组有序的 价值观?例如:一个程序必须有一个 rdf:Seq of Series 和一个 系列必须有一个 rdf:Seq of Episodes?
如果您正在使用 OWL (DL),那么您不应该真正使用 RDF 集合。 loopasam's answer 很好,如果您可以具体化关系并包含位置编号,但您也可以在类似于 RDF 列表的 OWL 中声明自己的列表结构(这只是单链表的 RDF 编码)。这样你就可以拥有
:series hasEpisodeList [ ex:first :episodeA ;
ex:rest [ ex:first :episodeB ;
ex:rest [ :episodeC ;
ex:rest ex:nil ] ] ] .
不过,这种方法的缺点是数字信息只是隐含的,而且使用 DL 查询很难重构(尽管使用 SPARQL 并不太难)。在Ordering of entities in an ontology 和它链接的其他问题和答案中更详细地描述了两种表示序列的方法。
【讨论】: