Help

Difference between revisions of "SPARQL/test"

< Help:SPARQLThis page is a temporary demo showcasting new support for Wikidata Query Service.

 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
=== Wikidata ===
+
{{#SUBTITLE: This page is a temporary demo showcasting new support for Wikidata Query Service.}}
 +
 
 +
== Lingualibre ==
 +
{| style="width:100%"
 +
|- style="vertical-align:top;"
 +
|style="padding: 0 3em;width:60%"|
 +
<syntaxhighlight lang="sparql">
 +
#defaultEndpoint:Lingualibre
 +
SELECT
 +
(COUNT(DISTINCT ?speaker) AS ?speakers)
 +
(COUNT(DISTINCT ?record) AS ?records)
 +
WHERE {
 +
  ?record prop:P2 entity:Q2 .
 +
  ?record prop:P6 ?date .
 +
  ?record prop:P5 ?speaker .
 +
  # Filters:
 +
  FILTER(?date >= "2018-07-01T00:00:00Z"^^xsd:dateTime)
 +
  FILTER(?date < "2019-01-01T00:00:00Z"^^xsd:dateTime)
 +
}
 +
</syntaxhighlight>
 +
||
 +
<query>
 +
#defaultEndpoint:Lingualibre
 +
SELECT
 +
(COUNT(DISTINCT ?speaker) AS ?speakers)
 +
(COUNT(DISTINCT ?record) AS ?records)
 +
WHERE {
 +
  ?record prop:P2 entity:Q2 .
 +
  ?record prop:P6 ?date .
 +
  ?record prop:P5 ?speaker .
 +
  # Filters:
 +
  FILTER(?date >= "2018-07-01T00:00:00Z"^^xsd:dateTime)
 +
  FILTER(?date < "2019-01-01T00:00:00Z"^^xsd:dateTime)
 +
}
 +
</query>
 +
|}
 +
 
 +
== Wikidata ==
 
To run on WDQS.<ref name="WDQS">https://w.wiki/6TBV</ref>
 
To run on WDQS.<ref name="WDQS">https://w.wiki/6TBV</ref>
 
{| style="width:100%"  
 
{| style="width:100%"  
Line 24: Line 61:
 
</query>
 
</query>
 
|}
 
|}
 +
 +
== Francophones ==
 +
To run on DFQS.<ref name="DFQS">https://www.dictionnairedesfrancophones.org/sparql</ref>
 +
 +
{| style="width:100%"
 +
|- style="vertical-align:top;"
 +
|style="padding: 0 3em;width:60%"|
 +
<syntaxhighlight lang="sparql">
 +
#defaultEndpoint:Francophones
 +
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
 +
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
 +
SELECT * WHERE {
 +
  ?sub ?pred ?obj .
 +
} LIMIT 10
 +
</syntaxhighlight>
 +
||
 +
<query _pagination="10">
 +
#defaultEndpoint:Francophones
 +
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
 +
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
 +
SELECT * WHERE {
 +
  ?sub ?pred ?obj .
 +
} LIMIT 10
 +
</query>
 +
|}
 +
== Issue ==
 +
See https://github.com/lingua-libre/QueryViz/pull/6#event-8827350657
  
 
== Commons ==
 
== Commons ==
Line 50: Line 114:
 
</query>
 
</query>
 
|}
 
|}
 +
 +
=== Issue ===
 +
Wikimedia Commons Query Service's end point rejects external queries :
 +
       
 +
:''Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://commons.wikimedia.org/wiki/Special:OAuth/authenticate?oauth_token=b0685605ac44eb315c2571d1a0fb43db. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 302.''
 +
   
 +
