Jump to content

User:Swpb/query-generator

From Wikipedia, the free encyclopedia

Generates a query of Wikidata statements matching a qualifier use case. Part of the WikiProject Deprecate P642 migration process.

main property main value qualifier qualifier value

1 any
0 P

0 any
0 instance of:
1 subclass of:
0 instance or subclass of:
0 exactly:
Q or
Q or
Q
BUT NOT:
0 instance of:
1 subclass of:
0 instance or subclass of:
0 exactly:
Q or
Q or
Q

P642

0 any
1 instance of:
0 subclass of:
0 instance or subclass of:
0 exactly:
Q or
Q or
Q
BUT NOT:
1 instance of:
0 subclass of:
0 instance or subclass of:
0 exactly:
Q or
Q or
Q

0 automatically execute query (hover right edge for menu)

Query URL (updates automatically; paste into browser):
Warning: If main value is not "any", at least one item must be specified.

Warning: If qualifier value is not "any", at least one item must be specified.

https://query.wikidata.org/embed.html#%23%20Template%20query%20for%20P642%20use%20cases%20using%20any%20main%20property%0ASELECT%20DISTINCT%20%3Fstatement%20%3Fitem%20%3FitemLabel%20%3Fmain_property%20%3Fmain_propertyLabel%20%3Fstatement_value%20%3Fstatement_valueLabel%20%3Fqval%20%3FqvalLabel%20%28COUNT%20%28%3Fother_qual_prop%29%20as%20%3Fother_quals%29%20%28COUNT%20%28%3Fprovenance%29%20as%20%3Frefs%29%20where%20%7B%0A%0A%20%20%3Fitem%20%3Fpredicate_p%20%3Fstatement%20.%20%0A%20%20%3Fmain_property%20wikibase%3Aclaim%20%3Fpredicate_p%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20wikibase%3AstatementProperty%20%3Fpredicate_ps%20.%0A%20%20%3Fstatement%20%3Fpredicate_ps%20%3Fstatement_value%3B%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20pq%3AP642%20%3Fqval%20.%20%0A%23%20%20FILTER%20EXISTS%20%7B%3Fmain_property%20wdt%3AP31%20wd%3AQ55452870.%7D%20%20%20%20%20%20%20%20%23Use%20to%20narrow%20down%20main%20properties%3Fitem%20p%3AP%20%3Fstatement.%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23Replace%20P31%20here%20and%20on%20the%20next%20two%20lines%0A%20%20%3Fstatement%20ps%3AP%20%3Fstatement_value.%0A%20%20BIND%28wd%3AP%20AS%20%3Fmain_property%29%0A%20%20%3Fstatement%20pq%3AP642%20%3Fqval.%0A%20%20%0A%20%20%23Statement%20value%3A%0A%20%20%23BIND%20%28wd%3AQ%20AS%20%3Fstatement_value%29%20%20%20%20%20%20%20%23Main%20statement%20value%20is%20exactly%0A%20%20%23VALUES%20%3Fstatement_value_classes%20%7B%20wd%3AQ%20wd%3AQ%20wd%3AQ%20%7D%20%20%20%20%20%23Classes%20used%20to%20restrict%20the%20main%20statement%20value%0A%20%20%23%3Fstatement_value%20wdt%3AP31%2Fwdt%3AP31%3F%2Fwdt%3AP279%2A%20%3Fstatement_value_classes%20.%20%20%20%20%20%20%20%20%23The%20statement%20value%20is%20AN%20INSTANCE%20OF%20IDENTICAL%20TO%20OR%20A%20SUBCLASS%20OF%20IDENTICAL%20TO,%20A%20SUBCLASS%20OF,%20OR%20AN%20INSTANCE%20OF%20one%20of%20statement_value_classes.%0A%20%20VALUES%20%3Fstatement_value_except_classes%20%7B%20wd%3AQ%20wd%3AQ%20wd%3AQ%20%7D%0A%20%20MINUS%20%7B%20%3Fstatement_value%20wdt%3AP31%2Fwdt%3AP31%3F%2Fwdt%3AP279%2A%20%3Fstatement_value_except_classes.%20%7DFILTER%20%28%20%3Fstatement_value%20%21%3D%20%3Fstatement_value_except_classes%20%29%0A%20%20%0A%20%20%23Qualifier%20value%3A%0A%20%20#BIND%20%28wd%3AQ%20AS%20%3Fqval%29%20%20%20%20%20%20%20%23Qualifier%20value%20is%20exactly%0A%20%20%23VALUES%20%3Fqualifier_value_classes%20%7B%20wd%3AQ%20wd%3AQ%20wd%3AQ%20%7D%20%20%20%20%20%23Classes%20used%20to%20restrict%20the%20qualifier%20value%0A%20%20%23%3Fqval%20wdt%3AP31%2Fwdt%3AP31%3F%2Fwdt%3AP279%2A%20%3Fqualifier_value_classes%20.%20%20%20%20%20%20%20%20%23The%20qualifier%20value%20is%20AN%20INSTANCE%20OF%20IDENTICAL%20TO%20OR%20A%20SUBCLASS%20OF%20IDENTICAL%20TO,%20A%20SUBCLASS%20OF,%20OR%20AN%20INSTANCE%20OF%20one%20of%20qualifier_value_classes.%0A%20%20VALUES%20%3Fqualifier_value_except_classes%20%7B%20wd%3AQ%20wd%3AQ%20wd%3AQ%20%7D%0A%20%20MINUS%20%7B%20%3Fqval%20wdt%3AP31%2Fwdt%3AP31%3F%2Fwdt%3AP279%2A%20%3Fqualifier_value_except_classes.%20%7DFILTER%20%28%20%3Fqval%20%21%3D%20%3Fqualifier_value_except_classes%20%29%0A%0A%20%20OPTIONAL%20%7B%20%20%20%23Used%20to%20count%20any%20other%20qualifiers%20on%20the%20statement%2C%20which%20could%20complicate%20migrating%20to%20a%20new%20main%20statement%0A%20%20%20%20%3Fother_qual_prop%20wikibase%3Aqualifier%20%3Fother_predicate_pq.%0A%20%20%20%20%3Fstatement%20%3Fother_predicate_pq%20%3Fother_qval.%0A%20%20%20%20FILTER%20%28%3Fother_qual_prop%20%21%3D%20wd%3AP642%29%20%20%0A%20%20%7D%0A%20%20OPTIONAL%20%7B%20%3Fstatement%20prov%3AwasDerivedFrom%20%3Fprovenance.%20%7D%0A%20%20%20%20%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%20%7D%20%0A%7D%0AGROUP%20BY%20%3Fstatement%20%3Fitem%20%3FitemLabel%20%3Fmain_property%20%3Fmain_propertyLabel%20%3Fstatement_value%20%3Fstatement_valueLabel%20%3Fqval%20%3FqvalLabel%0AORDER%20BY%20%3Fmain_propertyLabel%20%3Fstatement_valueLabel%0A

If queries time out, try:

[edit]
  1. Replacing items/properties with one of their subclasses/sub-properties, or eliminating large subclasses from the query with the MINUS keyword (using "BUT NOT" above);
  2. Querying one level of subclass at a time, by replacing wdt:P279* with zero or more copies of wdt:P279 with / between; or
  3. Commenting out the statement value or qualifier value sections entirely (results may include statements outside the use case)