User:Metamorforme42/Ambassadors
Jump to navigation
Jump to search
#display instance of class of ambassadors to/of a country |
---|
#display instance of class of ambassadors to/of a country
SELECT DISTINCT ?item ?itemLabel ?subclass ?subclassLabel
WHERE
{
{?item wdt:P279 wd:Q29645880.} union {?item wdt:P279 wd:Q29645886}
?item wdt:P279 ?subclass.
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" }
}
|
#display instance of ambassadors to/of a country |
---|
#display instance of ambassadors to/of a country
SELECT DISTINCT ?item2 ?item2Label
WHERE
{
{?item wdt:P279 wd:Q29645880.} union {?item wdt:P279 wd:Q29645886}
?item2 wdt:P31 ?item.
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr, en" }
}
|
#display instance of ambassadors with countries |
---|
#display instance of ambassadors with countries
SELECT DISTINCT ?item2 ?item2Label ?p1Label ?p2Label
WHERE
{
?item wdt:P279 wd:Q29645880.
?item_b wdt:P279 wd:Q29645886.
?item2 wdt:P31 ?item.
?item2 wdt:P31 ?item_b.
?item wdt:P17 ?p1.
?item_b wdt:P17 ?p2.
filter (?p1 != ?p2)
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr, en" }
}
|
Maintenance
[edit]#potentials category without subject but maybe should be some ambassador position |
---|
#potentials category without subject but maybe should be some ambassador position
SELECT DISTINCT ?item ?itemLabel WHERE {
?item wdt:P31 wd:Q4167836.
?item rdfs:label ?itemLabel .
FILTER(LANG(?itemLabel) = "en").
FILTER(STRSTARTS(?itemLabel, "Category:Ambassadors")).
FILTER NOT EXISTS{?item wdt:P301 ?_}
}
LIMIT 20 # too long and fail otherwise
|
#duplicated instances of ambassadors to/of a country |
---|
#duplicated instances of ambassadors to/of a country
SELECT DISTINCT ?item ?itemLabel ?item1 ?item1Label ?item2 ?item2Label
WHERE
{
{?item1 wdt:P279 wd:Q29645880.?item2 wdt:P279 wd:Q29645886}.
FILTER (?item1 != ?item2).
?item wdt:P31 ?item1.
?item wdt:P31 ?item2.
?item_bis wdt:P31 ?item1.
?item_bis wdt:P31 ?item2.
FILTER (?item != ?item_bis).
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr, en" }
}
|
#item with (ambassador of x) or (ambassador of y) as P279 (probably instead of P31) |
---|
#item with (ambassador of x) or (ambassador of y) as P279
#(probably instead of P31)
SELECT distinct ?item ?itemLabel ?class ?classLabel where{
{?class wdt:wdt:P31 wd:Q29918328 .} union {?class wdt:P31 wd:Q29918335}
?item wdt:P279 ?class.
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en" }
FILTER NOT EXISTS { # know exceptions
{?item wdt:P279 wd:Q30064715 }
union
{?item wdt:P279 wd:Q110620461 }
}
}
|
#display instance of ambassadors (to XOR of) a country |
---|
#display instance of ambassadors (to XOR of) a country
SELECT DISTINCT ?item ?itemLabel ?classLabel ?metaclassLabel
WHERE
{
{?item wdt:P31/wdt:P279* wd:Q29645880 .} union {?item wdt:P31/wdt:P279* wd:Q29645886}
OPTIONAL {?item wdt:P31 ?class.}
OPTIONAL {?class wdt:P31 ?metaclass.}
FILTER NOT EXISTS {?item wdt:P31/wdt:P279* wd:Q29645880 .?item wdt:P31/wdt:P279* wd:Q29645886}.
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en" }
}
|
#categories missing for instance of class of ambassadors to/of a country |
---|
#categories missing for instance of class of ambassadors to/of a country
SELECT DISTINCT ?item ?itemLabel ?subclass ?subclassLabel ?cat ?catLabel
WHERE
{
{?item wdt:P279 wd:Q29645880.} union {?item wdt:P279 wd:Q29645886}
?item wdt:P279 ?subclass.
FILTER NOT EXISTS {?item wdt:P910 ?cat}
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr" }
}
|
#category with label starting with 'Category:Ambassadors' and with subject instance of list |
---|
#category with label starting with 'Category:Ambassadors' and with subject instance of list
SELECT DISTINCT ?item ?itemLabel WHERE {
?item wdt:P31 wd:Q4167836.
?item rdfs:label ?itemLabel1 .
?item wdt:P301 ?sub.
?sub wdt:P31 wd:Q13406463.
FILTER(STRSTARTS(?itemLabel1, "Category:Ambassadors")).
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
|
#both ambassador and list instance (should be split) |
---|
#both ambassador and list instance (should be split)
SELECT DISTINCT ?item ?itemLabel WHERE {
?item wdt:P31/wdt:P279* wd:Q121998.
?item wdt:P31 wd:Q13406463.
?item rdfs:label ?itemLabel1.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
|
Automatic
[edit]#categories incomplete for instance of class of ambassadors to a country |
---|
#categories incomplete for instance of class of ambassadors to a country
SELECT DISTINCT ?item ?itemLabel ?cat ?catLabel
WHERE
{ ?cat wdt:P31 wd:Q4167836.
?item wdt:P910 ?cat.
?item wdt:P31/wdt:P279* wd:Q29645886.
FILTER NOT EXISTS {?cat wdt:P301 ?item_}.
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en" }
}
|
and use my python script with the tool `add_subject_to_categories()`.
Ambassador to a country creation helper
[edit]- complete a .csv with : country,category,enLabel,frLabel,enAlias,frAlias,modeCommand
- use my python script with `create_ambassadors_class(defaultmode=None)` (tip: you can set defaultmode to `to` or `of` and don’t fill modeCommand column).
→ Don't forget to run the automatic script for categories incomplete after.