如何使用java通过sparql搜索rdf?
我正在语义网中做项目,我使用 SPARQL 来查询 rdf 数据。我在netbeans中使用java,我的问题是我的程序运行,输入rdf文件并且执行查询,但是不考虑查询的WHERE区域。 (即)我得到一个空表作为输出
你能告诉我任何关于JAVA中的SPARQL语法从rdf文件中检索所有姓名、电话号码的建议吗
I am doing project in semantic web where i use SPARQL to query rdf data. I used java in netbeans and my problem is my program runs,inputs the rdf file and the query executes but the WHERE area of my query is not considered. (i.e) i get a empty table as output
Can you please tel me any suggestions of SPARQL syntax in JAVA to retrieve all name,phone number from rdf file
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“不考虑我的查询的 WHERE 区域。(即,我得到一个空表作为输出”
我怀疑
WHERE
子句未被考虑。空表表明 a) 您没有数据或 b) 您的查询没有匹配项。检索所有姓名和电话号码取决于所使用的词汇,但迄今为止最常见的是 foaf:
我们需要更多信息,因此这里有一些通用建议:
SELECT * WHERE { ?s ?p ?o }
。这样有结果吗?如果没有,请尝试...SELECT * WHERE { graph ?g { ?s ?p ?o } }
。这样有结果吗?如果两者都不起作用,您的数据可能有问题。如果只有第二个得到结果,则说明您正在查询图表。
这将使您对以任何方式加载的内容有一个很好的了解。如果看起来没问题:
WHERE
子句中的一个元素。您还可以尝试用变量替换术语。以这种方式工作可能有助于追踪哪些元素导致查询失败。
"WHERE area of my query is not considered. (i.e) i get a empty table as output"
I doubt the
WHERE
clause is not being considered. An empty table suggests a) you have no data or b) your query has no matches.Retrieving all names and phone number depends on the vocabulary used, but the most common by far is foaf:
We need more information, so here's some generic advice:
SELECT * WHERE { ?s ?p ?o }
. Is that getting results? If not, try...SELECT * WHERE { graph ?g { ?s ?p ?o } }
. Is that getting results?If neither are working you may have issues with you data. If only the second gets result you check you are querying graphs.
This will give you a good idea about what you have loaded either way. If it looks ok:
WHERE
clause.You can also try replacing terms with variables. Working this way might help track down which elements are causing the query to fail.