User:Ivanhercaz/queries

Useful queries for Wikidata Query Service.

Cultural heritage edit

Fortifications in the Canary Islands edit

# Fortifications in the Canary Islands

SELECT ?item ?itemLabel ?fortificationLabel ?locationLabel ?provinceLabel WHERE {
  ?location wdt:P31 wd:Q2074737 .
  ?location wdt:P131 ?province .
  
  ?fortification wdt:P31*/wdt:P279* wd:Q57821 .
            
  ?item wdt:P31 ?fortification .
  ?item wdt:P131 ?location .
  
  VALUES ?province { wd:Q95080 wd:Q99976 }
    
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es" }  
}
Try it!

Geography edit

Countries of America edit

# Países de América
# Countries of America

PREFIX schema: <http://schema.org/>

SELECT ?item ?itemLabel ?linkcount WHERE {
  ?item wdt:P31 wd:Q6256 .
  ?item wdt:P30 ?continente .
  
  VALUES ?continente {wd:Q49 wd:Q27611 wd:Q18}
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es, fr" }  
}
Try it!

Literature edit

Writers from the Canary Islands edit

Note. It just includes authors with occupation (P106)writer (Q36180), but playwright (Q214917), novelist (Q6625963) and poet (Q49757), among others, should also be included in the results. I will work on these query in a near-future to make it more reliable to the true of the data about writers from the Canary Islands available on Wikidata.

# Writers from the Canary Islands
# Escritoras y escritores de Canarias
SELECT DISTINCT ?autor ?autor_etiqueta ?eswiki_titulo ?eswiki_url WHERE {
  {
    ?autor (wdt:P19/(wdt:P131*)) ?provincia.
    VALUES ?provincia {
      wd:Q95080
      wd:Q99976
    }
  }
  UNION
  { ?autor wdt:P19 wd:Q5813. }
  ?autor (wdt:P106/(wdt:P279*)) wd:Q36180;
    rdfs:label ?autor_etiqueta.
  FILTER((LANG(?autor_etiqueta)) = "es")
  OPTIONAL {
    ?eswiki_url schema:about ?autor;
      schema:isPartOf <https://es.wikipedia.org/>;
      schema:name ?eswiki_titulo.
  }
}
ORDER BY DESC (?autor_etiqueta)
Try it!

Characters from the Foundation Universe by Isaac Asimov edit

# Personajes del Universo de la Fundación de Isaac Asimov con etiquetas
# y descripciones en inglés y en español (opcional)
# Characters from the Foundation Universe by Isaac Asimov with labels
# and descriptions in English and in Spanish (opcional)

SELECT ?item ?itemLabelEn ?itemDescEn ?itemLabelEs ?itemDescEs WHERE {
  ?item wdt:P31 wd:Q3658341 .
  ?item wdt:P1080 wd:Q3551232 .
  
  ?item rdfs:label ?itemLabelEn filter (lang(?itemLabelEn) = "en").
  ?item schema:description ?itemDescEn filter(lang(?itemDescEn) = "en").

  OPTIONAL {
    ?item rdfs:label ?itemLabelEs filter (lang(?itemLabelEs) = "es").
  }
  OPTIONAL {
    ?item schema:description ?itemDescEs filter (lang(?itemDescEs) = "es").
  }
}
Try it!

Libraries edit

Map of libraries from Spain edit

#defaultView:Map
SELECT DISTINCT ?biblioteca ?bibliotecaLabel ?coordenadas WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?biblioteca (wdt:P31/(wdt:P279*)) wd:Q7075;
    wdt:P17 wd:Q29;
  
  OPTIONAL { ?biblioteca wdt:P625 ?coordenadas. }
}
Try it!

Map of libraries from the Canary Islands edit

#defaultView:Map
SELECT DISTINCT ?biblioteca ?bibliotecaLabel ?coordenadas WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?biblioteca (wdt:P31/(wdt:P279*)) wd:Q7075;
    wdt:P17 wd:Q29;
    wdt:P131 ?municipio.
  
  ?municipio wdt:P131* wd:Q5813
  OPTIONAL { ?biblioteca wdt:P625 ?coordenadas. }
}
Try it!

Map of municipal public libraries of Las Palmas de Gran Canaria edit

#defaultView:Map
# Bibliotecas municipales de Las Palmas de Gran Canaria.
# Esta consulta depende de un filtrado por expresión regular de la etiqueta (rdfs:label)

SELECT DISTINCT ?biblioteca ?bibliotecaLabel ?coordenadas WHERE {
  ?biblioteca (wdt:P31/(wdt:P279*)) wd:Q7075;
    wdt:P17 wd:Q29;
    wdt:P131 wd:Q11974;
    rdfs:label ?bibliotecaName.
  
  # Coordenadas
  OPTIONAL { ?biblioteca wdt:P625 ?coordenadas. }
  
  # Filtrado
  FILTER (regex(?bibliotecaName, 'Biblioteca Pública Municipal.*'))
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}
Try it!

Sports edit

Sportswomen with pages in Spanish but not in French edit

# Deportistas con artículos en español pero no en francés
# Sportswomen with pages in Spanish but not in French

PREFIX schema: <http://schema.org/>

