{"id":643,"date":"2020-05-22T18:00:08","date_gmt":"2020-05-22T17:00:08","guid":{"rendered":"http:\/\/blog.magnusmanske.de\/?p=643"},"modified":"2020-05-22T18:00:08","modified_gmt":"2020-05-22T17:00:08","slug":"the-depicts","status":"publish","type":"post","link":"http:\/\/magnusmanske.de\/wordpress\/archives\/643","title":{"rendered":"The Depicts"},"content":{"rendered":"<p>So Structured Data on Commons (SDC) has been going for a while. Time to reap some benefits!<\/p>\n<p>Besides free-text image descriptions, the first, and likely most used, element one can add to a picture via SDC is &#8220;depicts&#8221;. This can be one or several Wikidata items which are visible (prominently or as background) on the image. Many people have done so, manually or via JavaScript- or Toolforge-based mass editing tools.<\/p>\n<p>This is all well and good, but what to do with that data? It can be searched for, if you know the magic incantation for the search engine, but that&#8217;s pretty much it for now. A SPARQL query engine would be insanely useful for more complex queries, especially if it would work seamlessly with the Wikidata one, but no usable, up-to-date one is in sight so far.<\/p>\n<p>Inspired by a <a href=\"https:\/\/twitter.com\/hayify\/status\/1263415151388172288\">tweet by Hay<\/a>, and with some help from Maarten Dammers, I found a way to use SDC &#8220;depicts&#8221; information in my <strong><a href=\"https:\/\/tools.wmflabs.org\/fist\/file_candidates\/#\/candidates\/?group=COMMONS_DEPICTS\">File Candidates tool<\/a><\/strong>. It suggests files that might be useful to add to specific Wikidata items.<\/p>\n<p>Now, since proper SDC support is &#8230; let&#8217;s say incomplete at the moment, I had to go a bit off beaten path. First, I use the &#8220;random&#8221; sort in the Commons API search for files with a &#8220;depicts&#8221; statement. That way, I get 50 such files with one query. Then, I use the wikibase API on Commons to get the structured data for these files. The structured data contains the information which Wikidata item(s) each file depicts.<\/p>\n<p>Armed with these Wikidata item IDs, I use the database replicas on Toolforge to retrieve the subset of items that (a) have no image (P18), (b) have P31 &#8220;instance of&#8221;, (c) have no P279 &#8220;subclass of&#8221;, and (d) do not link to any of a number of &#8220;unsuitable&#8221; items (eg. templates or given names). For that subset, I get the files the items use, eg as a logo image (to not suggest their usage with the item), and then I add an entry to the database that says &#8220;this item might use this image&#8221;, according to the depicts statements in the respective image (Code is <a href=\"https:\/\/bitbucket.org\/magnusmanske\/fist\/src\/master\/scripts\/file_candidates\/commons_random_depicts.php\">here<\/a>, in case you are interested).<\/p>\n<p>50 files (a restriction imposed by the Commons API) are not much, especially since many images with depicts statements probably are used as an image on the respective Wikidata item. So I do keep running such random requests in the background and collect them for the File Candidates tool. At the time of writing, over 12k such candidates exist.<\/p>\n<p>Happy image matching, and don&#8217;t forget to check out the other candidate image groups in the tool (including potentially useful free images from Flickr!).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So Structured Data on Commons (SDC) has been going for a while. Time to reap some benefits! Besides free-text image descriptions, the first, and likely most used, element one can add to a picture via SDC is &#8220;depicts&#8221;. This can be one or several Wikidata items which are visible (prominently or as background) on the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-643","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/posts\/643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/comments?post=643"}],"version-history":[{"count":1,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/posts\/643\/revisions"}],"predecessor-version":[{"id":645,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/posts\/643\/revisions\/645"}],"wp:attachment":[{"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/media?parent=643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/categories?post=643"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/tags?post=643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}