sparql query to get all versions of python - sparql

I tried to get all versions released of python from wiki but I'm getting confused with the notation of instance and property.
How can I get it to work?
# get all version release for python
select ?version ?versionLabel
where
{
wdt:P5568 wd:Q3331189 ?version;
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
also tried:
# get all version release for python
select ?version ?versionLabel ?app ?appLabel
where
{
?app wdt:P5568 wd:Q3331189;
wdt:P348 ?version;
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}

Related

How to create a SPARQL query to search Wikidata item descriptions

I'd like to be able to find an item based on words in its descriptions.
This is what I'm trying to do, but clearly I don't know what I'm doing. Any help is appreciated.
SELECT ?item ?itemLabel WHERE {
?item schema:description ?desc.
FILTER(CONTAINS(LCASE(?desc), "space telescope"))
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
LIMIT 10
Solved by UninformedUser in the comments!
WHERE { hint:Query hint:optimizer "None".
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:api "Search";
wikibase:endpoint "www.wikidata.org";
mwapi:srsearch "space telescope".
?item wikibase:apiOutputItem mwapi:title . }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
limit 10

Getting labels/names and invert wikidata query

I'am trying to get the names of the victims, which got a "stolperstein" (stumblestone) in my hometown. But I can't get the names with SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
I think, the query should be
SELECT ?Stolperstein ?StolpersteinLabel ?bild ?Person ?tod WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?Stolperstein wdt:P31 wd:Q26703203;
wdt:P131 wd:Q2107;
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
wdt:P547 ?Person.
But it doesn't work. What am I doing wrong?
My second question is, how can I display the data with missing information. (invert the query / like NOT IN)
SELECT ?Stolperstein ?StolpersteinLabel ?bild ?Person ?tod WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?Stolperstein wdt:P31 wd:Q26703203;
wdt:P131 wd:Q2107;
wdt:P547 ?Person.
?Person wdt:P570 ?tod
gives me only 88 results, but there are 188 "stones", so therefore in 100 datasets is the information date of death (P570) missing.

WIKIDATA/SPARQL: How to get the used language when using SERVICE wikibase:label with [AUTO_LANGUAGE] parameter

About everything in the title : When I use
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } I may get some results with the detected [AUTO_LANGUAGE] and others in 'en'.
Is it possible to get the used language for each of the lines of the result ?
Yes. LANG(?var) does that:
SELECT ?item ?itemLabel (LANG(?itemLabel) as ?langLabel)
WHERE {
?item wdt:P31 wd:Q146.
SERVICE wikibase:label {
bd:serviceParam wikibase:language "de,fr,en".
}
}

Find which direct property applied in a SPARQL query

I have a list of properties I want to apply to a specific entity mathematics: wd:Q395. In this case:
instanceOf: 'wdt:P31'
subclassOf: 'wdt:P279'
The results are:
Mathematics is instance of academic discipline and
Mathematics is subclass of exact science and formal science
Instead of making two different queries I would like to make them all at once:
SELECT ?field ?fieldLabel ?propertyApplied
WHERE {
wd:Q395 wdt:P31 | wdt:P279 ?field.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
BIND("" AS ?propertyApplied)
}
How can I know which property applied to fill the right column? ( for example next to academic discipline I would like that it appears instance of)
I tried this but it looks weird and the results repeat themselves.
SELECT ?instanceOf ?subclassOf ?instanceOfLabel ?subclassOfLabel
WHERE {
OPTIONAL { wd:Q395 wdt:P31 ?instanceOf. }
OPTIONAL { wd:Q395 wdt:P279 ?subclassOf. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Use VALUES or UNION:
SELECT ?field ?fieldLabel ?propertyLabel WHERE {
VALUES (?predicate) {(wdt:P31) (wdt:P279)}
wd:Q395 ?predicate ?field .
?property wikibase:directClaim ?predicate .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it!
SELECT ?field ?fieldLabel ?propertyLabel {
{ wd:Q395 wdt:P31 ?field . BIND (wd:P31 AS ?property) }
UNION
{ wd:Q395 wdt:P279 ?field . BIND (wd:P279 AS ?property) }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it!

Wikidata: list every physical objects

I'm trying to get the name of the all physical things (tangible concepts) Wikidata knows about (objects, places, countries, etc), or in other words everything non-abstract.
There are examples close to what I need, but with only a depth of one: all the things that are instances of phone.
I found this example that searches with more depth and I modified the start point to entity:
#Children of Genghis Khan
#added before 2016-10
#defaultView:Graph
PREFIX gas: <http://www.bigdata.com/rdf/gas#>
SELECT ?item ?itemLabel ?pic ?linkTo
WHERE
{
SERVICE gas:service {
gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.SSSP" ;
gas:in wd:Q35120 ;
gas:traversalDirection "Forward" ;
gas:out ?item ;
gas:out1 ?depth ;
gas:maxIterations 4 ;
gas:linkType wdt:279 .
}
OPTIONAL { ?item wdt:P40 ?linkTo }
OPTIONAL { ?item wdt:P18 ?pic }
SERVICE wikibase:label {bd:serviceParam wikibase:language "en" }
}
I still get no results.
As mentionned in a comment, your question is too broad and you'll end up with too much answers
You look for the A that are instance of a subclass of B
so the query you point to is the right one
SELECT DISTINCT ?item
WHERE {
?item wdt:P31/wdt:P279* wd:Q35120
}
the problem is the size
wd:Q35120 has a lot of subclasses
You can check that this way
SELECT ?a ?aLabel WHERE { ?a wdt:P279 wd:Q35120.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
SELECT ?a ?aLabel WHERE { ?a wdt:P279/wdt:P279? wd:Q35120.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
SELECT ?a ?aLabel WHERE { ?a wdt:P279/wdt:P279?/wdt:P279? wd:Q35120.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
And so on : you'll see that there are already 40'000+ at forth level which is huge
You could also huge this nice tool to have a more precise view
https://tools.wmflabs.org/bambots/WikidataClasses.php?id=Q35120&lang=en