Search code examples
sparqlrdfwikipediadbpediadisambiguation

How to catch correct resource among disambiguations / interrogate subresources in DBPedia using SPARQL?


I have the title of a Youtube music video and I need to gather additional information from DBPedia like album, artist, release date, etc. I'd also like to get the 'abstract' of all these entities from DBPedia. I already use Musicbrainz to differentiate between song and artist in the title and it works rather well, except a few cases.

However my main problem is: when I pass the song to ask DBPedia (using a query with resource/{song}), sometimes I get no answer because {song} causes disambiguation. Example: resource/It's_My_Life has 11 disambiguates, 6 of which are songs. I need the resource "It's_My_Life_(Bon_Jovi_song)". How can I tell DBPedia that I need a resource of 'MusicalWork' type of a certain artist?

I tried in many ways to do this with SPARQL, but I always get an empty result and I don't know what I'm doing wrong. So far I was able to only get the abstract of every disambiguation, but I cannot get a specific property (like abstract) of a subresource of a disambiguation.

SELECT ?x ?y WHERE {
    <http://dbpedia.org/resource/It's_My_Life>  dbo:wikiPageDisambiguates ?x .
    ?x dbo:abstract ?y .
}

I can't seem to go father than this. I tried with:

SELECT ?x ?y WHERE {
    <http://dbpedia.org/resource/It's_My_Life>  dbo:wikiPageDisambiguates ?x .
    ?x dbo:MusicalArtist ?y .
    { SELECT ?z WHERE { 
        ?y dbo:abstract ?z}
    }
}

and

SELECT ?x ?y WHERE {
    <http://dbpedia.org/resource/It's_My_Life>  dbo:wikiPageDisambiguates ?x
    ?x rdfs:type ?y .
}

But results are always empty. How am I supposed to interrogate a subresource of a resource? Can anyone help me?


Solution

  • Solution, pulled from comments by @AKSW --

    SELECT ?x ?y 
    WHERE
      { 
        <http://dbpedia.org/resource/It's_My_Life>  dbo:wikiPageDisambiguates  ?x              . 
        ?x                                          rdf:type                   dbo:MusicalWork . 
        ?x                                          dbo:abstract               ?y              . 
        FILTER ( LANGMATCHES ( LANG (?y), 'en' ) ) 
      }