Project:SPARQL/examples: Difference between revisions
Jump to navigation
Jump to search
OlafJanssen (talk | contribs) |
OlafJanssen (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
==Examples== | ==Examples== | ||
=== | |||
=== Overview of properties in this Wikibase, with their Labels, Descriptions and Aliases, both in NL and in EN, as well their equivalent properties in Wikidata (if applicable) === | |||
<sparql tryit="1"> | <sparql tryit="1"> | ||
# | # Overview of properties in this Wikibase, | ||
# with their Labels, Descriptions and Aliases, | |||
# both in NL and in EN, | |||
# as well their equivalent properties in Wikidata (if applicable) | |||
PREFIX skos: <http://www.w3.org/2004/02/skos/core#> | |||
PREFIX schema: <http://schema.org/> | |||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | |||
PREFIX wikibase: <http://wikiba.se/ontology#> | PREFIX wikibase: <http://wikiba.se/ontology#> | ||
PREFIX wdt: <https://kbtestwikibase.wikibase.cloud/prop/direct/> | |||
SELECT ? | SELECT ?p ?pType | ||
? | ?pLabelNL ?pLabelEN | ||
?pDescriptionNL ?pDescriptionEN | |||
(GROUP_CONCAT(DISTINCT ?pAliasNL ; separator = "|") as ?pAliasesNL ) | |||
(GROUP_CONCAT(DISTINCT ?pAliasEN ; separator = "|") as ?pAliasesEN ) | |||
?wikidataEquivalentProperty | |||
WHERE { | |||
?p wikibase:propertyType ?pType . | |||
OPTIONAL{?p wdt:P1 ?wikidataEquivalentProperty.} | |||
OPTIONAL{?p rdfs:label ?pLabelNL FILTER(LANG(?pLabelNL)='nl').} | |||
OPTIONAL{?p rdfs:label ?pLabelEN FILTER(LANG(?pLabelEN)='en').} | |||
OPTIONAL{?p schema:description ?pDescriptionNL FILTER(LANG(?pDescriptionNL) = "nl"). } | |||
OPTIONAL{?p schema:description ?pDescriptionEN FILTER(LANG(?pDescriptionEN) = "en"). } | |||
OPTIONAL{?p skos:altLabel ?pAliasNL FILTER(LANG(?pAliasNL) = "nl"). } | |||
OPTIONAL{?p skos:altLabel ?pAliasEN FILTER(LANG(?pAliasEN) = "en"). } | |||
} | } | ||
ORDER BY ASC(xsd:integer(STRAFTER(STR(? | GROUP BY ?p ?pType ?pLabelNL ?pLabelEN ?pDescriptionNL ?pDescriptionEN ?wikidataEquivalentProperty | ||
ORDER BY ASC(xsd:integer(STRAFTER(STR(?p), 'P'))) | |||
</sparql> | </sparql> | ||
Line 64: | Line 91: | ||
ORDER BY ASC(xsd:integer(STRAFTER(STR(?item), 'Q'))) | ORDER BY ASC(xsd:integer(STRAFTER(STR(?item), 'Q'))) | ||
LIMIT 35 | LIMIT 35 | ||
</sparql> | </sparql> |
Revision as of 11:39, 30 June 2022
Examples
Overview of properties in this Wikibase, with their Labels, Descriptions and Aliases, both in NL and in EN, as well their equivalent properties in Wikidata (if applicable)
# Overview of properties in this Wikibase,
# with their Labels, Descriptions and Aliases,
# both in NL and in EN,
# as well their equivalent properties in Wikidata (if applicable)
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <https://kbtestwikibase.wikibase.cloud/prop/direct/>
SELECT ?p ?pType
?pLabelNL ?pLabelEN
?pDescriptionNL ?pDescriptionEN
(GROUP_CONCAT(DISTINCT ?pAliasNL ; separator = "|") as ?pAliasesNL )
(GROUP_CONCAT(DISTINCT ?pAliasEN ; separator = "|") as ?pAliasesEN )
?wikidataEquivalentProperty
WHERE {
?p wikibase:propertyType ?pType .
OPTIONAL{?p wdt:P1 ?wikidataEquivalentProperty.}
OPTIONAL{?p rdfs:label ?pLabelNL FILTER(LANG(?pLabelNL)='nl').}
OPTIONAL{?p rdfs:label ?pLabelEN FILTER(LANG(?pLabelEN)='en').}
OPTIONAL{?p schema:description ?pDescriptionNL FILTER(LANG(?pDescriptionNL) = "nl"). }
OPTIONAL{?p schema:description ?pDescriptionEN FILTER(LANG(?pDescriptionEN) = "en"). }
OPTIONAL{?p skos:altLabel ?pAliasNL FILTER(LANG(?pAliasNL) = "nl"). }
OPTIONAL{?p skos:altLabel ?pAliasEN FILTER(LANG(?pAliasEN) = "en"). }
}
GROUP BY ?p ?pType ?pLabelNL ?pLabelEN ?pDescriptionNL ?pDescriptionEN ?wikidataEquivalentProperty
ORDER BY ASC(xsd:integer(STRAFTER(STR(?p), 'P')))
Alle Qs in deze Wikibase
# All Qnumbers in this Wikibase
PREFIX wikibase: <http://wikiba.se/ontology#>
SELECT ?identifier ?identifierLabel ?identifierDescription ?identifierAltLabel
WHERE
{
?identifier wikibase:identifiers ?b
SERVICE wikibase:label { bd:serviceParam wikibase:language "nl". }
}
ORDER BY ASC(xsd:integer(STRAFTER(STR(?identifier), 'Q')))
Alle Ps en Qs samen
# All Ps and Qs in this Wikibase
PREFIX wikibase: <http://wikiba.se/ontology#>
SELECT ?statement ?statementLabel ?statementDescription ?statementAltLabel
WHERE
{
?statement wikibase:statements ?b
SERVICE wikibase:label { bd:serviceParam wikibase:language "nl". }
}
ORDER BY ?statement
Claim ids (GUID) for Qnumbers in this Wikibase
# Find claim ids (GUID) for Qnumbers in this Wikibase
# https://kbtestwikibase.wikibase.cloud/w/api.php?action=help&modules=wbgetclaims
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <https://kbtestwikibase.wikibase.cloud/prop/>
PREFIX ps: <https://kbtestwikibase.wikibase.cloud/prop/statement/>
SELECT ?item ?itemLabel ?itemDescription ?claim ?IsEenLabel
WHERE
{
?item wikibase:identifiers ?b.
?item p:P3 ?claim.
?claim ps:P3 ?IsEen.
SERVICE wikibase:label { bd:serviceParam wikibase:language "nl". }
}
ORDER BY ASC(xsd:integer(STRAFTER(STR(?item), 'Q')))
LIMIT 35