SPARQL 查询中规则的使用

发布于 2025-01-09 11:34:26 字数 871 浏览 0 评论 0原文

我想在我的本体中使用规则,以便在推理时我可以检索一些在三元组存储中未明确表达的信息。 我创建了一个基本本体,我想添加此规则:

Person(?p) ^ hasSibling(?p, ?s) ^ Man(?s) → hasBrother(?p, ?s)

我想要执行的 SPARQL 查询正在

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX prova: <http://www.example.it/prova/>
SELECT ?subject ?object
    WHERE { ?subject prova:hasBrother ?object }

运行,但不会返回任何内容。当然,我已经为每个类创建了个体,但我没有创建涉及 hasBrother 的实例,因为这是我希望智能自行检索的内容。 那么,我的问题是:是否可以使用SPARQL查询来实现规则描述的推理?或者这些类型的推论只能通过专用的查询系统才能实现?例如,在 protegè 中,我了解了 SQWRL 选项卡。

我正在使用最新版本的 Protegè (5.5.0) 和最新版本的 SWRL 规则插件 (2.11)。我已经在 SWRL 选项卡中定义了规则。然后我尝试使用 SQWRL 选项卡执行查询,但出现与“无效查询名称”相关的奇怪错误,我不太明白。关于第二点的任何建议都会有所帮助。

I would like to use rules in my ontology so that at the moment of the inference I can retrieve some information not explicitly expressed in the triplestore.
I created a basic ontology and I want to add this rule:

Person(?p) ^ hasSibling(?p, ?s) ^ Man(?s) → hasBrother(?p, ?s)

The SPARQL query I would like to perform is

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX prova: <http://www.example.it/prova/>
SELECT ?subject ?object
    WHERE { ?subject prova:hasBrother ?object }

Running this does not return anything. Of course, I have created the individuals for each class, but I have not created the instance that involves hasBrother, as this is what I want the intelligence to retrieve by itself.
So, my question is: is it possible to use SPARQL queries to achieve inference described by rules? Or these kind of inferences are only possible with a dedicated query system? In protegè I learn about the SQWRL tab for instance.

I am using the last version of Protegè (5.5.0) and the last version of the SWRL Rules plugin (2.11). I have defined the rule in the SWRL Tab. Then I tried the SQWRL tab to perform the query, but I get a strange error related to "invalid query name", which I don't really understand. Any suggestion about this second point would be helpful.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文