如何定义一个类 Road 等价于一组具有相同 hasRoadNumber 数据属性值的对象 [英] How to define a class Road to be equivalent to a set of objects with the same value of hasRoadNumber data property
本文介绍了如何定义一个类 Road 等价于一组具有相同 hasRoadNumber 数据属性值的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我定义了类 RoadSegment
和数据类型属性 hasRoadNumber
.所以,现在我想定义 Road
类并声明 Road
是一组具有相同道路编号的 RoadSegments
.怎么做?
I defined class RoadSegment
and datatype property hasRoadNumber
. So, now I want to define class Road
and state that a Road
is a set of RoadSegments
with the same road number. How it can be done?
推荐答案
让我们假设这个数据
<r123> a :Road; :number "123".
<r123.1> a :RoadSegment; :number "123"; :seq 1.
<r123.2> a :RoadSegment; :number "123"; :seq 2.
您可以使用此 GraphDB 规则 (.pie) 轻松推断出您想要的内容:
You can easily infer what you want with this GraphDB rule (.pie):
id: roadSegments
r <rdf:type> <Road>
rs <rdf:type> <RoadSegment>
r <number> n
rs <number> n
-------------
r <hasSegment> rs
好处是规则是动态的,即当您添加/删除/编辑段时,:hasSegment
将动态更新.
The benefit is that the rule is dynamic, i.e. as you add/remove/edit segments, :hasSegment
will be updated dynamically.
至于序列,有多种模式可以表示它们.
As for sequences, there are various patterns to represent them.
rdf:List
是标准的,但非常笨拙.- 使用序列号使事情变得更容易,例如 https://schema.org/ItemList 使用它(但与上面不同的是,允许一个项目成为多个列表的成员,使用辅助类 https://schema.org/ListItem一>.
rdf:List
is standard but quite unwieldy.- Using a sequence number makes things easier, eg https://schema.org/ItemList uses it (but unlike above, allows an item to be member of several lists, using auxiliary class https://schema.org/ListItem.
这篇关于如何定义一个类 Road 等价于一组具有相同 hasRoadNumber 数据属性值的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文