【问题标题】:in owl "Dl query" how to use advanced valu query in protege在 owl "Dl query" 如何在 protege 中使用高级值查询
【发布时间】:2009-05-09 03:18:41
【问题描述】:

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

有一个类叫“花”

这个类有一些花名的子类

还有另一个类叫做“flowersColor”

它具有这些值(“red”、“green”和“blue”)作为个体——而不是子类——

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

我想寻找一朵只有红色的红色花朵

我的深度学习查询是:

“花和有颜色值红色”

这个查询将给我所有红色的花,即使它有其他颜色

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

我想写这样的东西

"flower and hasColor only value red"

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

希望你能帮我解答一下

谢谢

【问题讨论】:

    标签: semantic-web owl protege4 dlquery manchester-syntax


    【解决方案1】:

    请记住,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>
    

    【讨论】:

      【解决方案2】:

      您要查询的是:

      flower and (hasColor only {red})
      

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-03-29
        • 1970-01-01
        相关资源
        最近更新 更多