Topic on User talk:Nono314

Jump to navigation Jump to search
Multichill (talkcontribs)
Nono314 (talkcontribs)

Hi Multichill,

I was not aware of that template. Might be useful indeed, though there are not so many and they do not all follow that pattern. The main source lies in commons (~9K harvested today).

By the way, do you have a plan for the SOAP lists that used to display described at URL (P973) values, most of which have been migrated to specific properties lately? It's of course possible to build urls from ids, but inserting them into all those existing queries is not so straightforward.

Multichill (talkcontribs)

For per collection identifiers I just updated the query, see for example [[Wikidata:WikiProject sum of all paintings/Collection/Yale Center for British Art]. Using more than one of these identifier properties is harder.

On Wikidata:WikiProject sum of all paintings/Image suggestions/Creator, institution and inventory number match the links started disappearing so I updated my bot with a new query. You can do something like this:

SELECT ?item ?url WHERE {
        ?item wdt:P31/wdt:P279* wd:Q3305213 .
        OPTIONAL { ?item wdt:P973 ?url } .
        OPTIONAL { ?item ?identifierproperty ?identifier .
                   ?property wikibase:directClaim ?identifierproperty .
                   ?property wikibase:propertyType wikibase:ExternalId .
                   ?property wdt:P1630 ?formatterurl .
                   BIND(IRI(REPLACE(?identifier, '^(.+)$', ?formatterurl)) AS ?url).
                    } 
} LIMIT 100

Try it!

Nono314 (talkcontribs)

Yes that's what I was referring to. It also needs grouping on item to avoid duplicate lines. This makes it quite difficult to update existing lists on a large scale and risks scaring off people without a strong sparql background, while the existing ones where pretty easy to adapt for new catalogs/creators.

The best I had been able to come up with is something like

SELECT * 
WITH {
  SELECT ?item ?catcode WHERE { ?item p:P528 [ pq:P972 wd:Q15088284; ps:P528 ?catcode].  }
} AS %original_query
WITH {
  select ?p ?formatter {
    ?prop wdt:P31/wdt:P279* wd:Q44847669 .
    ?prop wdt:P1630 ?formatter .
    ?prop wikibase:directClaim ?p .
  }
} as %artwork_properties
{
  INCLUDE %original_query
  OPTIONAL { #build up url list
    SELECT ?item (GROUP_CONCAT(?url;SEPARATOR="<br/>") as ?urls) {
      { SELECT ?item ?url WHERE {
        INCLUDE %artwork_properties
        ?item ?p ?value .
        BIND( REPLACE(str(?formatter),"\\$1",?value) as ?url) .
      } } UNION { ?item wdt:P973 ?url }
    } GROUP BY ?item
  }
} ORDER BY xsd:integer(?catcode)

Try it! trying to keep the useful part visible at the top, but this still looks so convoluted.

Reply to "Google Cultural institute links"