DBpedia SPARQL Query American Universities

I created a SPARQL query that I run on a DBpedia SNORQL SPARQL endpoint . The purpose of the request is to obtain a list of universities or colleges in the United States, including their longitude, latitude, and donation. The request seems to work, but some entries and / or attributes seem to be missing. For example, Harvard University does not appear as a result, although there is a DBpedia entry , and the attributes must match my query. I do not know why this entry does not appear. Another example is the University of Massachusetts Boston , which appears as the result of a query, but the result does not receive longitude and latitude attributes, although the record contains these attributes. Here's the SPARQL query:

PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> PREFIX d: <http://dbpedia.org/ontology/> SELECT ?uni ?link ?lat ?long ?endowment WHERE { ?s foaf:homepage ?link ; rdf:type <http://schema.org/CollegeOrUniversity> ; rdfs:label ?uni OPTIONAL {?s geo:lat ?lat ; geo:long ?long . ?sd:endowment ?endowment . } FILTER (LANGMATCHES(LANG(?uni), 'en')) {?s dbpedia2:country "US"@en . } UNION {?s dbpedia2:country "US" . } UNION {?sd:country :United_States . } } ORDER BY ?s 
+4
source share
2 answers

The query you requested will only select objects with foaf:homepage and Harvard University does not. (That is, the resource does not have the foaf:homepage property. Obviously, the university has a homepage.) UMass Boston does not match an additional template -

 OPTIONAL {?s geo:lat ?lat ; geo:long ?long . ?sd:endowment ?endowment . } 

- because this pattern matches only when ?s has geo:lat , a geo:long and a d:endowment . Although the template is optional, the entire template must either match or not; you do not get partial matches.

Here's your query, redesigned to use the built-in namespaces that the DBPedia SPARQL endpoint currently supports (this list can be modified over time), with the OPTIONAL parts broken up as needed and moved to the end. (Moving them all the way to the end is just an aesthetic consideration.) I tried some different limitations, and it’s interesting to note that only 32 universities have dbpprop:country "US"@en , but 273 have dbpprop:country "United States"@en . A total of 7620 results were obtained.

 PREFIX dbpedia-owl: <http://dbpedia.org/ontology/> PREFIX dbpedia: <http://dbpedia.org/resource/> PREFIX dbpprop: <http://dbpedia.org/property/> SELECT ?label ?homepage ?lat ?long ?endowment WHERE { ?school a <http://schema.org/CollegeOrUniversity> { ?school dbpedia-owl:country dbpedia:United_States } UNION { ?school dbpprop:country dbpedia:United_States } UNION { ?school dbpprop:country "US"@en } UNION { ?school dbpprop:country "United States"@en } OPTIONAL { ?school rdfs:label ?label . FILTER (LANGMATCHES(LANG(?label), 'en')) } OPTIONAL { ?school foaf:homepage ?homepage } OPTIONAL { ?school geo:lat ?lat ; geo:long ?long } OPTIONAL { ?school dbpedia-owl:endowment ?endowment } } 

SPARQL Results

+5
source

You are looking for foaf:homepage , but some of them are not assigned. This is the first thing that caught my eye. Check the rest of the query by phasing out each item and see what the result set has to offer.

+1
source

Source: https://habr.com/ru/post/1485721/


All Articles