繁体   English   中英

在猫头鹰“ Dl查询”中如何使用高级值查询

[英]in owl “Dl query” how to use advanced valu query in protege

我正在开发一个本体,而我的Dl查询有问题

有一个叫做“花”的类

这个类有一些花名的子类

还有另一个叫做“ flowersColor”的类

并且具有这些值(“红色”,“绿色”和“蓝色”)作为个人,而不是子类,

每朵花都有一种或多种颜色

我想搜索只有红色的花朵

我的DL查询是:

“花和hasColor值红色”

该查询将为我提供所有具有红色的花朵,即使它具有其他颜色

但是我想要所有只有红色的花朵

我想写这样的东西

“ flower和hasColor仅值红色” <-语法上不正确

我主要是如果颜色包含“红色”和“绿色”的组合,那么我不想在结果中看到它

希望您能帮我查询

谢谢

请记住,OWL使用开放世界假设,因此您在通过描述逻辑进行推断时会受到一些限制。

因此,正如Kaarel所说,您的“查询”可能是:

flower and (hasColor only {red})

但这在开放世界的假设中是无法证明的。 在宇宙的某个地方可能有这样的陈述:

<RedRose> :hasColor :StackOverflow .

与您的断言(您要查询的)结合使用时:

<RedRose> :hasColor :Red .
<RedRose> a :Flower .

将导致DL查询不返回任何结果。 因此,由于开放世界的假设,以及理论上存在野性,不准确和不相关的断言(至少从您的角度来看),DL查询将失败,因为它只能推断出可以证明是正确的语句。

但是,可以在OWL限制中使用示例查询来确定是否不是其他内容。 例如,如果您有一个类( :OnlyRedFlower ),该类只必须具有红色,但是具有蓝色(您已经声明了该其他颜色),则可以推断出该新花不在集合中来自:OnlyRedFlower

更新:对于那些有兴趣自己尝试的人,这是我根据此问题创建的本体:

<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
    <!ENTITY owl "http://www.w3.org/2002/07/owl#" >
    <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
    <!ENTITY owl2xml "http://www.w3.org/2006/12/owl2-xml#" >
    <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
    <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
    <!ENTITY onto "http://www.elastra.com/onto/2009/5/30/onto.owl#" >
]>
<rdf:RDF xmlns="http://stackoverflow.com/users/64881/ontology_842588.rdf#"
     xml:base="http://stackoverflow.com/users/64881/ontology_842588.rdf"
     xmlns:owl2xml="http://www.w3.org/2006/12/owl2-xml#"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:onto="http://www.elastra.com/onto/2009/5/30/onto.owl#">
    <owl:Ontology rdf:about="">
        <rdfs:comment xml:lang="en"
            >Example for http://stackoverflow.com/questions/842588/in-owl-dl-query-how-to-use-advanced-valu-query-in-protege</rdfs:comment>
    </owl:Ontology>
    <owl:ObjectProperty rdf:about="&onto;hasColor"/>
    <owl:Class rdf:about="&onto;Color"/>
    <owl:Class rdf:about="&onto;ExampleFlower">
        <rdfs:subClassOf rdf:resource="&onto;Flower"/>
    </owl:Class>
    <owl:Class rdf:about="&onto;Flower"/>
    <owl:Class rdf:about="&onto;OnlyRedFlower">
        <owl:equivalentClass>
            <owl:Class>
                <owl:intersectionOf rdf:parseType="Collection">
                    <rdf:Description rdf:about="&onto;Flower"/>
                    <owl:Restriction>
                        <owl:onProperty rdf:resource="&onto;hasColor"/>
                        <owl:allValuesFrom>
                            <owl:Class>
                                <owl:oneOf rdf:parseType="Collection">
                                    <rdf:Description rdf:about="&onto;Red"/>
                                </owl:oneOf>
                            </owl:Class>
                        </owl:allValuesFrom>
                    </owl:Restriction>
                </owl:intersectionOf>
            </owl:Class>
        </owl:equivalentClass>
        <rdfs:subClassOf rdf:resource="&onto;Flower"/>
    </owl:Class>
    <owl:Class rdf:about="&onto;OtherFlower">
        <rdfs:subClassOf rdf:resource="&onto;Flower"/>
    </owl:Class>
    <onto:Color rdf:about="&onto;Blue">
        <rdf:type rdf:resource="&owl;Thing"/>
    </onto:Color>
    <onto:Flower rdf:about="&onto;BlueOrchid">
        <rdf:type rdf:resource="&owl;Thing"/>
        <onto:hasColor rdf:resource="&onto;Blue"/>
    </onto:Flower>
    <onto:Color rdf:about="&onto;Red">
        <rdf:type rdf:resource="&owl;Thing"/>
    </onto:Color>
    <onto:Flower rdf:about="&onto;RedRose">
        <rdf:type rdf:resource="&owl;Thing"/>
        <onto:hasColor rdf:resource="&onto;Red"/>
    </onto:Flower>
</rdf:RDF>

您要查询的是:

flower and (hasColor only {red})

请注意, {.}构造函数根据一个人或一个人的列表创建一个类。 因此,您可以在需要语法的任何地方使用它,例如

(not {blue}) subClassOf
             {red} and {green,blue} or (hasColor max 10 ({red} or {blue}))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM