Project:SPARQL/examples: Difference between revisions
Superraptor (talk | contribs) No edit summary |
Superraptor (talk | contribs) No edit summary |
||
Line 83: | Line 83: | ||
=== Lexemes === | === Lexemes === | ||
==== Instances of lexemes derived from a particular lexeme ==== | |||
This query returns all instances of lexemes wherein at least one of the indicated etyma is the lexeme 'queen' (L127). It uses the service wikibase:label to return the labels in your default language or in English. | |||
<sparql tryit="1">PREFIX wd: <https://lgbtdb.wikibase.cloud/entity/> | |||
PREFIX wdt: <https://lgbtdb.wikibase.cloud/prop/direct/> | |||
SELECT ?l ?lemma ?languageLabel | |||
WHERE | |||
{ | |||
?l a ontolex:LexicalEntry; # Indicates that the entity is of the type lexical entry | |||
dct:language ?language; # Returns the language | |||
wikibase:lemma ?lemma . # Returns the lemma | |||
?l wdt:P32 wd:L127. # Returns all lexemes with an etymon for 'queen' indicated. | |||
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language | |||
} | |||
</sparql> | |||
[[Category:Query Service]] | [[Category:Query Service]] |
Revision as of 15:15, 24 August 2024
This page is parsed by the web interface of the query service to fill the query example dialog. For general examples and their explanations, please see here.
Simple Queries
Instances
Instances of gender identities
This query returns all instances of gender identities in lgbtDB. It uses the service wikibase:label to return the labels in your default language or in English.
PREFIX wd: <https://lgbtdb.wikibase.cloud/entity/>
PREFIX wdt: <https://lgbtdb.wikibase.cloud/prop/direct/>
SELECT ?item ?itemLabel
WHERE
{
?item wdt:P1 wd:Q10639 . # Must be a gender identity
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}
Instances of romantic orientations
This query returns all instances of romantic orientations in lgbtDB. It uses the service wikibase:label to return the labels in your default language or in English.
PREFIX wd: <https://lgbtdb.wikibase.cloud/entity/>
PREFIX wdt: <https://lgbtdb.wikibase.cloud/prop/direct/>
SELECT ?item ?itemLabel
WHERE
{
?item wdt:P1 wd:Q226 . # Must be a romantic orientation
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}
Instances of sexual orientations
This query returns all instances of sexual orientations in lgbtDB. It uses the service wikibase:label to return the labels in your default language or in English.
PREFIX wd: <https://lgbtdb.wikibase.cloud/entity/>
PREFIX wdt: <https://lgbtdb.wikibase.cloud/prop/direct/>
SELECT ?item ?itemLabel
WHERE
{
?item wdt:P1 wd:Q10638 . # Must be a sexual orientation
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}
Instances of websites
This query returns all instances of websites in lgbtDB. It uses the service wikibase:label to return the labels in your default language or in English.
PREFIX wd: <https://lgbtdb.wikibase.cloud/entity/>
PREFIX wdt: <https://lgbtdb.wikibase.cloud/prop/direct/>
SELECT ?item ?itemLabel
WHERE
{
?item wdt:P1 wd:Q179 . # Must be a website
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}
Subclasses
Dates
Instances of real-life people with a birth or death date available
This query returns all instances of real-life (human) persons with a birth or death date available. It uses the service wikibase:label to return the labels in your default language or in English.
PREFIX wd: <https://lgbtdb.wikibase.cloud/entity/> PREFIX wdt: <https://lgbtdb.wikibase.cloud/prop/direct/>
PREFIX wd: <https://lgbtdb.wikibase.cloud/entity/>
PREFIX wdt: <https://lgbtdb.wikibase.cloud/prop/direct/>
SELECT DISTINCT ?item ?itemLabel ?bdate ?ddate
WHERE
{
?item wdt:P1 wd:Q8775 . # Must be a human person (a real-life person)
?item wdt:P141|wdt:P142 [] . # Must have a birthdate or deathdate available
OPTIONAL { ?item wdt:P141 ?bdate . } # Date of birth
OPTIONAL { ?item wdt:P142 ?ddate . } # Date of death
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}
Lexemes
Instances of lexemes derived from a particular lexeme
This query returns all instances of lexemes wherein at least one of the indicated etyma is the lexeme 'queen' (L127). It uses the service wikibase:label to return the labels in your default language or in English.
PREFIX wd: <https://lgbtdb.wikibase.cloud/entity/>
PREFIX wdt: <https://lgbtdb.wikibase.cloud/prop/direct/>
SELECT ?l ?lemma ?languageLabel
WHERE
{
?l a ontolex:LexicalEntry; # Indicates that the entity is of the type lexical entry
dct:language ?language; # Returns the language
wikibase:lemma ?lemma . # Returns the lemma
?l wdt:P32 wd:L127. # Returns all lexemes with an etymon for 'queen' indicated.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}