如果我想说某事的标题应该是rdfs:Literal,我这样做:
example:title a owl:DatatypeProperty ;
rdfs:range rdfs:Literal .
现在我想表达一些有序的标题列表:
example:titles a rdf:List .
如何指定列表成员应该是什么?我是否需要继承rdf:List?
更新:我想继续使用rdf:List,如果可能,基于Joshua的回答我认为以下说任何rdf:List只有rdfs:Literal值是一个例子:ListOfLiterals,然后我可以使用这是一个范围。
@prefix entity: <http://example.com/stuff/> .
@prefix example: <http://example.com/my/term/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
example:ListOfLiterals a owl:Class ;
owl:equivalentClass [
a owl:Class ;
owl:intersectionOf (
rdf:List
[
a owl:Restriction ;
owl:allValuesFrom rdfs:Literal ;
owl:onProperty rdf:first
]
[
a owl:Restriction ;
owl:allValuesFrom example:ListOfLiterals ;
owl:onProperty rdf:rest
] )
] .
example:Book a owl:Class .
example:titles a owl:DatatypeProperty ;
rdfs:domain example:Book ;
rdfs:range example:ListOfLiterals .
entity:somebook a example:Book ;
example:titles ( "Book Title"@en "Second Book Title"@en ) .
这有什么意义,还是我误解了什么?
答案 0 :(得分:8)
首先,请注意在您的OWL代码中使用rdf:List
意味着您将使用OWL Full,而许多reasoners旨在与OWL DL一起使用。你可能对此感到满意,如果你愿意,那就太好了。如果你需要留在OWL DL中,那么你必须使用你自己的词汇表来列表,例如,一个班级warp:List
和一个属性warp:first
和warp:rest
,并使用它们而不是他们的RDF同行。
无论如何,一旦您决定使用List
课程以及first
和rest
属性,就可以定义一个只能包含ListOfElements
的列表类型Element
某个班级ElementList
的成员有以下限制:
元素列表⊑列出和(第一个仅元素)和(其余仅元素列表)
这意味着List
是:(i)first
; (ii)具有Element
属性ElementList
的值; (iii)rest
为List
,这意味着Element
中的其他内容也必须为nil
。无论List
对象应该已经被声明为TitleList
,但您可能还想包括:
nil a ElementList
但这并不一定重要。对于您的情况,您希望以类似的方式定义类TitleList
,然后将您的属性范围声明为List
。
这是一个示例本体,其中包括仅定义这些类型的ElementList
类和@prefix : <http://stackoverflow.com/a/19480798/1281433/code#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
:rest a owl:ObjectProperty ;
rdfs:domain :List ;
rdfs:range :List .
:List a owl:Class .
:nil a owl:NamedIndividual , :ElementList , :List .
:ElementList a owl:Class ;
rdfs:subClassOf [ a owl:Class ;
owl:intersectionOf ( :List [ a owl:Restriction ;
owl:allValuesFrom :Element ;
owl:onProperty :first
] [ a owl:Restriction ;
owl:allValuesFrom :ElementList ;
owl:onProperty :rest
] )
] .
:Element a owl:Class .
:first a owl:ObjectProperty ;
rdfs:domain :List .
<http://stackoverflow.com/a/19480798/1281433/code>
a owl:Ontology .
[ a owl:Axiom ;
rdfs:comment "It's probably a good idea to specify that nil is an ElementList. This could also be inferred, though, if there is a nil-terminated List that is known to be an ElementList." ;
owl:annotatedProperty rdf:type ;
owl:annotatedSource :nil ;
owl:annotatedTarget :ElementList
] .
类(在人类可读的Turtle中):
List
为了完全普遍,我已经定义了新的first
类,rest
和nil
属性以及个人rdf:List
,但是如果OWL Full可以使用你,那么你可以使用<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns="http://stackoverflow.com/a/19480798/1281433/code#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://stackoverflow.com/a/19480798/1281433/code"/>
<owl:Class rdf:about="http://stackoverflow.com/a/19480798/1281433/code#List"/>
<owl:Class rdf:about="http://stackoverflow.com/a/19480798/1281433/code#ElementList">
<rdfs:subClassOf>
<owl:Class>
<owl:intersectionOf rdf:parseType="Collection">
<owl:Class rdf:about="http://stackoverflow.com/a/19480798/1281433/code#List"/>
<owl:Restriction>
<owl:onProperty>
<owl:ObjectProperty rdf:about="http://stackoverflow.com/a/19480798/1281433/code#first"/>
</owl:onProperty>
<owl:allValuesFrom>
<owl:Class rdf:about="http://stackoverflow.com/a/19480798/1281433/code#Element"/>
</owl:allValuesFrom>
</owl:Restriction>
<owl:Restriction>
<owl:onProperty>
<owl:ObjectProperty rdf:about="http://stackoverflow.com/a/19480798/1281433/code#rest"/>
</owl:onProperty>
<owl:allValuesFrom rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#ElementList"/>
</owl:Restriction>
</owl:intersectionOf>
</owl:Class>
</rdfs:subClassOf>
</owl:Class>
<owl:ObjectProperty rdf:about="http://stackoverflow.com/a/19480798/1281433/code#rest">
<rdfs:range rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#List"/>
<rdfs:domain rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#List"/>
</owl:ObjectProperty>
<owl:ObjectProperty rdf:about="http://stackoverflow.com/a/19480798/1281433/code#first">
<rdfs:domain rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#List"/>
</owl:ObjectProperty>
<owl:Axiom>
<rdfs:comment>It's probably a good idea to specify that nil is an ElementList. This could also be inferred, though, if there is a nil-terminated List that is known to be an ElementList.</rdfs:comment>
<owl:annotatedTarget rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#ElementList"/>
<owl:annotatedSource>
<owl:NamedIndividual rdf:about="http://stackoverflow.com/a/19480798/1281433/code#nil">
<rdf:type rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#ElementList"/>
<rdf:type rdf:resource="http://stackoverflow.com/a/19480798/1281433/code#List"/>
</owl:NamedIndividual>
</owl:annotatedSource>
<owl:annotatedProperty rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"/>
</owl:Axiom>
</rdf:RDF>
等。为了完整起见,这里是RDF / XML中相同的本体:
{{1}}