According to [[:commons:Commons:SPARQL_query_service#Release_notes]] :
 +
:''OAuth is currently not working. See https://stackoverflow.com/questions/65303450/how-to-authenticate-to-wikimedia-commons-query-service-using-oauth-in-python#comment115828158_65424900. This is so that we can contact abusive bots and/or users and block them selectively as a last resort if needed.''
 +
 +
See also [[:phab:T297995]].
  
 
== References ==
 
== References ==
 
<references />
 
<references />
 +
 +
{{technicals}}

Latest revision as of 17:45, 23 March 2023


Lingualibre

#defaultEndpoint:Lingualibre
SELECT
(COUNT(DISTINCT ?speaker) AS ?speakers)
(COUNT(DISTINCT ?record) AS ?records)
WHERE {
  ?record prop:P2 entity:Q2 .
  ?record prop:P6 ?date .
  ?record prop:P5 ?speaker .
  # Filters:
  FILTER(?date >= "2018-07-01T00:00:00Z"^^xsd:dateTime)
  FILTER(?date < "2019-01-01T00:00:00Z"^^xsd:dateTime)
}
... Loading ...

Wikidata

To run on WDQS.[1]

#defaultEndpoint:Wikidata
SELECT DISTINCT ?item ?itemLabel
WHERE {
  ?item p:P31 ?statement0.
  ?statement0 (ps:P31/(wdt:P279*)) wd:Q34228.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
}
... Loading ...

Francophones

To run on DFQS.[2]

#defaultEndpoint:Francophones
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT * WHERE {
  ?sub ?pred ?obj .
} LIMIT 10
... Loading ...

Issue

See https://github.com/lingua-libre/QueryViz/pull/6#event-8827350657

Commons

To run on WCQS.[3]

#defaultEndpoint:Commons
SELECT ?item
WHERE { 
  ?item wdt:P31 wd:Q108167708 . # Filter: P31 'instance of' Q108167708 'record'
  ?item wdt:P407 wd:Q1860 .     # Filter: P407 'language' is Q1860 'English'
  ?item wdt:P9533 "apple"@en.   # Filter: P9533 'transcription' is "apple"
}
... Loading ...

Issue

Wikimedia Commons Query Service's end point rejects external queries :

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://commons.wikimedia.org/wiki/Special:OAuth/authenticate?oauth_token=b0685605ac44eb315c2571d1a0fb43db. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 302.

According to commons:Commons:SPARQL_query_service#Release_notes :

OAuth is currently not working. See https://stackoverflow.com/questions/65303450/how-to-authenticate-to-wikimedia-commons-query-service-using-oauth-in-python#comment115828158_65424900. This is so that we can contact abusive bots and/or users and block them selectively as a last resort if needed.

See also phab:T297995.

References

Lingua Libre technical helps
Template {{Speakers category}} • {{Recommended lists}} • {{To iso 639-2}} • {{To iso 639-3}} • {{Userbox-records}} • {{Bot steps}}
Audio files How to create a frequency list?Convert files formatsDenoise files with SoXRename and mass rename
Bots Help:BotsLinguaLibre:BotHelp:Log in to Lingua Libre with PywikibotLingua Libre Bot (gh) • OlafbotPamputtBotDragons Bot (gh)
MediaWiki MediaWiki: Help:Documentation opérationelle MediawikiHelp:Database structureHelp:CSSHelp:RenameHelp:OAuthLinguaLibre:User rights (rate limit) • Module:Lingua Libre record & {{Lingua Libre record}}JS scripts: MediaWiki:Common.jsLastAudios.jsSoundLibrary.jsItemsSugar.jsLexemeQueriesGenerator.js (pad) • Sparql2data.js (pad) • LanguagesGallery.js (pad) • Gadgets: Gadget-LinguaImporter.jsGadget-Demo.jsGadget-RecentNonAudio.js
Queries Help:APIsHelp:SPARQLSPARQL (intermediate) (stub) • SPARQL for lexemes (stub) • SPARQL for maintenanceLingualibre:Wikidata (stub) • Help:SPARQL (HAL)
Reuses Help:Download datasetsHelp:Embed audio in HTML
Unstable & tests Help:SPARQL/test
Categories Category:Technical reports