Project:SPARQL/examples: Difference between revisions

From lgbtDB
Jump to navigation Jump to search
No edit summary
Line 112: Line 112:
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}
}
</sparql>
==== Instances of English-language pronoun sets with different forms ====
This query returns all instances of English-language pronoun sets with the assorted pronoun forms (subject, object, dependent possessive, independent possessive, and reflexive forms). 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 ?pronounSetLabel ?subjectLabel ?objectLabel ?dependentPossessiveLabel ?independentPossessiveLabel ?reflexiveLabel
WHERE
{
  ?pronounSet wdt:P1 wd:Q2524 .
  ?pronounSet wdt:P216 ?subject .
  ?subject ontolex:representation ?subjectLabel .
  ?pronounSet wdt:P217 ?object .
  ?object ontolex:representation ?objectLabel .
  ?pronounSet wdt:P218 ?dependentPossessive .
  ?dependentPossessive ontolex:representation ?dependentPossessiveLabel .
  ?pronounSet wdt:P219 ?independentPossessive .
  ?independentPossessive ontolex:representation ?independentPossessiveLabel .
  ?pronounSet wdt:P220 ?reflexive .
  ?reflexive ontolex:representation ?reflexiveLabel .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}
ORDER BY ?pronounSetLabel
</sparql>
</sparql>



Revision as of 16:30, 17 September 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
}

Try it!


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
}

Try it!


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
}

Try it!


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
}

Try it!


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
}

Try it!


Lexemes

Instances of lexemes returned in dictionary order

This query returns all instances of English lexemes in dictionary order. 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 ?headword ?categoryLabel { 
  ?item wikibase:lemma ?headword . # Returns the lemma as the headword for the entry
  ?item wikibase:lexicalCategory ?category . # Returns the lexical category (noun, verb, etc.)
  ?item dct:language wd:Q2 . # Returns only English-language lexemes
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
} ORDER BY ASC(UCASE(str(?headword))) # Orders the headwords in ascending order after being sent to uppercase

Try it!


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
}

Try it!


Instances of English-language pronoun sets with different forms

This query returns all instances of English-language pronoun sets with the assorted pronoun forms (subject, object, dependent possessive, independent possessive, and reflexive forms). 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 ?pronounSetLabel ?subjectLabel ?objectLabel ?dependentPossessiveLabel ?independentPossessiveLabel ?reflexiveLabel
WHERE 
{
  ?pronounSet wdt:P1 wd:Q2524 .
  ?pronounSet wdt:P216 ?subject . 
  ?subject ontolex:representation ?subjectLabel .
  ?pronounSet wdt:P217 ?object .
  ?object ontolex:representation ?objectLabel .
  ?pronounSet wdt:P218 ?dependentPossessive .
  ?dependentPossessive ontolex:representation ?dependentPossessiveLabel .
  ?pronounSet wdt:P219 ?independentPossessive .
  ?independentPossessive ontolex:representation ?independentPossessiveLabel .
  ?pronounSet wdt:P220 ?reflexive .
  ?reflexive ontolex:representation ?reflexiveLabel .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}
ORDER BY ?pronounSetLabel

Try it!


Maps

Map of instances of gay bars

This query returns all instances of gay bars (or instances of subclasses of gay bars) in the form of a map. 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/>

#defaultView:Map
SELECT ?gayBar ?gayBarLabel ?coor
WHERE
{
   ?gayBar wdt:P1/wdt:P2* wd:Q1106 . # Returns instances of gay bars or instances of subclasses of gay bars (such as lesbian bars)
   ?gayBar wdt:P638 ?coor . # Returns instances of gay bars with geographic coordinates available.
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}

Try it!


Identifiers

COEXISTENCE Thesaurus

This query returns all instances of items with at least one mapping to an identifier in the COEXISTENCE Thesaurus. 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 DISTINCT ?item ?itemLabel ?coexist
WHERE 
{
  ?item wdt:P652 ?coexist . # Returns COEXISTENCE identifiers.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}
ORDER BY xsd:integer(?coexist)

Try it!


GSSO

This query returns all instances of items with at least one mapping to an identifier in the GSSO (version 2). 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 DISTINCT ?item ?itemLabel ?gsso
WHERE 
{
  ?item wdt:P25 ?gsso . # Returns GSSO identifiers.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}

Try it!


Mappings

Mappings between all versions of the Homosaurus

This query returns all instances of items with at least one mapping to one of the versions of the Homosaurus, providing mappings between them where possible. 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 DISTINCT ?item ?itemLabel ?val_0 ?val_1 ?val_2 ?val_3
WHERE 
{
  ?item wdt:P29|wdt:P28|wdt:P27|wdt:P26 [] . # Must have a mapping to at least one of the versions of the Homosaurus available
  OPTIONAL { ?item wdt:P29 ?val_0 . } # Homosaurus Version 0
  OPTIONAL { ?item wdt:P28 ?val_1 . } # Homosaurus Version 1
  OPTIONAL { ?item wdt:P27 ?val_2 . } # Homosaurus Version 2
  OPTIONAL { ?item wdt:P26 ?val_3 . } # Homosaurus Version 3
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}

Try it!


Visualization Queries

Graphs

Subclass tree for a class entity

This query returns a graph of the subclass tree for the class of animals (Q4243). 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/>

#defaultView:Graph
SELECT ?item ?itemLabel ?linkTo {
  wd:Q4243 wdt:P2* ?item
  OPTIONAL { ?item wdt:P2 ?linkTo }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}

Try it!