User:Infovarius/Queries
Interesting[edit]
(71,611,020) |
---|
|
Grammatical[edit]
- Падежи (tinyurl.com/zl6lvvb)
- Наклонения (tinyurl.com/jc3xyfp)
- Времена (tinyurl.com/llgonpd)
Фильмы-мультфильмы по годам-языкам[edit]
- Распределение всех фильмов по годам histogram:
#фильмы по годам
SELECT ?year (count(?item) as ?cnt) WHERE{
?item wdt:P31/wdt:P279* wd:Q11424 .
?item wdt:P577 ?publicationdate .
BIND(str(year(?publicationdate)) as ?year)
FILTER(bound(?year))
} GROUP BY ?year ORDER BY ?year
#Мультфильмы СССР по годам
SELECT ?year (count(?item) as ?cnt) WHERE{
?item wdt:P31/wdt:P279* wd:Q202866 .
?item wdt:P577 ?publicationdate .
?item wdt:P495 wd:Q15180 .
BIND(str(year(?publicationdate)) as ?year)
FILTER(bound(?year))
} GROUP BY ?year ORDER BY ?year
#фильмы по языкам
SELECT ?lang ?langLabel ?cnt WHERE {
{
SELECT distinct ?lang (COUNT(distinct ?item) AS ?cnt) WHERE {
?item (wdt:P31/wdt:P279*) wd:Q11424.
?item wdt:P364 ?lang.
} GROUP BY ?lang
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "ru,[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?cnt)
#Фильмы конкретного года
SELECT DISTINCT ?item ?itemLabel ?name ?typeLabel ?year ?countryLabel ?valLabel WHERE {
?item (wdt:P31/wdt:P279*) wd:Q11424.
?item wdt:P577 ?publicationdate.
OPTIONAL { ?item wdt:P793 ?val .}
OPTIONAL { ?item wdt:P1476 ?name .}
OPTIONAL { ?item wdt:P495 ?country .}
?item wdt:P31 ?type .
BIND(STR(YEAR(?publicationdate)) AS ?year)
FILTER(?year = "1894")
SERVICE wikibase:label { bd:serviceParam wikibase:language "ru" }
} order BY ?valLabel
Города России[edit]
#defaultView:Map
#Карта городов России
SELECT ?cityLabel ?coord WHERE {
?city wdt:P131* wd:Q159;
wdt:P625 ?coord;
wdt:P1082 ?population;
wdt:P31 wd:Q515 .
FILTER(?population > 100000) .
SERVICE wikibase:label { bd:serviceParam wikibase:language "ru" }
}
Кратеры по астрономическим объектам[edit]
# Distribution of craters on astronomical bodies
SELECT distinct ?planet ?planetLabel (COUNT(distinct ?crater) AS ?cnt)
WHERE {
?crater wdt:P31 wd:Q3240715 ;
wdt:P376 ?planet .
#FILTER(?planet)
SERVICE wikibase:label { bd:serviceParam wikibase:language "ru" }
} GROUP BY ?planet ?planetLabel ORDER BY DESC(?cnt)
Покинутые населённые пункты[edit]
# map of places with population 0 (zero)
#defaultView:Map
SELECT ?place ?placeLabel ?coordinates ?layer WHERE {
?place wdt:P1082 0.
OPTIONAL { ?place wdt:P17 ?country. }
OPTIONAL { ?place wdt:P625 ?coordinates. }
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en".
?place rdfs:label ?placeLabel.
?country rdfs:label ?layer.
}
}
Кладбища Перми[edit]
#defaultView:Map
SELECT DISTINCT ?loc ?coor ?locLabel WHERE {
?loc wdt:P31/wdt:P279* wd:Q39614.
?loc wdt:P131/wdt:P131* wd:Q915.
OPTIONAL {?loc wdt:P625 ?coor }.
SERVICE wikibase:label { bd:serviceParam wikibase:language "ru" }
}
Объекты в России без русских меток[edit]
#defaultView:Map
SELECT DISTINCT ?item ?itemLabel ?coor WHERE {
?item (wdt:P31/wdt:P279*) wd:Q618123.
?item wdt:P17 wd:Q159.
?item rdfs:label ?itemLabel.
OPTIONAL { ?item wdt:P625 ?coor . }
MINUS {
?item rdfs:label ?label2.
FILTER((LANG(?label2)) = "ru")
}
}
LIMIT 1000
Около Перми:
#defaultView:Map
SELECT DISTINCT ?item ?itemLabel ?coor WHERE {
wd:Q915 wdt:P625 ?Loc.
SERVICE wikibase:around {
?item wdt:P625 ?coor.
bd:serviceParam wikibase:center ?Loc.
bd:serviceParam wikibase:radius "50".
}
#FILTER { #?item (wdt:P31/wdt:P279*) wd:Q618123.
#?item wdt:P17 wd:Q159.
?item rdfs:label ?itemLabel.
MINUS {
?item rdfs:label ?label2.
FILTER((LANG(?label2)) = "ru")
}
}
Имена-фамилии[edit]
- Most frequently variants of given names Anton
#Most frequently variants of given names Anton
# Query to find the most-frequently represented
# variants of the male given name ?tgt_name
# when ?tgt_name = Q2958359
# Query generated by [[Template:NameVariantStatsM]]
SELECT distinct ?name ?nameLabel ?nameDescription ?string ?count ?example ?exampleLabel WHERE {
hint:Query hint:optimizer "None" .
{
SELECT distinct ?name ?string (COUNT(DISTINCT ?a) AS ?count) (SAMPLE(?a) AS ?example) WHERE {
{
SELECT DISTINCT ?name ?string WHERE {
{?name wdt:P460* wd:Q35663473 } UNION { wd:Q35663473 wdt:P460* ?name} .
?name wdt:P31 wd:Q12308941 .
?name wdt:P1705 ?string.
}
} .
?a wdt:P735 ?name .
?a wdt:P31 wd:Q5 .
# ?a wdt:P27 wd:болгария.
} GROUP BY ?name ?string
} .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "ru,en" .
}
}
# HAVING (?count > 1)
ORDER BY DESC(?count) ?itemLabel
- Все (мужские) имена русского языка с кол-вом носителей:
# Distribution of values of a property
SELECT distinct ?name ?nameLabel (COUNT(distinct ?item) AS ?cnt)
WHERE {
?name wdt:P31 wd:Q12308941 .
?name wdt:P407 wd:Q7737 .
?item wdt:P735 ?name .
SERVICE wikibase:label { bd:serviceParam wikibase:language "ru" }
} GROUP BY ?name ?nameLabel ORDER BY DESC(?cnt)
Требует обработки:
# Русские имена на латинице
SELECT DISTINCT ?name ?nameLabel (COUNT(DISTINCT ?item) AS ?cnt) WHERE {
?name wdt:P31 wd:Q11879590.
?name wdt:P407 wd:Q7737.
?name wdt:P282 wd:Q8229.
?item wdt:P735 ?name.
SERVICE wikibase:label { bd:serviceParam wikibase:language "ru". }
}
GROUP BY ?name ?nameLabel
ORDER BY DESC(?cnt)
и
# Русские граждане с именем на латинице
SELECT ?name ?nameLabel (COUNT(?person) AS ?cnt) WHERE
{
?person wdt:P31 wd:Q5;
wdt:P27 wd:Q159;
wdt:P735 ?name.
?name wdt:P282 wd:Q8229.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?name ?nameLabel
ORDER BY DESC(?cnt)
SELECT DISTINCT ?all ?names
WITH
{
SELECT ?other ?ru (COUNT(DISTINCT ?p ) as ?count)
WHERE
{
hint:Query hint:optimizer "None".
?p wdt:P27 wd:Q159 ; wdt:P21 wd:Q6581072 ; wdt:P734 ?item .
?item wdt:P1705 ?ru .
{ ?item wdt:P460* ?other } UNION { ?other wdt:P460* ?item } .
}
GROUP BY ?other ?ru
ORDER BY ?ru
} as %a
WHERE
{
SELECT ?other (sum(?count) as ?all) (GROUP_CONCAT(DISTINCT CONCAT(?ru, " (",str(?count),"), ") ) as ?names)
{ INCLUDE %a }
GROUP bY ?other
}
ORDER BY DESC(?all)
LIMIT 100
Все детективы-персонажи[edit]
SELECT distinct ?item ?label ?desc ?samplework ?workLabel ?authorLabel ?_image WHERE {
?item wdt:P31/wdt:P279* wd:Q15632617.
?item wdt:P106/wdt:P279* wd:Q842782 .
OPTIONAL {?item schema:description ?desc FILTER( LANG( ?desc ) = 'ru' ) .}
OPTIONAL {
SELECT ?item (count(*) as ?ct) (SAMPLE(?work) as ?samplework)
WHERE { OPTIONAL { ?item wdt:P1441 ?work .}
}
GROUP BY ?item
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "ru","en" .
?item rdfs:label ?label .
?samplework rdfs:label ?workLabel.
?author rdfs:label ?authorLabel.
}
OPTIONAL { ?item wdt:P18 ?_image .}
OPTIONAL { ?item wdt:P170 ?author .}
# sampling by image timeout:
# OPTIONAL {
# SELECT ?item (count(*) as ?ct) (SAMPLE(?image) as ?_image)
# WHERE { OPTIONAL { ?item wdt:P18 ?image .}
# }
# GROUP BY ?item
# }
}
Города по населению у любой исторической страны[edit]
SELECT ?cityLabel ?population WHERE {
?city (wdt:P31/wdt:P279*) wd:Q515.
?city p:P17 ?statement.
?statement ps:P17 wd:Q34266.
?statement wikibase:rank ?rank.
?city wdt:P1082 ?population.
SERVICE wikibase:label { bd:serviceParam wikibase:language "ru". }
}
GROUP BY ?population ?cityLabel
ORDER BY DESC(?population)
LIMIT 20
Анализ списка ролей[edit]
SELECT ?d ?cast ?castLabel ?dob ?age ?sitelinks ?img ?role1 ?role1Label ?role2
{
BIND( wd:Q328695 as ?film)
?film wdt:P577|wdt:P580 ?d
FILTER NOT EXISTS { ?film wdt:P577 ?d1 FILTER( ?d1 < ?d) }
?film ( wdt:P161| wdt:P57 ) ?cast . ?cast wikibase:sitelinks ?sitelinks.
OPTIONAL { ?cast wdt:P569 ?dob }
BIND( YEAR(?d)-YEAR(?dob) as ?age)
OPTIONAL { ?cast wdt:P18 ?img}
OPTIONAL { ?film p:P161 [ps:P161 ?cast; pq:P453 ?role1] }
OPTIONAL { ?film p:P161 [ps:P161 ?cast; pq:P4633 ?role2] }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by desc(?sitelinks) LIMIT 10
Расстояние между элементами[edit]
PREFIX gas: <http://www.bigdata.com/rdf/gas#>
SELECT ?depth ?subject ?subjectLabel ?predicate ?object ?objectLabel {
SERVICE gas:service {
gas:program gas:gasClass 'com.bigdata.rdf.graph.analytics.BFS';
gas:in wd:Q1072190;
gas:target wd:Q6027402;
gas:out ?object;
gas:out1 ?depth;
gas:out2 ?subject;
gas:maxIterations 12;
gas:maxVisited 10000 .
}
?subject ?predicate ?object . # figure out what link type(s) connect a vertex with a predecessor
FILTER(?depth > 0) . # remove dead ends from results
SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} ORDER BY ASC(?depth)
Железные дороги России[edit]
#defaultView:Map{"hide":["?coord1", "?coord2", "?line"]}
SELECT * WHERE {
?comm1 wdt:P31 wd:Q55488 ; wdt:P17 wd:Q159 ; wdt:P625 ?coord1 ; wdt:P197 ?comm2.
?comm1 wdt:P131* wd:Q5400.
MINUS { ?comm1 p:P31 [ ps:P31 wd:Q55488 ; pq:P582 [] ] . }
MINUS { ?comm2 p:P31 [ ps:P31 wd:Q55488 ; pq:P582 [] ] . }
?comm2 wdt:P625 ?coord2 .
?comm1 p:P625 [ ps:P625 []; psv:P625 [ wikibase:geoLongitude ?coord1lon; wikibase:geoLatitude ?coord1lat; ] ].
?comm2 p:P625 [ ps:P625 []; psv:P625 [ wikibase:geoLongitude ?coord2lon; wikibase:geoLatitude ?coord2lat; ] ].
BIND(CONCAT('LINESTRING (', STR(?coord1lon), ' ', STR(?coord1lat), ',', STR(?coord2lon), ' ', STR(?coord2lat), ')') AS ?str) .
BIND(STRDT(?str, geo:wktLiteral) AS ?line)
}
#defaultView:Map
SELECT ?station ?line (CEIL(?depth/10)*10 as ?layer) {
SERVICE gas:service {
gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS" ; gas:in wd:Q4351569 ; gas:out ?station ; gas:out1 ?depth ; gas:out2 ?pred .
gas:program gas:linkType wdt:P197 . }
FILTER(?station != wd:Q4351569)
?pred wdt:P625 ?cds.
BIND(IF(xsd:double(?depth/10) = xsd:integer(?depth/10),?cds,"") as ?coords)
?pred p:P625/psv:P625/wikibase:geoLatitude ?lat1 ; p:P625/psv:P625/wikibase:geoLongitude ?lon1 .
?station p:P625/psv:P625/wikibase:geoLatitude ?lat2 ; p:P625/psv:P625/wikibase:geoLongitude ?lon2 .
?station wdt:P17 wd:Q159 .
BIND(CONCAT('LINESTRING(', STR(?lon1), ' ', STR(?lat1), ',', STR(?lon2), ' ', STR(?lat2), ')') AS ?str) . BIND(STRDT(?str, geo:wktLiteral) AS ?line)
SERVICE wikibase:label { bd:serviceParam wikibase:language "ru,en". }
}
#Единицы СИ
select
?unit (sample(?label) as ?label) (sample(?desc) as ?desc)
(sample(?conversion) as ?conversion) (sample(?symbol) as ?symbol)
(group_concat(distinct ?quantity; separator = "; ") as ?quantities)
where {
?unit wdt:P31 / wdt:P279* wd:Q69197847 . # coherent SI unit
optional { ?unit rdfs:label ?label . filter (lang(?label) = "en") }
optional { ?unit schema:description ?desc . filter (lang(?desc) = "en") }
optional { ?unit wdt:P2370 ?conversion } # 1 for every coherent SI unit
optional { ?unit wdt:P5061 ?symbol . filter (lang(?symbol) = "en") }
optional { ?unit wdt:P111 / rdfs:label ?quantity . filter (lang(?quantity) = "en") }
} group by ?unit
Languages without notable men[edit]
Can anyone list languages without any speaker (languages spoken, written or signed (P1412) and native language (P103)) on Wikidata? Better if sorted by a number of real speakers. --Infovarius (talk) 19:18, 6 January 2017 (UTC)
- Try it!
SELECT ?lang ?langLabel ?speakers { ?lang wdt:P279*/wdt:P31 wd:Q315 . FILTER NOT EXISTS { [] (wdt:P1412|wdt:P103) ?lang } . OPTIONAL { ?lang wdt:P1098 ?speakers } . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } . } ORDER BY DESC(?speakers)
- Matěj Suchánek (talk) 21:06, 7 January 2017 (UTC)
- Or directly?
- Try it!
SELECT ?lang ?langLabel ?speakers { ?lang wdt:P1098 ?speakers . FILTER NOT EXISTS { [] (wdt:P1412|wdt:P103) ?lang } . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } . } ORDER BY DESC(?speakers)
- Given that P1412 was largely fed by BnF, it might be a list of languages in which there are no books held?
--- Jura 07:18, 8 January 2017 (UTC)
Maintenance[edit]
Recent deaths nearby without Commons pic[edit]
#title:People recently buried in a cemetery nearby without an image of the grave (P1442) on Wikidata
#defaultView:Map{"hide":["?coor"]}
#by Jura1, 2021-11-0, source: https://www.wikidata.org/wiki/Property_talk:P1442#Queries
SELECT ?item ?itemLabel ?itemDescription ?date_of_death ?cemetery ?cemeteryLabel ?coor ?commons_category_which_may_include_one ?findagrave ?img_person ?img_cemetery WHERE {
?item wdt:P119 ?cemetery.
?cemetery wdt:P31 wd:Q39614.
?item wdt:P570 ?date_of_death.
FILTER(?date_of_death > "2010-01-01"^^xsd:dateTime)
FILTER(NOT EXISTS { ?item p:P1442 _:b0. })
?cemetery wdt:P625 ?coor.
FILTER(NOT EXISTS {
?cemetery wdt:P625 ?c2.
FILTER((STR(?coor)) > (STR(?c2)))
})
OPTIONAL {
?item wdt:P373 ?cat.
BIND(URI(CONCAT("https://commons.wikimedia.org/wiki/Category:", ?cat)) AS ?commons_category_which_may_include_one)
}
OPTIONAL {
?item wdt:P535 ?fid.
wd:P535 wdt:P1630 ?ff.
BIND(URI(REPLACE(?ff, "\\$1", ?fid)) AS ?findagrave)
}
OPTIONAL { ?item wdt:P18 ?img_person. }
FILTER(NOT EXISTS {
?item wdt:P18 ?i2.
FILTER((STR(?i2)) > (STR(?img_person)))
})
OPTIONAL { ?cemetery wdt:P18 ?img_cemetery. }
FILTER(NOT EXISTS {
?cemetery wdt:P18 ?i3.
FILTER((STR(?i3)) > (STR(?img_cemetery)))
})
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,fr". }
?cemetery wdt:P131* wd:Q915.
}
Useful[edit]
Wikidata:SPARQL query service/query optimization mw:Wikidata Query Service/Categories
Qlever federated[edit]
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
select * {
# fetch results from qlever
service <https://qlever.cs.uni-freiburg.de/api/wikidata> {
?a wdt:P279+ ?b.
?b wdt:P279 ?a.
}
# tell blazegraph to not be stupid and fetch results from qlever first
hint:Prior hint:runFirst "true".
# repeat query on the subset returned from qlever to filter out anything that's been fixed
?a wdt:P279+ ?b.
?b wdt:P279 ?a.
}
Hints[edit]
- hint:Prior hint:rangeSafe true. - all of the data in the objects in the preceding triple are of the same sort. See query optimization#Fixed values and ranges
- hint:Query hint:optimizer "None". - make the query engine run the clauses in the order you list them, rather than deciding where to start
- hint:SubQuery hint:optimizer "None" - ditto, but for a named subquery
- hint:Prior hint:gearing "forward". - as above: when dealing with a compound property path, tell the optimiser to run from subject to object (or if "reverse", from object to subject)
- hint:Prior hint:runFirst true. - run this clause first. Need to wrap compound property path clauses within braces {} & the hint outside.
- hint:Prior hint:runLast true. - run this clause last
There is more here - https://github.com/blazegraph/database/wiki/QueryHints - and here - https://blazegraph.com/database/apidocs/com/bigdata/rdf/sparql/ast/QueryHints.html and possibly here - https://github.com/blazegraph/database/wiki/Explain but it's a bit inpenetrable. --Tagishsimon (обсуждение) 18:50, 16 October 2023 (UTC)
Subquery form[edit]
SELECT ?something
with {SELECT ?something where {
. . .
} group by ?something
} as %stuff
. . .
where { include %stuff
SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
}
Distribution of statement values[edit]
# Distribution of values of a property
SELECT distinct ?value ?valueLabel (COUNT(distinct ?item) AS ?cnt)
WHERE {
?item wdt:P3716 ?value .
SERVICE wikibase:label { bd:serviceParam wikibase:language "ru" }
} GROUP BY ?value ?valueLabel ORDER BY DESC(?cnt)
# Distribution of craters on astronomical bodies
SELECT distinct ?planet ?planetLabel (COUNT(distinct ?crater) AS ?cnt)
WHERE {
?crater wdt:P31 wd:Q3240715 ;
wdt:P376 ?planet .
#FILTER(?planet)
SERVICE wikibase:label { bd:serviceParam wikibase:language "ru" }
} GROUP BY ?planet ?planetLabel ORDER BY DESC(?cnt)
Amount of values[edit]
SELECT ?item (COUNT(*) AS ?elo_cnt) WHERE {
?item p:P1087 [] .
} GROUP BY ?item HAVING(?elo_cnt<5)
Statistics of properties of the item[edit]
SELECT ?property ?propertyLabel (COUNT(?property) AS ?count) WHERE {
wd:Q12823 ?p [] .
?property wikibase:claim ?p .
SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} GROUP BY ?property ?propertyLabel
Number of values of a property of each instance[edit]
SELECT ?lang ?langLabel (COUNT(DISTINCT ?website) as ?count)
WHERE {
?lang wdt:P31/wdt:P279* wd:Q9143.
?lang p:P856 ?website.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
GROUP BY ?lang ?langLabel
ORDER BY DESC(?count)
Number of properties' uses in some set of items[edit]
#title:count of statements by property for instances
SELECT ?property ?propertyLabel ?count WITH {
SELECT ?property (count(distinct ?property) as ?count)
WHERE
{
?item wdt:P31 wd:Q3918.
hint:Prior hint:runFirst true.
?item ?predicate [].
?property wikibase:directClaim ?predicate .
} group by ?property ?propertyLabel } as %props
WHERE
{
INCLUDE %props
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY DESC(?count)
Separating query due to Q-number[edit]
SELECT ?item ?itDescrizione WITH {
SELECT ?item {
BIND( 1000000 * 13 AS ?base ) . # change this 0-30
?item wdt:P31 wd:Q4167836 .
BIND( xsd:integer( STRAFTER( STR( ?item ), STR( wd:Q ) ) ) AS ?num ) .
FILTER( ?num > ?base + 0 && ?num < ?base + 1000001 ) .
}
} AS %sub WHERE {
INCLUDE %sub .
?item schema:description ?itDescrizione FILTER( LANG( ?itDescrizione ) = 'it' ) .
FILTER( STR( ?itDescrizione ) != 'categoria di un progetto Wikimedia' ) .
}
Objects around[edit]
SELECT ?place
WHERE
{
# Berlin coordinates
wd:Q7150840 wdt:P625 ?berlinLoc .
SERVICE wikibase:around {
?place wdt:P625 ?location .
bd:serviceParam wikibase:center ?berlinLoc .
bd:serviceParam wikibase:radius "30" .
}
# Is an airport
?place wdt:P31/wdt:P279* wd:Q1248784 .
}
Most popular qualifiers for most popular properties[edit]
I have a query, which lists used properties by their popularity at Eurovision Song Contest (Q276) items. Could somebody add column, which lists, what qualifiers (and their count) are used for that particular property? Something like this: P<qualifier>: <count>, P<qualifier>: <count> etc.
. Or at least row for each property+qualifier pair. Query (probably may be done in a better way):
SELECT ?prop ?propLabel ?count WHERE {
{
SELECT ?prop (COUNT(DISTINCT ?item) AS ?count) WHERE {
hint:Query hint:optimizer "None" .
?item wdt:P31 wd:Q276 .
?item ?p ?id .
?prop wikibase:directClaim ?p .
} GROUP BY ?prop
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
} ORDER BY DESC (?count)
--Edgars2007 (talk) 15:43, 13 May 2017 (UTC)
- I hope this is what you wanted:
- Try it!
SELECT ?prop ?propLabel ?count ?qualifiers WHERE { { SELECT ?p (COUNT(DISTINCT ?item) AS ?count) (GROUP_CONCAT(DISTINCT ?q; separator=', ') AS ?qualifiers) WHERE { ?item wdt:P31 wd:Q276; ?p [] . ?p ^wikibase:claim [] . OPTIONAL { { SELECT ?p (CONCAT(STRAFTER(STR(?qualifier), STR(pq:)), ': ', STR(COUNT(DISTINCT ?statement))) AS ?q) WHERE { [] wdt:P31 wd:Q276; ?p ?statement . ?p ^wikibase:claim [] . ?statement ?qualifier [] . ?qualifier ^wikibase:qualifier [] . } GROUP BY ?p ?qualifier } . } . } GROUP BY ?p } . ?prop wikibase:claim ?p . SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } . } ORDER BY DESC(?count)
- Matěj Suchánek (talk) 17:05, 13 May 2017 (UTC)
Sort by number of sitelinks (with image)[edit]
#defaultView:ImageGrid
SELECT ?itemLabel ?count ?image WHERE {
?item wikibase:sitelinks ?count.
?item wdt:P31/wdt:P279* wd:Q466797.
# FILTER (SUBSTR(str(?sitelink), 11, 15) = ".wikipedia.org/") .
OPTIONAL {?item wdt:P18 ?image }
SERVICE wikibase:label { bd:serviceParam wikibase:language "ru","en" }
}
ORDER BY DESC(?count)
Сравнение меток и описаний[edit]
select * {
wd:Q25290 schema:description ?desc .
wd:Q577 rdfs:label ?label .
filter (lang(?desc) = lang(?label)) .
filter (?label != ?desc) .
bind (lang(?label) as ?lang) .
} order by ?lang
select ?lang (count(*) as ?total) {
?item wdt:P31 wd:Q577 .
?item wdt:P585 ?pit .
?item rdfs:label ?label .
bind (lang(?label) as ?lang) .
filter (str(?label) != str(year(?pit))) .
filter (?item not in (wd:Q3342801, wd:Q16131968)) . # out of sync items
} group by ?lang order by ?lang
Area chart - distribution vs years[edit]
#defaultView:AreaChart
SELECT ?cid (str(SAMPLE(?year)) AS ?year ) (COUNT(*) AS ?count) ?cause WHERE {
?pid wdt:P31/wdt:P279* wd:Q7397.
?pid wdt:P277 ?cid.
OPTIONAL {
?cid rdfs:label ?cause.
FILTER((LANG(?cause)) = "en")
}
?pid wdt:P571 ?_date_of_death.
BIND ( YEAR(?_date_of_death) AS ?year )
FILTER( BOUND(?cause) )
FILTER( BOUND(?year) )
FILTER( ?year > 1900 )
}
GROUP BY ?cid ?cause ?year
Units[edit]
# Ближайшие к Солнцу галактики
SELECT distinct ?item ?label ?dist ?distunitLabel WHERE {
?item wdt:P361 wd:Q3944.
SERVICE wikibase:label {
bd:serviceParam wikibase:language "ru" .
?item rdfs:label ?label.
?distunit rdfs:label ?distunitLabel.
}
?item p:P2583/psv:P2583 ?distT.
?distT wikibase:quantityAmount ?dist.
?distT wikibase:quantityUnit ?distunit.
OPTIONAL { ?item wdt:P18 ?_image. }
}
Normalisation[edit]
# Stars up to 18 light years away sorted by the nearest
SELECT ?star ?starLabel ?distance ?unitLabel ?lightyears
WHERE
{
{
SELECT ?star ?distance ?unit ?lightyears
WHERE
{
?star wdt:P31 wd:Q523.
?star p:P2583/psv:P2583 ?statement.
?statement wikibase:quantityUnit ?unit.
?statement wikibase:quantityAmount ?distance.
?statement wikibase:quantityNormalized/wikibase:quantityAmount ?distanceNormalized. # convert to normalized unit (meter)
BIND (?distanceNormalized / 9460800000000000 AS ?lightyears)
FILTER( ?lightyears < 19)
}
LIMIT 100
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
ORDER BY ?lightyears
LIMIT 100
Sitelinks, featured, badges[edit]
PREFIX schema: <http://schema.org/>
# Featured/Good articles in one language that don't have a French Wikipedia page
SELECT DISTINCT ?item ?itemLabel WHERE {
?featuredArticle schema:about ?item.
?featuredArticle schema:inLanguage "ru".
?featuredArticle wikibase:badge ?badgeValues.
?item wdt:P31 wd:Q5.
?item wdt:P21 wd:Q6581072.
VALUES (?badgeValues) {
(wd:Q17437796)
(wd:Q17437798)
}
OPTIONAL {
?sitelink schema:about ?item.
?sitelink schema:inLanguage "fr".
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en,ru". }
FILTER(!BOUND(?sitelink))
}
ORDER BY ?itemLabel
All events in the city between dates[edit]
SELECT distinct ?event ?eventLabel ?time ?begin ?end ?create ?destroy WHERE {
VALUES ?city { wd:Q649 }.
VALUES ?startTime {"1990-12-31"^^xsd:dateTime}.
{?event wdt:P131* ?city.} UNION {?event wdt:P276 ?city.}
# ?event wdt:P31/wdt:P279* wd:Q1190554. (anyway timesout)
{?event p:P276 ?statement.
?statement pqv:P580 ?beginvalue;
pqv:P582 ?endvalue;
ps:P276 ?city.
?beginvalue wikibase:timeValue ?begin .
?endvalue wikibase:timeValue ?end .
FILTER("1990-12-31"^^xsd:dateTime < ?begin && ?begin < "2020-00-00"^^xsd:dateTime||
"1990-12-31"^^xsd:dateTime < ?end && ?end < "2020-00-00"^^xsd:dateTime)
}
UNION
{ ?event wdt:P585 ?time.
FILTER("1990-12-31"^^xsd:dateTime < ?time && ?time < "2020-00-00"^^xsd:dateTime)
}
UNION
{ ?event wdt:P580 ?begin;
wdt:P582 ?end.
FILTER("1990-12-31"^^xsd:dateTime < ?begin && ?begin < "2020-00-00"^^xsd:dateTime ||
"1990-12-31"^^xsd:dateTime < ?end && ?end < "2020-00-00"^^xsd:dateTime)
}
UNION
{ ?event wdt:P571 ?create;
wdt:P576 ?destroy;
FILTER("1990-12-31"^^xsd:dateTime < ?create && ?create < "2020-00-00"^^xsd:dateTime ||
"1990-12-31"^^xsd:dateTime < ?destroy && ?destroy < "2020-00-00"^^xsd:dateTime)
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Пересечение двух запросов[edit]
SELECT *
WITH {
SELECT ?item WHERE {
?item wdt:P31/wdt:P279* wd:Q16917 ; wdt:P17 wd:Q145 .
}
} AS %UK
WITH {
SELECT ?item WHERE {
?item wdt:P131/wdt:P131* wd:Q25 .
}
} AS %Wales
WHERE {
INCLUDE %UK .
INCLUDE %Wales .
}
График от момента во времени[edit]
# number of living people who have walked on the moon, over time
#defaultView:LineChart
SELECT ?date (COUNT(DISTINCT ?item) AS ?count)
WITH {
# get all the dates where the number of living people who have walked on the moon changed
# (person walked on the moon or person died)
SELECT DISTINCT ?date WHERE {
{
# person walked on the moon
?item p:P793 [
ps:P793 wd:Q42882411;
pq:P580 ?date_
].
} UNION {
# person died
?item p:P793/ps:P793 wd:Q42882411;
wdt:P570 ?date_.
}
# for each date, inject a second date, one day before,
# so that we get a straight line until that date and then a steep climb/drop for the real change,
# instead of a diagonal slope over the entire preceding period
VALUES ?toggle { true false }
BIND(IF(?toggle, ?date_, ?date_ - "P1D"^^xsd:duration) AS ?date)
}
} AS %dates
WHERE {
# inject the current time as another date, so that the chart continues until the present day
{ INCLUDE %dates. } UNION { BIND(NOW() AS ?date) }
# main query: find all living people who have walked on the moon at each date
?item p:P793 [
ps:P793 wd:Q42882411;
pq:P580 ?walkdate
].
FILTER(?date >= ?walkdate) # must have walked on the moon already
OPTIONAL { ?item wdt:P570 ?died. }
FILTER(!BOUND(?died)|| ?date < ?died) # must not yet have died
}
GROUP BY ?date
ORDER BY ?date
Blazegraph[edit]
- construct only with hints
CONSTRUCT {
?film wdt:P31 wd:Q11424.
?film rdfs:label ?filmLabel.
}
WHERE {
?film wdt:P31 wd:Q11424 .
# hint:Query hint:queryEngineChunkHandler "Managed" .
hint:Query hint:constructDistinctSPO false .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}
MediaWiki api[edit]
SELECT * WHERE {
hint:Query hint:optimizer "None".
BIND(wd:Q2673411 AS ?item)
BIND(<https://en.wikipedia.org/> AS ?wiki)
BIND(STRBEFORE(STRAFTER(STR(?wiki), "https://"), "/") AS ?domain)
?sitelink schema:about ?item;
schema:isPartOf ?wiki;
schema:name ?title.
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:endpoint ?domain;
wikibase:api "Generator";
mwapi:generator "allpages";
mwapi:gapfrom ?title;
mwapi:gapto ?title.
?id wikibase:apiOutput "@pageid".
}
}
Поиск по строке[edit]
SELECT DISTINCT ?item ?itemLabel
WHERE {
hint:Query hint:optimizer "None".
VALUES ?name {"Wolfgang Amadeus Mozart" "George Frideric Handel"}
BIND(?name as ?name2)
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:api "Search";
wikibase:endpoint "www.wikidata.org";
mwapi:srsearch ?name.
?item wikibase:apiOutputItem mwapi:title .
}
?item wdt:P31 wd:Q5.
?item rdfs:label ?label.
FILTER regex(str(?label), ?name2)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de". }
}
Categories[edit]
For every article in category_en find article which isn't in category_it
SELECT ?item ?itemLabel ?article_en ?category_en ?article_it ?category_it
WITH
{
SELECT ?item (COUNT(?in_en) AS ?category_en) (COUNT(?in_it) AS ?category_it)
WHERE
{
VALUES ?category { wd:Q7893678 }
{
[] schema:about ?category; schema:isPartOf <https://en.wikipedia.org/>; schema:name ?cat_title_en.
SERVICE wikibase:mwapi
{
bd:serviceParam wikibase:api "Generator".
bd:serviceParam wikibase:endpoint "en.wikipedia.org".
bd:serviceParam mwapi:gcmtitle ?cat_title_en.
bd:serviceParam mwapi:generator "categorymembers".
bd:serviceParam mwapi:gcmprop "ids".
bd:serviceParam mwapi:gcmlimit "max".
?item wikibase:apiOutputItem mwapi:item.
}
VALUES ?in_en { true }
}
UNION
{
[] schema:about ?category; schema:isPartOf <https://it.wikipedia.org/>; schema:name ?cat_title_it.
SERVICE wikibase:mwapi
{
bd:serviceParam wikibase:api "Generator".
bd:serviceParam wikibase:endpoint "it.wikipedia.org".
bd:serviceParam mwapi:gcmtitle ?cat_title_it.
bd:serviceParam mwapi:generator "categorymembers".
bd:serviceParam mwapi:gcmprop "ids".
bd:serviceParam mwapi:gcmlimit "max".
?item wikibase:apiOutputItem mwapi:item.
}
VALUES ?in_it { true }
}
}
GROUP BY ?item
HAVING (?category_en = 0|
#Search in categories
SELECT ?item ?itemLabel
WHERE
{
SERVICE wikibase:mwapi
{
bd:serviceParam wikibase:api "Search" .
bd:serviceParam wikibase:endpoint "sv.wikipedia.org" .
bd:serviceParam mwapi:srnamespace "0" .
bd:serviceParam mwapi:srsearch 'deepcat:"Pargas (kommun)"' .
?title wikibase:apiOutput mwapi:title .
}
BIND (STRLANG(?title, "sv") AS ?title_sv)
hint:Query hint:optimizer "None".
?article_sv schema:name ?title_sv.
?article_sv schema:about ?item.
?article_sv schema:isPartOf <https://sv.wikipedia.org/>.
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv". }
}
Category Tree[edit]
SELECT ?out ?depth WHERE {
SERVICE <https://query.wikidata.org/bigdata/namespace/categories/sparql> {
SERVICE mediawiki:categoryTree {
bd:serviceParam mediawiki:start <https://en.wikipedia.org/wiki/Category:Ducks>;
mediawiki:direction "Reverse";
mediawiki:depth 5 .
}
}
}
ORDER BY ?depth
Getting elements in category tree with name of subcat[edit]
SELECT ?subcat ?item ?title WHERE {
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:api "Generator" .
bd:serviceParam wikibase:endpoint "ru.wikipedia.org" .
bd:serviceParam mwapi:gcmtitle "Категория:Древнегреческие боги" .
bd:serviceParam mwapi:generator "categorymembers" .
bd:serviceParam mwapi:gcmprop "title" .
bd:serviceParam mwapi:gcmlimit "max" .
bd:serviceParam mwapi:gcmnamespace "14" .
?subcat wikibase:apiOutput mwapi:title .
}
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:api "Generator" .
bd:serviceParam wikibase:endpoint "ru.wikipedia.org" .
bd:serviceParam mwapi:gcmtitle ?subcat .
bd:serviceParam mwapi:generator "categorymembers" .
bd:serviceParam mwapi:gcmprop "title" .
bd:serviceParam mwapi:gcmlimit "max" .
?title wikibase:apiOutput mwapi:title .
?item wikibase:apiOutputItem mwapi:item .
?ns wikibase:apiOutput "@ns" .
}
FILTER(?ns = "0")
}
#Using mwapi to base a query on articles in a Wikipedia category
# Use the MediaWiki API to get the articles from a specific category in a specific Wikipedia language version.
# Then use this results as usual in a query, in this example a simple query for the gender.
# By User:Ainali with the help of User:Dipsacus fullonum 2021-02
SELECT ?item ?itemLabel ?genderLabel WHERE {
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:endpoint "sv.wikipedia.org"; # Set the project here
wikibase:api "Generator";
mwapi:generator "categorymembers"; # Selects the content from a category
mwapi:gcmtitle "Category:Födda 2001";. # Specifies the category (Born in 2001)
?item wikibase:apiOutputItem mwapi:item.
}
FILTER BOUND (?item) # Safeguard to not get a timeout from unbound items when using ?item below
?item wdt:P21 ?gender . # Example retrieval of a value
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,sv". }
}
Father genealogical[edit]
SELECT ?father ?fatherLabel ?child ?childLabel ?depth ?dob WHERE
{
SERVICE gas:service {
gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS" ; gas:in wd:Q7747 ; gas:out ?father ; gas:out1 ?depth ; gas:out2 ?child .
gas:program gas:linkType wdt:P22 . }
OPTIONAL {?father wdt:P569 ?dob.}
SERVICE wikibase:label { bd:serviceParam wikibase:language "ru". }
} order by ?depth
Numeration[edit]
SELECT ?item ?itemLabel ?id (COUNT(?thing) + 1 AS ?row)
WITH
{
SELECT ?item ?id
WHERE
{
?item wdt:P9178 ?id .
} limit 300
}
AS %people
WHERE
{
INCLUDE %people
{
SELECT (?id AS ?id2)
WHERE
{
INCLUDE %people
}
}
BIND (IF(?id2 > ?id, true, 1/0) AS ?thing)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?item ?itemLabel ?id
ORDER BY DESC(?id)
Creators and date of creation of items[edit]
SELECT ?item ?itemLabel ?created ?comment
{
SERVICE wikibase:mwapi
{
bd:serviceParam wikibase:endpoint "www.wikidata.org" .
bd:serviceParam wikibase:api "Generator" .
bd:serviceParam mwapi:generator "random" .
bd:serviceParam mwapi:list "usercontribs" .
bd:serviceParam mwapi:ucuser "Infovarius" .
bd:serviceParam mwapi:ucprop "title|timestamp|comment" .
bd:serviceParam mwapi:ucnamespace "0" .
bd:serviceParam mwapi:ucshow "new" .
bd:serviceParam mwapi:uclimit "1" .
?created wikibase:apiOutput "//api/query/usercontribs/item/@timestamp" .
?comment wikibase:apiOutput "//api/query/usercontribs/item/@comment" .
?item wikibase:apiOutputItem "//api/query/usercontribs/item/@title" .
bd:serviceParam wikibase:limitContinuations "249" .
}
MINUS { ?item wdt:P31 [] }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
}
или
SELECT ?item ?itemLabel ?created ?comment
{
SERVICE wikibase:mwapi
{
bd:serviceParam wikibase:endpoint "www.wikidata.org" .
bd:serviceParam wikibase:api "Generator" .
bd:serviceParam mwapi:generator "random" .
bd:serviceParam mwapi:list "usercontribs" .
bd:serviceParam mwapi:ucuser "Infovarius" .
bd:serviceParam mwapi:ucprop "title|timestamp|comment" .
bd:serviceParam mwapi:ucnamespace "0" .
bd:serviceParam mwapi:ucshow "new" .
bd:serviceParam mwapi:uclimit "1" .
?created wikibase:apiOutput "//api/query/usercontribs/item/@timestamp" .
?comment wikibase:apiOutput "//api/query/usercontribs/item/@comment" .
?item wikibase:apiOutputItem "//api/query/usercontribs/item/@title" .
bd:serviceParam wikibase:limitContinuations "249" .
}
MINUS { ?item wdt:P31 [] }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
Lexemes[edit]
Glossary | SPARQL code |
A Lexeme is a lexical element of a language, such as a word, a phrase, or a prefix (see Lexeme on Wikipedia). Lexemes are Entities in the sense of the Wikibase data model. A Lexeme is described using the following information:
|
|
|
|
|
|
- Распределение по частям речи:
SELECT ?pos ?posLabel (count(?l) as ?count) (SAMPLE(?l) as ?sampleword) WHERE {
?l a ontolex:LexicalEntry ; wikibase:lexicalCategory ?pos.
?l a ontolex:LexicalEntry ; dct:language ?language .
?language wdt:P218 'ru'
SERVICE wikibase:label { bd:serviceParam wikibase:language "ru,[AUTO_LANGUAGE],en". }
} group by ?pos ?posLabel order by desc(?count)
Или в русском:
select ?cat ?catLabel ?cnt ?lems where {
{SELECT ?cat (count(*) as ?cnt) (GROUP_CONCAT(DISTINCT ?lem; SEPARATOR=", ") AS ?lems) WHERE {
?l <http://purl.org/dc/terms/language> wd:Q7737.
?l wikibase:lexicalCategory ?cat.
MINUS { ?l wikibase:lexicalCategory wd:Q1084 }
?l wikibase:lemma ?lem.
} group by ?cat}
SERVICE wikibase:label { bd:serviceParam wikibase:language "ru". }
}
- Без смысла:
# lexemes without sense in the language
SELECT ?l ?lemma WHERE {
?l a ontolex:LexicalEntry ; dct:language ?language ;
wikibase:lemma ?lemma .
?language wdt:P218 'ru'
FILTER NOT EXISTS {?l ontolex:sense ?sense }
}
# distribution of senses per language
SELECT ?lang (COUNT(?sense) AS ?cnt) WHERE {
?l a ontolex:LexicalEntry ; dct:language ?language ;
wikibase:lemma ?lemma .
?language wdt:P218 ?lang.
?l ontolex:sense ?sense.
# ?sense wdt:P5137 [].
}
GROUP BY ?lang
ORDER BY DESC(?cnt)
# Number of forms per language
SELECT
(SAMPLE(?number_of_forms) / SAMPLE(?number_of_lexemes) AS ?form_to_lexeme_ratio)
(SAMPLE(?number_of_lexemes) AS ?number_of_lexemes)
(SAMPLE(?number_of_forms) AS ?number_of_forms)
?language ?languageLabel
WHERE {
{
SELECT ?language (COUNT(*) AS ?number_of_lexemes) WHERE {
[] dct:language ?language .
}
GROUP BY ?language
}
UNION
{
SELECT ?language (COUNT(*) AS ?number_of_forms) WHERE {
[] ^ontolex:lexicalForm / dct:language ?language .
}
GROUP BY ?language
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?language ?languageLabel
HAVING (?number_of_forms > 1)
ORDER BY DESC(?form_to_lexeme_ratio)
# most common properties on senses
SELECT ?property ?propertyLabel ?count WITH {
SELECT ?property (COUNT(?statement) AS ?count) WHERE {
hint:SubQuery hint:optimizer "None".
?lexeme ontolex:sense ?sense.
?sense ?p ?statement.
?property wikibase:claim ?p.
}
GROUP BY ?property
} AS %results WHERE {
INCLUDE %results.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?count)
# Automatic hyperonymy
SELECT ?l ?lemma ?sense ?item ?itemLabel ?class ?classLabel ?lemclass ?ru ?senseHyper WHERE {
?l a ontolex:LexicalEntry ; dct:language ?language ;
wikibase:lemma ?lemma;
#ontolex:gloss ?gloss;
ontolex:sense ?sense.
?language wdt:P218 'ru'.
?sense wdt:P5137 ?item.
?item wdt:P279 ?class.
?class rdfs:label ?ru . filter(lang(?ru)="ru")
?lemclass a ontolex:LexicalEntry; dct:language ?language;
wikibase:lemma ?ru;
ontolex:sense ?senseHyper.
?senseHyper wdt:P5137 ?class.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
SELECT ?lexeme (GROUP_CONCAT(DISTINCT ?lemma; separator = "/") AS ?lemmata) ?sampleSense (SAMPLE(?gloss) AS ?anyGloss)
WITH {
SELECT ?lexeme (SAMPLE(?sense) AS ?sampleSense) WHERE {
SERVICE bd:sample {
?lexeme dct:language wd:Q8752.
bd:serviceParam bd:sample.limit 20 .
}
OPTIONAL { ?lexeme ontolex:sense ?sense. }
}
GROUP BY ?lexeme
} AS %lexemesWithOneSense
WHERE {
INCLUDE %lexemesWithOneSense.
?lexeme wikibase:lemma ?lemma.
BIND(BOUND(?sampleSense) AS ?haveSampleSense) # if ?sampleSense is unbound, the result of the below OPTIONAL is meaningless
BIND(?sampleSense AS ?sampleSense_) # copy of ?sampleSense that can be bound without harm (not included in GROUP BY / SELECT)
OPTIONAL { ?sampleSense_ skos:definition ?gloss_. } # if ?sampleSense_ was unbound, it is now bound to any sense of any gloss
BIND(IF(?haveSampleSense, ?gloss_, ?unbound) AS ?gloss) # use the gloss only if it belongs to the already known ?sampleSense
}
GROUP BY ?lexeme ?sampleSense
- Толковый словарь
SELECT ?l ?lemma ?myPartLabel ?sense ?lang ?senseLabel
WHERE {
?l a ontolex:LexicalEntry ;
dct:language wd:Q143 ;
wikibase:lexicalCategory ?myPart;
wikibase:lemma ?lemma;
ontolex:sense ?sense.
?sense skos:definition ?senseLabel.
# VALUES ?myPart { wd:Q1084 wd:Q24905 wd:Q34698 wd:Q380057 }
# FILTER (LANG(?sense)='ru').
BIND(LANG(?senseLabel) AS ?lang)
# FILTER (STR(?lemma) = ?word) .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
- Все слова опр. части речи
#All words of POS
SELECT ?lang ?langLabel (COUNT(?l) AS ?c) (GROUP_CONCAT(?lemma) as ?lemmata) WHERE {
?l wikibase:lexicalCategory/wdt:P279* wd:Q63116 ; wikibase:lemma ?lemma ; dct:language ?lang .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?lang ?langLabel
ORDER BY DESC ( ?c )
- https://tools.wmflabs.org/ordia/language/
- Wikidata:Lexicographical data/Statistics/indirect translations
- Wikidata:Lexicographical data/Statistics/translations
- Number of Lexemes including recordings from Lingua Libre by language
To Do[edit]
- Какое распределение доли российских фильмов по годам?
- В каком роде больше всего видов? Какое распределение по кол-ву? [1]
Other[edit]
- Asaf's gradually complicating examples using Estonia and Estonians
- more queries by Asaf
- queries by MKar
- queries by MartinPoulter
- the example queries featured in the Examples button on query.wikidata.org
- queries by Hsarrazin (descriptions in French)
- https://qlever.cs.uni-freiburg.de/wikidata/yxaYvc - for fast queris