Project:Sample queries: Difference between revisions

From MaRDI portal
Created page with "== About == This page is meant to provide example queries for users of the SPARQL endpoint at [https://query.portal.mardi4nfdi.de/ https://query.portal.mardi4nfdi.de/]. The ticket [https://phabricator.wikimedia.org/T387064 https://phabricator.wikimedia.org/T387064 ] tracks progress in this regard. == Local SPARQL queries == === DLMF formulas that depend indirectly on the gamma function === {{SPARQL| query= #title: DLMF formulas that depend indirectly on the gamma func..."
 
No edit summary
Tag: Reverted
Line 2: Line 2:


This page is meant to provide example queries for users of the SPARQL endpoint at [https://query.portal.mardi4nfdi.de/ https://query.portal.mardi4nfdi.de/]. The ticket [https://phabricator.wikimedia.org/T387064 https://phabricator.wikimedia.org/T387064 ] tracks progress in this regard.
This page is meant to provide example queries for users of the SPARQL endpoint at [https://query.portal.mardi4nfdi.de/ https://query.portal.mardi4nfdi.de/]. The ticket [https://phabricator.wikimedia.org/T387064 https://phabricator.wikimedia.org/T387064 ] tracks progress in this regard.
=== Cats ===
This query looks at all items whose value of {{P|P31}} is {{Q|Q146}}. It uses the service wikibase:label to return the labels in your default language or in English.
{{SPARQL|query=SELECT ?item ?itemLabel
WHERE
{
  ?item wdt:P31 wd:Q146. # <translate><!--T:680--> Must be a cat</translate>
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } # <translate><!--T:681--> Helps get the label in your language, if not, then <tvar name="1">{{int:wikibase-language-name-for-terms-mul}}</tvar>, then en language</translate>
}
}}


== Local SPARQL queries ==
== Local SPARQL queries ==

Revision as of 15:22, 23 June 2025

About

This page is meant to provide example queries for users of the SPARQL endpoint at https://query.portal.mardi4nfdi.de/. The ticket https://phabricator.wikimedia.org/T387064 tracks progress in this regard.

Cats

This query looks at all items whose value of Template:P is Template:Q. It uses the service wikibase:label to return the labels in your default language or in English.

SELECT ?item ?itemLabel
WHERE
{
  ?item wdt:P31 wd:Q146. # <translate> Must be a cat</translate>
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } # <translate> Helps get the label in your language, if not, then <tvar name="1">default for all languages</tvar>, then en language</translate>
}
¡Pruébalo! (es) / Próbáld ki! (hu) / ¡Pruébalo! (ast) / Prova-ho! (ca) / Es kann versucht werden! (de-ch) / Ceisio! (cy) / Try it! (en-gb) / Փորձի՛ր (hy) / 试一试! (zh) / Prøv det! (da) / Deneyin! (tr) / 試す! (ja) / Testa! (sv) / Versuchen Sie es! (de-formal) / 試一試! (zh-hant) / Versuche es! (de) / Kokeile! (fi) / Δοκιμάστε το! (el) / Provu ĝin! (eo) / Zkuste to! (cs) / Isprobajte! (bs) / Provalo! (it) / এটি চেষ্টা করে দেখুন! (bn) / Essayez ! (fr) / پرشن کرو (pnb) / Паспрабуйце! (be-tarask) / de-at (1) / Виконати! (uk) / לנסות את זה! (he) / SPARQL 쿼리 실행하기 (ko) / Biceribîne! (ku) / Probeer! (nl) / Experimenta! (pt) / ਪ੍ਰਸ਼ਨ ਕਰੋ (pa) / Izmēģini! (lv) / Prøv sjølv (nn) / Испробајте! (sr) / Cobalah! (id) / Пробајте! (mk) / Experimente! (pt-br) / جالنکن! (ms-arab) / ทดลองใช้ (th) / Wypróbuj! (pl) / Prøv selv! (nb) / 試試看! (zh-tw) / Jalankan! (ms) / Încercați! (ro) / Выполнить запрос (ru) / Provoje (sq) / Try it! (en) / تجربة! (ar) / 试一试! (zh-hans) / Оскалтэ! (udm)

Local SPARQL queries

DLMF formulas that depend indirectly on the gamma function

#title: DLMF formulas that depend indirectly on the gamma function

PREFIX wdt: <https://portal.mardi4nfdi.de/prop/direct/>
PREFIX wd: <https://portal.mardi4nfdi.de/entity/>

SELECT (?dep2nd as ?qid) ?dlmfid ?definesLabel ?formula
WHERE {
  ?item wdt:P4 wd:Q1818 .
         ?item wdt:P3 ?defines .
       ?dep2nd wdt:P4 ?defines 
       FILTER( NOT EXISTS { ?dep2nd wdt:P4 wd:1818.})
         OPTIONAL{?dep2nd wdt:P2 ?dlmfid .}
                OPTIONAL{?dep2nd wdt:P14 ?formula .}      
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }

      }
Limit 10
DLMF formulas that depend indirectly on the gamma function

Federated SPARQL queries

Federation within MaRDI

Federation with NFDI knowledge graphs outside MaRDI

Street addresses of historic mathematicians in Paris

#title: Street addresses of historic mathematicians in Paris
# This federated query combines data from 
# https://query.portal.mardi4nfdi.de (the MaRDI portal's knowledge graph)
# and 
# https://database.factgrid.de (NFDI4Memory's FactGrid)

#defaultView:Map

# MaRDI-related prefixes
PREFIX wdt: <https://portal.mardi4nfdi.de/prop/direct/>
PREFIX wd: <https://portal.mardi4nfdi.de/entity/>

# FactGrid-related prefixes
PREFIX factgrid_wd: <https://database.factgrid.de/entity/>
PREFIX factgrid_wdt: <https://database.factgrid.de/prop/direct/>

SELECT DISTINCT 
  ?factgrid_mathematician ?factgrid_mathematicianLabel ?factgrid_addressLabel ?factgrid_coord 
  ?mardi_person ?mardi_personLabel 
WHERE {
  ?mardi_person wdt:P316 ?mardi_factgrid_item_id .

  # mapping between MaRDI and FactGrid
  BIND(URI(CONCAT("https://database.factgrid.de/entity/", ?mardi_factgrid_item_id)) AS ?factgrid_mathematician)

  # start of federation to FactGrid 
  SERVICE <https://database.factgrid.de/sparql> {

    SELECT ?factgrid_mathematician ?factgrid_mathematicianLabel ?factgrid_addressLabel ?factgrid_coord
    WHERE {
      ?factgrid_mathematician factgrid_wdt:P2 factgrid_wd:Q7;       # person
                              factgrid_wdt:P208 ?factgrid_address.  # address
      ?factgrid_address factgrid_wdt:P48 ?factgrid_coord;           # geocoordinates
                        factgrid_wdt:P47 factgrid_wd:Q10441 .       # place: Paris
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } 
    }
    LIMIT 100

  }
  # end of federation to FactGrid 

  BIND(?factgrid_mathematicianLabel AS ?mathematicianLabel)

  BIND(STR(CONCAT("mardi: ", STR(?mathematicianLabel))) AS ?mardi_personLabel)  
}
Street addresses of historic mathematicians in Paris

Federation beyond NFDI

Federation with Wikidata