如何在 ROWLEX 中将数组归因于自定义类型
我有一些自定义类型:
[RdfSerializable]
public class Item
{
[RdfProperty(true)]
public string Name { get; set; }
}
以及一些具有项目数组的其他类型:
[RdfSerializable]
public class Container
{
// ... some code
// if this attribute is missing, then this property will not be exported as array
[CardinalityRestriction(1, 100)]
[RdfProperty(false)]
public Item[] MyArray { get { return mMyArray; } }
}
并且如果我从 MyArray 中删除 CardinalityRestriction 属性,OwlGrinder.exe 会将其导出为单个项目而不是项目数组。
是否有其他方法来定义数组而不将它们限制在某些元素范围内?
I have some custom type:
[RdfSerializable]
public class Item
{
[RdfProperty(true)]
public string Name { get; set; }
}
and some other type that has array of Item:
[RdfSerializable]
public class Container
{
// ... some code
// if this attribute is missing, then this property will not be exported as array
[CardinalityRestriction(1, 100)]
[RdfProperty(false)]
public Item[] MyArray { get { return mMyArray; } }
}
And it is happening that if I remove CardinalityRestriction attribute from MyArray it will be exported by OwlGrinder.exe as single Item and NOT as array of Items.
Is there some other way to define arrays without constraining them to some range of elements?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ROWLEX OntologyExtractor 行为正确(OwlGrinder 读取本体并生成程序集。OntologyExtractor 读取程序集并吐出出本体)。 根据 OWL 规范,如果没有与OWL 属性,则其基数被假定为“零或更多”。 如果您希望属性不是“数组属性”,那么您需要应用基数限制。 一种简写方式是将 OWL 属性设为功能属性,其中基数为 0 或 1。
因此您需要做的就是删除 [CardinalityRestiction(1,100)] 装饰,您就得到了您想要的。
[编辑:回应评论]
我重现了您的案例,删除了 CardinalityRestriction,并且 OntologyExtractor 生成以下本体:
该本体允许您创建 RDF 文件,其中您的容器对象具有通过 MyArray OWL 属性链接的零个或多个项目。
ROWLEX OntologyExtractor behaves correctly (OwlGrinder reads ontologies and produce assemblies. OntologyExtractor reads assemblies and spits out ontologies). According to the OWL specifications, if there is no cardinality restriction associated to the OWL property, then its cardinality is assumed "zero or more". Should you want a property be not an "array property" then you need to apply the cardinality restriction. A shorthand for that is making the OWL property a functional property, where the cardinality is 0 or 1.
So all you need to do is remove the [CardinalityRestiction(1,100)] decoration and you have what you want.
[EDIT: responding on the comment]
I reproduced your case, removed the CardinalityRestriction, and OntologyExtractor produces the following ontology:
This ontology allows you to create RDF files where your container object has zero or more items linked via MyArray OWL property.