57394

Syntax for Sparql query for pages with specific infobox

Question:

I'm trying Sparql for the first time (on dbpedia) and can't get any queries to work. Everything I try returns a syntax error or an empty dataset.

For example, I tried the queries on <a href="https://stackoverflow.com/questions/12353537/sparql-exact-match-regex" rel="nofollow">this page</a>. They didn't work, so I made the following changes:<br /> - I read that wikiPageUsesTemplate has changed to <a href="http://dbpedia.org/ontology/wikiPageUsesTemplate" rel="nofollow">http://dbpedia.org/ontology/wikiPageUsesTemplate</a>,<br /> - I add 'WHERE' to select statement, though I guess that must be optional,<br /> - I reduced the whole thing to a minimum: just the infobox clause.

But it still doesn't work! Here is what I came up with:

PREFIX dbo: <http://dbpedia.org/ontology/> SELECT * WHERE { ?page dbo:wikiPageUsesTemplate <http://dbpedia.org/resource/Template:Infobox_artist> } LIMIT 100

I have been trying my queries <a href="http://dbpedia.org/snorql/" rel="nofollow">here</a>.

Answer1:

I'm not sure why you're using dbpedia-owl:wikiPageUsesTemplate. According to <a href="http://wiki.dbpedia.org/Datasets39/Properties" rel="nofollow">http://wiki.dbpedia.org/Datasets39/Properties</a> (emphasis added):

<blockquote>

<a href="http://xx.dbpedia.org/property/wikiPageUsesTemplate" rel="nofollow">http://xx.dbpedia.org/property/wikiPageUsesTemplate</a> (<strong>may be</strong> changed to <a href="http://dbpedia.org/ontology/wikiPageUsesTemplate" rel="nofollow">http://dbpedia.org/ontology/wikiPageUsesTemplate</a> in <strong>future releases</strong>)

</blockquote>

I'm not whether the current data in DBpedia is a future release (in terms of that document), but it sounds like you should still be on the old property. It's easy enough to test this, though. Since you have a query language and a webservice, it's quite easy to try a more general result as a sort of sanity check. In particular, something like the following very strongly suggests that it's not the property you want.

SELECT * WHERE { ?s <http://dbpedia.org/ontology/wikiPageUsesTemplate> ?o } LIMIT 100

<a href="http://dbpedia.org/sparql?default-graph-uri=http://dbpedia.org&query=SELECT%20%2a%20%20WHERE%20%7B%0D%0A%20%20?s%20%3Chttp://dbpedia.org/ontology/wikiPageUsesTemplate%3E%20?o%20%20%20%20%20%20%20%20%20%0D%0A%7D%0D%0ALIMIT%20100&format=text/html&timeout=30000&debug=on" rel="nofollow">SPARQL results (0 results)</a>

Similarly, since you've got an interactive endpoint, why not try seeing what properties <em>do</em> relate things to <http://dbpedia.org/resource/Template:Infobox_artist>, and by what properties?

SELECT distinct ?p WHERE { ?s ?p <http://dbpedia.org/resource/Template:Infobox_artist> } limit 500

<a href="http://dbpedia.org/sparql?default-graph-uri=http://dbpedia.org&query=SELECT%20distinct%20?p%20%20WHERE%20%7B%0D%0A%20%20?s%20?p%20%3Chttp://dbpedia.org/resource/Template%3aInfobox_artist%3E%20%20%20%20%20%20%0D%0A%7D%0D%0Alimit%20500&format=text/html&timeout=30000&debug=on" rel="nofollow">SPARQL results (2 results)</a>

The two results are

http://www.w3.org/2002/07/owl#sameAs http://dbpedia.org/ontology/wikiPageRedirects

More queries can show us what redirects to it. It turns out that it's just

http://dbpedia.org/resource/Template:Infobox_Artist

As it turns out, though, nothing is related to that either.

SELECT * WHERE { ?s ?p <http://dbpedia.org/resource/Template:Infobox_Artist> } limit 500

<a href="http://dbpedia.org/sparql?default-graph-uri=http://dbpedia.org&query=SELECT%20%2a%20WHERE%20%7B%0D%0A%20%20%20?s%20?p%20%3Chttp://dbpedia.org/resource/Template%3aInfobox_Artist%3E%0D%0A%7D%0D%0Alimit%20500&format=text/html&timeout=30000&debug=on" rel="nofollow">SPARQL results (0 results)</a>

It doesn't look like DBpedia is actually recording the information that you're looking for.

Recommend

  • Pyuno indexing issue that I would like an explanation for
  • Google Maps API draw a text from GeoJSON point geometry
  • Find lines in shape
  • How to reduce the time delay to reach run method of Runnable class using ExecutorService Java
  • QVideoWidget: Video is cut off
  • Java Netbeans Error Cannot find symbol, symbol: class out, location: class System, expected, illega
  • Use CASE statement with SUM function in SQL Server
  • what does the follow prolog codes do?
  • SQL Server Like Query not case sensitive
  • Does sql server minds the way records where inserted?
  • SQL append distinct values from two columns and two tables
  • How do you SELECT several columns with one distinct column
  • How to retrieve multiple columns from non-entity type sql query?
  • command line of process by name
  • SQL Server re-calculate or not?
  • Does the MySQL IN clause execute the subquery multiple times?
  • How to configure Cygnus in relation to Orion and Cosmos
  • In Java, how can I construct a File from a resource?
  • Which open source license has no forking [closed]
  • Salesforce Different WSDL files and when to use
  • Intel-64 and ia32 atomic operations acquire-release semantics and GCC 5+
  • JBoss External Properties Files in Classpath
  • Admob requires api-13 or later can I not deploy on old API-8 phones?
  • Launch Runnable Jar from Web Start
  • In LanguageTool, how do you create a dictionary and use it for spell checking?
  • ORA-29908: missing primary invocation for ancillary operator
  • Alternatives to the OPTIONAL fallback SPARQL pattern?
  • How to get next/previous record number?
  • Comma separated Values
  • A cron job substitute?
  • How do you join a server to an Active Directory (domain)?
  • How does Linux kernel interrupt the application?
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • Busy indicator not showing up in wpf window [duplicate]
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal