SPARQL examples: Difference between revisions
From MBI
No edit summary |
No edit summary |
||
Line 79: | Line 79: | ||
OPTIONAL { ?propertyWikibase skos:altLabel ?propertyAlias. } | OPTIONAL { ?propertyWikibase skos:altLabel ?propertyAlias. } | ||
} | } | ||
}} | |||
=== Properties with non-capitalized labels and their datatypes === | |||
{{SPARQL|query= | |||
SELECT DISTINCT ?propertyWikibase ?propertyLabel ?propertyType WHERE { | |||
?propertyWikibase wikibase:directClaim ?p; | |||
wikibase:propertyType ?propertyType; | |||
rdfs:label ?propertyLabel. | |||
FILTER(REGEX(?propertyLabel, "[a-z].+")) | |||
OPTIONAL { ?propertyWikibase skos:altLabel ?propertyAlias. } | |||
} | |||
} | |||
=== Properties with capitalized labels and their datatypes === | |||
{{SPARQL|query= | |||
SELECT DISTINCT ?propertyWikibase ?propertyLabel ?propertyType WHERE { | |||
?propertyWikibase wikibase:directClaim ?p; | |||
wikibase:propertyType ?propertyType; | |||
rdfs:label ?propertyLabel. | |||
FILTER(!REGEX(?propertyLabel, "[a-z].+")) | |||
OPTIONAL { ?propertyWikibase skos:altLabel ?propertyAlias. } | |||
} | |||
} | |||
}} | }} |
Revision as of 15:20, 26 April 2023
Companies
Companies with labels, inception, Postscheckkonto, Fernruf and Drahtanschrift
SELECT DISTINCT ?company ?companyLabel (year(?inc) as ?inception) ?POSTSCHECKKONTO ?FERNRUF ?DRAHTANSCHRIFT WHERE {
?company rdfs:label ?companyLabel;
wdt:P3 wd:Q1.
OPTIONAL { ?company wdt:P46 ?inc. }
OPTIONAL { ?company wdt:P7 ?POSTSCHECKKONTO. }
OPTIONAL { ?company wdt:P8 ?FERNRUF. }
OPTIONAL { ?company wdt:P9 ?DRAHTANSCHRIFT. }
FILTER((LANG(?companyLabel)) = "de")
}
Companies with labels, Inhaber, Geschäftsführer and Bankverbindungen
SELECT DISTINCT ?company ?companyLabel ?INHABER ?GESCHÄFTSFÜHRER ?BANKVERBINDUNGEN WHERE {
?company rdfs:label ?companyLabel;
wdt:P3 wd:Q1.
OPTIONAL { ?company wdt:P12 ?INHABER. }
OPTIONAL { ?company wdt:P18 ?GESCHÄFTSFÜHRER. }
OPTIONAL { ?company wdt:P10 ?BANKVERBINDUNGEN. }
FILTER((LANG(?companyLabel)) = "de")
}
Companies with labels, raw texts and file segments
SELECT DISTINCT ?company ?companyLabel ?RAW_TEXT ?FILE_SEGMENT WHERE {
?company rdfs:label ?companyLabel;
wdt:P3 wd:Q1;
wdt:P4 ?RAW_TEXT;
wdt:P5 ?FILE_SEGMENT.
FILTER((LANG(?companyLabel)) = "de")
}
Companies with labels, Postscheckkonto, Fernruf, Drahtanschrift and inception in time interval 1905-1910
SELECT DISTINCT ?company ?companyLabel (YEAR(?inc) AS ?inception) ?POSTSCHECKKONTO ?FERNRUF ?DRAHTANSCHRIFT WHERE {
?company rdfs:label ?companyLabel;
wdt:P3 wd:Q1.
OPTIONAL { ?company wdt:P46 ?inc. }
FILTER(?inc >= "1905-01-01T00:00:00Z"^^xsd:dateTime)
FILTER(?inc <= "1910-01-01T00:00:00Z"^^xsd:dateTime)
OPTIONAL { ?company wdt:P7 ?POSTSCHECKKONTO. }
OPTIONAL { ?company wdt:P8 ?FERNRUF. }
OPTIONAL { ?company wdt:P9 ?DRAHTANSCHRIFT. }
FILTER((LANG(?companyLabel)) = "de")
}
Entities
Entities with labels
SELECT DISTINCT ?entity ?entityLabel WHERE {
?entity rdfs:label ?entityLabel.
FILTER((LANG(?entityLabel)) = "en")
}
Properties
Properties with labels, aliases, descriptions and datatypes
SELECT DISTINCT ?propertyWikibase ?propertyLabel ?propertyAlias ?propertyDescription ?propertyType WHERE {
?propertyWikibase wikibase:directClaim ?p;
wikibase:propertyType ?propertyType;
schema:description ?propertyDescription;
rdfs:label ?propertyLabel.
OPTIONAL { ?propertyWikibase skos:altLabel ?propertyAlias. }
}
Properties with non-capitalized labels and their datatypes
{{SPARQL|query= SELECT DISTINCT ?propertyWikibase ?propertyLabel ?propertyType WHERE {
?propertyWikibase wikibase:directClaim ?p; wikibase:propertyType ?propertyType; rdfs:label ?propertyLabel. FILTER(REGEX(?propertyLabel, "[a-z].+")) OPTIONAL { ?propertyWikibase skos:altLabel ?propertyAlias. }
} }
Properties with capitalized labels and their datatypes
SELECT DISTINCT ?propertyWikibase ?propertyLabel ?propertyType WHERE {
?propertyWikibase wikibase:directClaim ?p;
wikibase:propertyType ?propertyType;
rdfs:label ?propertyLabel.
FILTER(!REGEX(?propertyLabel, "[a-z].+"))
OPTIONAL { ?propertyWikibase skos:altLabel ?propertyAlias. }
}
}