python - 来自 AllegroGraph Python API 的 Prolog 查询中的 OWL 推理

标签 python prolog triplestore allegrograph

我注意到在 AllegroGraph Python API 教程 here ,每当他们想要使用 OWL 推理时,他们都会使用 conn.getStatements 方法,而不是发出 Prolog 或 SPARQL 查询。是否可以通过发出 Prolog 或 SPARQL 查询而不是使用 conn.getStatements 方法来从 OWL 推理器推断出三元组?我尝试了 Prolog 查询:

(select (?x ?y) (q ?x !ex:owned-by ?y))

我将owned-by定义为owl:inverseOf ex:owns,并在我的商店中有三元组ex:someone ex:owns ex:something,并且我没有结果。我确实通过使用 conn.getStatements 获得了结果,那么我是否遗漏了 Prolog 查询中的一些重要内容?

最佳答案

在调用评估之前,您是否对从prepareTupleQuery返回的查询对象调用了setIncludeInferred?

http://www.franz.com/agraph/support/documentation/v4/python-tutorial/python-API-40.html#Query%20Class

IncludeInferred 默认为 False。我相信有效值为 false(无推理)、“rdfs++”或 True 以及“restriction”,如 infer http 查询参数的 HTTP Rest 文档中所述。 Python 实现只是传递值。

http://www.franz.com/agraph/support/documentation/v4/http-protocol.html#header2-364

关于python - 来自 AllegroGraph Python API 的 Prolog 查询中的 OWL 推理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10489540/

相关文章:

python - sklearn train_test_split on pandas 按多列分层

Python,如何从列表列表中有效地制作嵌套字典

recursion - Prolog 程序中的无效结果

prolog - Prolog 中没有统一的匹配模式

sparql - 使用命名图会影响检索查询结果的速度吗?

semantic-web - 芝麻内存三重存储

python - 识别航拍图像上的人行横道

list - 在 Prolog 中反转列表

rdf - 在构建语义 Web 应用程序时,OWL 是如何实际使用的?

python - PLY Lex 和 Yacc 问题