定义范围为有序列表的属性 [英] Defining a property whose range is an ordered list
问题描述
给出两个类Container
和Element
,我想定义一个属性contains
来描述Container
的内容.
Given two classes Container
and Element
, I would like to define a property contains
to describe the contents of a Container
.
但是,Elements
的顺序很重要,所以我不能简单地写
However, the order of Elements
is important, so I can't simply write
_:container :contains _:element1, _:element2, _:element3 .
如何正确定义contains
属性?
我看过rdf:List
和owl:Seq
,但是我不知道如何将其转换为我的本体.
I've looked at rdf:List
and owl:Seq
but I don't know how to translate that into my ontology.
推荐答案
您可以根据需求和用例的不同,以多种方式定义属性.
You can define your property in many ways depending on what your requirements and your use cases are.
首先,有时有可能避免完全使用列表或序列,而保持事物的顺序.如果要订购的元素具有固有顺序,则可以这样做.例如,如果要命名某人的孩子(从大到小),则可以使用hasChild
关系:
First, it is sometimes possible to avoid using lists or sequences completely, and yet keep the ordering of things. This can be done if the elements that you are ordering have an intrinsic order. For instance, if you want to name the children of someone from the oldest to the youngest, you can just use a hasChild
relation:
ex:someone onto:hasChild ex:child3, ex:child1, ex:child2 .
ex:child1 onto:birthDay "1995-10-25"^xsd:date .
ex:child2 onto:birthDay "1997-03-10"^xsd:date .
ex:child3 onto:birthDay "2003-01-14"^xsd:date .
如果您没有确切的日期,也可以使用关系isOlderThan
使订单明确.但是,这在许多情况下不起作用.如果您想说比赛的参加者到达终点的顺序,您不能说:
If you do not have the exact dates, it is also possible to use a relation isOlderThan
to make the order explicit. However, this cannot work in many cases. If you want to say in which order participants to a race arrived at the finish line, you cannot say:
ex:runner1 onto:arrivedBefore ex:runner2 .
# etc.
因为这仅适用于该特定种族.一种解决方案是使用RDF列表,如下所示:
because this only applies to this particular race. One solution is to use an RDF list like so:
ex:race42 onto:arrival (ex:runner1 ex:runner2 ex:runner3) .
但是,不能在OWL DL中像这样使用RDF列表. OWSW处理此类列表的典型方式是AKSW在其评论中链接到的文档中所描述的内容.也就是说,您定义了模仿RDF列表构造的类和属性:
However, RDF lists cannot be used like this in OWL DL. The typical way of dealing with such lists in OWL is what is described in the document that AKSW links to in his comment. That is, you define a class and properties that mimic the RDF list constructs:
ex:container42 onto:contains [
a listonto:OWLList;
listonto:hasElement ex:element1;
listonto:hasNext [
a listonto:OWLList;
listonto:hasElement ex:element2;
listonto:hasNext [
a listonto:OWLList;
listonto:hasElement ex:element3;
listonto:hasNext listonto:emptylist
]
]
] .
这不是唯一的解决方案.也可以使用rdf:Seq
(尽管许多人通常不建议使用).同样,这不能在OWL DL中使用.但是,可以引入一种本体,该本体部分地模仿rdf:Seq
的工作方式:
This is not the only solution. Using rdf:Seq
is also an option (though usually discouraged by many people). Again, this cannot be used in OWL DL. However, one can introduce an ontology that partially mimics the way rdf:Seq
works:
ex:container42 onto:contains [
a seqonto:Sequence;
seqonto:hasSlots
[ a seqonto:Slot; seqonto:content ex:element1; seqonto:position 1 ],
[ a seqonto:Slot; seqonto:content ex:element2; seqonto:position 2 ],
[ a seqonto:Slot; seqonto:content ex:element3; seqonto:position 3 ],
seqonto:numberOfElements 3
] .
具有其编号的属性position
用于模仿RDF词汇表中的属性rdf:_1
,rdf:_2
等.标识最后一个插槽的其他方法可以是特殊的seqonto:lastSlot
属性.请注意,这就是排序列表本体的作用.
The property position
with its number are used to mimic the properties rdf:_1
, rdf:_2
, etc. from the RDF vocabulary. Other ways of identifying the last slot could be a special seqonto:lastSlot
property. Note that this is what the ordered list ontology does.
也许还有其他选择,可能涉及这里讨论的选择,但我认为它涵盖了大多数可能性.
There may be other options, probably as involved as the ones discussed here, but I think it covers most possibilities well enough.
这篇关于定义范围为有序列表的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!