Wikidata:WikiProject Duplicates/Queries

From Wikidata
Jump to navigation Jump to search

People[edit]

# duplicates between existing Russian Wikipedia articles and items created from FAST
SELECT DISTINCT ?item1 ?label_en ?birthyear ?deathyear ?item2 ?label_ru
WITH
{
  SELECT ?item1 ?FAST_ID ?label_en
  WHERE
  {
    #VALUES ?item1 { wd:??? } .
    ?item1 p:P214 [ps:P214 ?viaf ; prov:wasDerivedFrom [pr:P248 wd:Q3294867] ] .
    ?item1 rdfs:label ?label_en .
    FILTER(LANG(?label_en) = "en")
    FILTER(CONTAINS(?label_en,"vich"))
  }
  #LIMIT 20
} AS %get_humans_with_FAST_ID
WHERE
{
  INCLUDE %get_humans_with_FAST_ID
  ?item1 wdt:P569 ?birth.
  ?item2 wdt:P569 ?birth.
  BIND(str(YEAR(?birth)) AS ?birthyear)
  ?item1 wdt:P570 ?death.
  ?item2 wdt:P570 ?death.
  BIND(str(YEAR(?death)) AS ?deathyear)
  FILTER (?item1 != ?item2)
  ?item2 wdt:P31 wd:Q5.
  ?ruwiki_sitelink schema:about ?item2 .
  ?ruwiki_sitelink schema:isPartOf <https://ru.wikipedia.org/>.
  { ?item2 wdt:P27 wd:Q159. } UNION { ?item2 wdt:P27 wd:Q15180 . } UNION { ?item2 wdt:P27 wd:Q34266 . }
  ?item2 rdfs:label ?label_ru.
  FILTER (LANG(?label_ru) = "ru")
}
ORDER BY ?label_en ?label_ru
Try it!
#pairs of persons that have the same date of birth AND share a place of birth (Brazil) with population lower than a certain threshold 
SELECT ?person1 ?person1Label ?person2 ?person2Label ?date_of_birth ?place_of_birth WHERE {
  ?place_of_birth wdt:P17 wd:Q155; #in Brazil
    wdt:P1082 ?population.
  FILTER(?population < 100000 ) # for places with huge population, use additional constraints for person1/person2 pair
  ?person1 wdt:P31 wd:Q5; #human
    wdt:P19 ?place_of_birth;
    wdt:P569 ?date_of_birth.
  ?person2 wdt:P31 wd:Q5; #human, empty P31 is also useful here
    wdt:P19 ?place_of_birth;
    wdt:P569 ?date_of_birth.
  FILTER(!(((DAY(?date_of_birth)) = 1 ) && ((MONTH(?date_of_birth)) = 1 ))) # I usually exclude January 1, too many false positives even with 1 day precision
  FILTER( ?person1 != ?person2)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "pt,es,[AUTO_LANGUAGE]". }
  }
  ORDER BY DESC(?date_of_birth)
Try it!