如何在sparql中获取个人数据属性值 [英] How to get individuals data property value in sparql
问题描述
我是本体的新手.我已经通过Protege软件开发了餐厅本体.但是我非常需要一个SPARQL查询,该查询可以为一个类的所有个体查找属性值.
Hi i am in new to ontologies. I have developed a restaurant ontology by Protege software. But I badly need a SPARQL query that finds property values for all individuals of a class.
我想要得到这样的结果:
I want to get a result like:
Angels_n_Gypsies
House #30, Rd No. 19/A, Dhaka 1213, Bangladesh
推荐答案
只需遵循属性值...
Just follow the property values...
SELECT ?rname ?lname
WHERE {
?inst a :Popular_restaurant .
?inst :restaurant_name ?rname .
?inst :Location_name ?lname .
}
但这只是最终结果.了解SPARQL的一种方法是徒劳地开始.例如:
But that's just the end result. A way to understand SPARQL is to start pedantically. For example:
SELECT ?inst
WHERE {
?inst a :Popular_restaurant .
}
这使您成为该类的所有成员:Popular_restaurant.然后找到为每个成员定义了哪些属性:
That gets you all members of the class :Popular_restaurant. Then find what properties are defined for each member:
SELECT ?inst ?p ?o
WHERE {
?inst a :Popular_restaurant .
?inst ?p ?o .
}
p
的绑定将告诉您为此类的成员定义了哪些属性.因此,请使用这些值来不断优化查询.
And the bindings for p
will tell you what properties are defined for members of this class. So use those values to continuously refine the query.
这篇关于如何在sparql中获取个人数据属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!