AD Research Wiki:

SPARQL+Text example queries

Astronauts who walked on the moon

PREFIX fb: <http://rdf.freebase.com/ns/>
SELECT ?person ?name TEXT(?text) SCORE(?text) WHERE {
 ?person fb:people.person.profession ?profession .
 ?profession fb:type.object.name "Astronaut"@en .
 ?person fb:type.object.name ?name .
 ?text ql:contains-entity ?person .
 ?text ql:contains-word "walk* moon"
}
LIMIT 100
ORDER BY DESC(SCORE(?text))

Table for: City, country, population, latitude, longitude

PREFIX fb: <http://rdf.freebase.com/ns/>
SELECT DISTINCT ?cityname ?countryname ?populationnumber ?lat ?long WHERE {
  ?city fb:type.object.type fb:location.citytown .
  ?city fb:location.location.containedby ?country .
  ?city fb:location.statistical_region.population ?population .
  ?country fb:type.object.type fb:location.country .
  ?city fb:type.object.name ?cityname .
  ?country fb:type.object.name ?countryname .
  ?population fb:measurement_unit.dated_integer.number ?populationnumber .
  ?city fb:location.location.geolocation ?geolocation .
  ?geolocation fb:location.geocode.latitude ?lat .
  ?geolocation fb:location.geocode.longitude ?long .
}

AD Research Wiki: Projects/SparqlTextExampleQueries (last edited 2018-03-26 23:09:17 by Hannah Bast)