目前,您的表示有效,但在我看来,它有点令人费解。您最终会得到如下实例数据:
Chihuahua describedBy fluffiness72 .
fluffiness72 hasValue 4.
正如您所注意到的,您可以改为拥有一个 hasFluffiness 数据类型属性,但如果您不想这样做,我认为您最好的选择是拥有一个Attribute类,其中诸如Fluffiness、Size、Friendliness等是实例。然后,您可以拥有一个AttributeValue类和 properties属性和值(您可能会想出更好的名称),这样您就可以像这样编写数据:
:chihuahua62 rdf:type :Chihuahua ;
:hasAttributeValue [ :attribute :Fluffiness ; :value 3 ] ;
:hasAttributeValue [ :attribute :Friendliness ; :value 2 ] .
通过这种表示,您可以说“每只吉娃娃的蓬松度都低于 4”:
((∃hasAttributeValue -1 .Chihuahua) ⊓ (=attribute.Fluffiness)) ⊑ ∀value.xsd:float[≤4.0]
((( inverse (hasAttributeValue) some Chihuahua) and (attribute value Fluffiness)) SubClassOf (value only xsd:float[<= 4.0])
用英语表示,吉娃娃的每个属性值都必须小于 4.0。
您可以使用另一种表示形式,即“如果吉娃娃具有属性值,则如果该属性是蓬松度,则该值小于 4.0”。这相当于“如果一只吉娃娃有一个属性值,那么要么该属性不是Fluffiness,要么该值小于 4.0”:
吉娃娃 ⊑ ∀hasAttributeValue.(¬(=attribute.Fluffiness) ⊔ (∀value.xsd:float[≤4.0]))
这更容易写入本体编辑器,因为它是关于您感兴趣的类的子类公理。
这是一个显示这两种方法的本体:
@prefix : <http://stackoverflow.com/q/24760392/1281433/dogProperties#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
:Shagginess a owl:NamedIndividual , :Attribute .
:hasValue a owl:DatatypeProperty ;
rdfs:domain :_attVal .
[ a owl:Class ;
rdfs:subClassOf [ a owl:Restriction ;
owl:allValuesFrom [ a rdfs:Datatype ;
owl:onDatatype xsd:float ;
owl:withRestrictions ( [ xsd:minInclusive
10 ] )
] ;
owl:onProperty :hasValue
] ;
owl:intersectionOf ( [ a owl:Restriction ;
owl:onProperty [ owl:inverseOf :hasAttributeValue ] ;
owl:someValuesFrom :Newfoundland
] [ a owl:Restriction ;
owl:hasValue :Shagginess ;
owl:onProperty :hasAttribute
] )
] .
:Newfoundland a owl:Class ;
rdfs:subClassOf :Dog .
:Attribute a owl:Class .
:_attVal a owl:Class .
:hasAttribute a owl:ObjectProperty ;
rdfs:domain :_attVal ;
rdfs:range :Attribute .
:Chihuahua a owl:Class ;
rdfs:subClassOf :Dog ;
rdfs:subClassOf [ a owl:Restriction ;
owl:allValuesFrom [ a owl:Class ;
owl:unionOf ( [ a owl:Class ;
owl:complementOf [ a owl:Restriction ;
owl:hasValue :Shagginess ;
owl:onProperty :hasAttribute
]
] [ a owl:Restriction ;
owl:allValuesFrom [ a rdfs:Datatype ;
owl:onDatatype xsd:float ;
owl:withRestrictions ( [ xsd:maxInclusive
4 ] )
] ;
owl:onProperty :hasValue
] )
] ;
owl:onProperty :hasAttributeValue
] .
:hasAttributeValue a owl:ObjectProperty ;
rdfs:range :_attVal .
:Dog a owl:Class .
<http://stackoverflow.com/q/24760392/1281433/dogProperties>
a owl:Ontology .