在owl“Dl查询”中 如何在 protege 中使用高级值查询

发布于 2024-07-18 11:27:46 字数 452 浏览 11 评论 0原文

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

有一个名为“flower”的类

,该类有一些子类,它们是一些花的名称

,还有另一个名为“flowersColor”的类

,它具有这些值(“red”) ”,“绿色”和“蓝色”)作为个体 - 不是子类 -

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

我想搜索一朵有红色并且只有红色的花

我的DL查询是:

“花和hasColor值红色”

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

,但是我想要所有仅具有红色的花

我想写这样的内容

“花和 hasColor 仅值红色”< - 这是不正确的从语法上讲,

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

我希望你能在我的查询中帮助我

谢谢

I am developing an ontology and I have a problem with my Dl query

there is a class called "flower"

and this class has subclasses which are some flowers names

and also there is another class called "flowersColor"

and it has these values ("red","green" and "blue") as individuals-not subclass-

every flower has one color or more

I want to search for a flower that has red color and only red

my DL Query is :

"flower and hasColor value red"

this query will give me all flowers that has the color red even if it has other colors

however I want all flowers that has ONLY the color red

I want to write something like this

"flower and hasColor only value red" <- this is not correct grammatically

I main if the color has a combination of "red" and "green" then I don't want to see it in my result

I hope you can help me in my query

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天气好吗我好吗 2024-07-25 11:27:46

请记住,OWL 使用开放世界假设,因此通过描述逻辑推断的内容会受到一定限制。

因此,正如卡雷尔提到的,你的“查询”可能是:

flower and (hasColor only {red})

然而,这在开放世界假设中是无法证明的。 在宇宙中的某个地方可能有这样的语句,它断言:

<RedRose> :hasColor :StackOverflow .

当与你的断言(你试图查询的)结合时:

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

将导致深度学习查询不返回任何结果。 因此,由于开放世界假设,以及理论上存在疯狂、不准确和不相关的断言(至少从您的角度来看),深度学习查询将失败,因为它只能推断它可以证明是真实的陈述。

但是,您的示例查询可以在 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>

Remember that OWL uses the open world assumption, so you are somewhat limited in what can be inferred via description logic.

So your "query", as Kaarel mentions, could be:

flower and (hasColor only {red})

Yet this is unprovable in the open world assumption. There could be statement, somewhere in the universe, which asserts:

<RedRose> :hasColor :StackOverflow .

Which, when combined with your assertions (which you're trying to query):

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

Will cause the DL query to return no results. So due to the open world assumption, and the theoretical existence of wild, inaccurate, and irrelevant assertions (at least from your perspective), the DL query will fail, since it can only infer statements it can prove are true.

However, your example query can be used in an OWL restriction to determine if something is not something else. As an example, if you have a class (:OnlyRedFlower) which must only have the color red, but it has the color blue (you've asserted this additional color), then you can infer that this new flower is not in the set of :OnlyRedFlower.

Update: For those that are interested in trying this themselves, here's the ontology I created based on this question:

<?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>
一城柳絮吹成雪 2024-07-25 11:27:46

您执行的查询是:

flower and (hasColor only {red})

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

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

The query that you are after is:

flower and (hasColor only {red})

Note that the {.} constructor creates a class from an individual, or a list of individuals. So you can use it everywhere where a class is syntactically required, e.g.

(not {blue}) subClassOf
             {red} and {green,blue} or (hasColor max 10 ({red} or {blue}))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文