SELECT ?item ?itemLabel ?linkcount WHERE {
    ?item wdt:P31 wd:Q5 .
    ?item wdt:P21 wd:Q6581072 .
    ?item wdt:P106 wd:Q2066131 .
    ?item wikibase:sitelinks ?linkcount .
    ?article_ schema:about ?item .
    ?article_ schema:inLanguage "es" .
    ?article_ schema:isPartOf <https://es.wikipedia.org/> 
  FILTER (?linkcount >= 1) .
  FILTER NOT EXISTS {
    ?article schema:about ?item .
    ?article schema:inLanguage "fr" .
    ?article schema:isPartOf <https://fr.wikipedia.org/> 
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es, fr" }
}
GROUP BY ?item ?itemLabel ?linkcount
ORDER BY DESC(?linkcount)
Try it!

Spanish sportswomen with pages in Spanish but not in French edit

# Deportistas españolas con artículos en español pero no en francés
# Spanish sportswomen with pages in Spanish but not in French

PREFIX schema: <http://schema.org/>

SELECT ?item ?itemLabel ?linkcount WHERE {
    ?item wdt:P31 wd:Q5 .
    ?item wdt:P21 wd:Q6581072 .
    ?item wdt:P27 wd:Q29 .
    ?item wdt:P106 wd:Q2066131 .
    ?item wikibase:sitelinks ?linkcount .
    ?article_ schema:about ?item .
    ?article_ schema:inLanguage "es" .
    ?article_ schema:isPartOf <https://es.wikipedia.org/> .
    
  FILTER (?linkcount >= 1) .
  FILTER NOT EXISTS {
    ?article schema:about ?item .
    ?article schema:inLanguage "fr" .
    ?article schema:isPartOf <https://fr.wikipedia.org/> 
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es, fr" }
}
GROUP BY ?item ?itemLabel ?linkcount
ORDER BY ASC(?linkcount)
Try it!

Hispanic American sportswomen with pages in Spanish but not in French edit

# Deportistas hispanoamericanas con artículos en español pero no en francés
# Hispanic American sportswomen with pages in Spanish but not in French

PREFIX schema: <http://schema.org/>

SELECT ?item ?itemLabel ?countryLabel ?linkcount WHERE {
    ?item wdt:P31 wd:Q5 .
    ?item wdt:P21 wd:Q6581072 .
    ?item wdt:P27 ?nacionalidad .
    ?item wdt:P106 wd:Q2066131 .
    ?item wikibase:sitelinks ?linkcount .
    ?article_ schema:about ?item .
    ?article_ schema:inLanguage "es" .
    ?article_ schema:isPartOf <https://es.wikipedia.org/> .
  VALUES ?country {wd:Q77 wd:Q96 wd:Q155 wd:Q717 wd:Q733 wd:Q736
                        wd:Q739 wd:Q241 wd:Q298 wd:Q414 wd:Q419 wd:Q750
                        wd:Q774 wd:Q783 wd:Q786 wd:Q790 wd:Q792 wd:Q800
                        wd:Q804 wd:Q811}
    
  FILTER (?linkcount >= 1) .
  FILTER NOT EXISTS {
    ?article schema:about ?item .
    ?article schema:inLanguage "fr" .
    ?article schema:isPartOf <https://fr.wikipedia.org/> 
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es, fr" }
}
GROUP BY ?item ?itemLabel ?countryLabel ?linkcount
ORDER BY DESC(?countryLabel)
Try it!

Wikidata edit

Books without Spanish description edit

# Chapters without Spanish description
# Capítulos sin descripción en español

PREFIX schema: <http://schema.org/>

SELECT ?item ?itemLabel ?desc WHERE {
  ?item wdt:P31 wd:Q1980247 .
  
  FILTER NOT EXISTS { ?item schema:description ?desc filter (lang(?namePropertyES) = "es") . }
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

LIMIT 2000
Try it!

Properties without label in Spanish edit

# Properties without label in Spanish

SELECT ?property ?propertyLabel ?propertyDescription
WHERE
{
    ?property rdf:type wikibase:Property .
    FILTER NOT EXISTS { ?property rdfs:label ?namePropertyES filter (lang(?namePropertyES) = "es")}
  
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }	
}

ORDER BY ?property
Try it!

Properties without description in Spanish edit

# Properties without description in Spanish

SELECT ?property ?propertyLabel ?propertyDescription
WHERE
{
    ?property rdf:type wikibase:Property .
    FILTER NOT EXISTS { ?property schema:description ?namePropertyES filter (lang(?namePropertyES) = "es")}
  
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }	
}

ORDER BY ?property
Try it!

Scientific journals without label in Spanish edit

# Revistas científicas con etiqueta en inglés pero no en español
# Scientific journals with label in English but not in Spanish

PREFIX schema: <http://schema.org/>

SELECT ?item ?LabelEN ?LabelES WHERE {
  ?item wdt:P31 wd:Q5633421.
  
  ?item rdfs:label ?LabelEN filter (lang(?LabelEN) = "en").
    
  FILTER NOT EXISTS {
    ?item rdfs:label ?LabelES filter (lang(?LabelES) = "es").
  }
}
Try it!

Scientific journals without description in Spanish edit

# Revistas científicas sin descripción en español
# Scientific journals without description in Spanish

PREFIX schema: <http://schema.org/>

SELECT ?item ?itemDescEs WHERE {
  ?item wdt:P31 wd:Q5633421.
    
  FILTER NOT EXISTS {
    ?item rdfs:label ?itemDescEs filter (lang(?itemDescEs) = "es").
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en", "es" }
}
Try it!

Scientific articles without label in Spanish edit

# Artículos científicos con etiqueta en inglés pero no en español
# Scientific articles with label in English but not in Spanish

PREFIX schema: <http://schema.org/>

SELECT ?item ?LabelEN ?LabelES WHERE {
  ?item wdt:P31 wd:Q13442814.
  
  ?item rdfs:label ?LabelEN filter (lang(?LabelEN) = "en").
    
  FILTER NOT EXISTS {
    ?item rdfs:label ?LabelES filter (lang(?LabelES) = "es").
  }

}

# The limit is necessary to not get a time out
LIMIT 200000
Try it!