简体   繁体   中英

How to get individuals data property value in 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.

protege屏幕截图

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 .
}

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 .
}

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 .
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM