0

I am trying to retrieve the titles and release dates (publication date) for movies using the wikidata.org sparkql endpoint (https://query.wikidata.org/). The titles are listed in different languages, which are filtered in the query below. However, some movies also have several publication dates (e.g. for different countries), e.g. https://www.wikidata.org/wiki/Q217020. I'm not sure how the RDF triple structure is actually used to assign a country to the value of another triple, but specifically, how can I only retrieve the publication date for a movie in the US?

SELECT ?item ?title ?publicationdate
WHERE { 
    ?item wdt:P31 wd:Q11424 ;
        rdfs:label ?title ;
        wdt:P577 ?publicationdate ;
    filter ( lang(?title) = "en" )
}
ORDER BY ?movieid
LIMIT 10

Solution

The solution provided by M.Sarmini works. Apparently, facts such as publication data are stored as n-ary relations, they create a unique symbolic tag that links the resources. The value that P577 links to is just the date, when turned into a string will give the release date, while in reality it is a token that you can link to other qualifiers.

logi-kal
  • 7,107
  • 6
  • 31
  • 43
Jeroen Vuurens
  • 1,171
  • 1
  • 9
  • 10

1 Answers1

1

Just add a new variable to hold the place of publication and filter your results to just list US films like this:

PREFIX q: <http://www.wikidata.org/prop/qualifier/>
PREFIX s: <http://www.wikidata.org/prop/statement/>

SELECT distinct ?item  ?title ?publicationdate
WHERE { 
  ?item wdt:P31 wd:Q11424;
        rdfs:label ?title;             
        p:P577 ?placeofpublication.
  ?placeofpublication q:P291 wd:Q30.   
  ?placeofpublication s:P577 ?publicationdate;

  filter ( lang(?title) = "en")
}  
ORDER BY ?item
M.Sarmini
  • 70
  • 3
  • Thanks for the answer. It seems that there is only a single movie that satisfies this criterium on https://query.wikidata.org/ . Semantically, I don't see how this actually connects the place of publication to the date of publication. – Jeroen Vuurens Nov 29 '16 at 12:34
  • @JeroenVuurens You are welcome. I edited the query to match your conditions. Give it a try. – M.Sarmini Nov 30 '16 at 08:52
  • 1
    You can read the slides here [link](http://www.slideshare.net/_Emw/an-ambitious-wikidata-tutorial) to have a brief summary about the elements of the wikidata statement and the relations between them. – M.Sarmini Nov 30 '16 at 08:57
  • Thank you very much! So apparently, the ternary relations are bound by a unique placeofpublication. Also thanks for the link, it appears wikidata.org is an awesome resource, thanks to the endpoint and being able to navigate their data on the site. – Jeroen Vuurens Nov 30 '16 at 09:10