Toggle navigation
Home
New Query
Recent Queries
Discuss
Database tables
Database names
MediaWiki
Wikibase
Replicas browser and optimizer
Login
History
Fork
Fork of
TEST 4
by
SR5
This query is marked as a draft
This query has been published
by
SR5
.
Toggle Highlighting
SQL
//https://github.com/BorderCloud/SPARQL-JAVA import com.bordercloud.sparql.Endpoint; import java.util.ArrayList; import java.util.HashMap; public class Main { public static void main(String[] args) { try { Endpoint sp = new Endpoint("https://query.wikidata.org/sparql", false); String querySelect = "SELECT DISTINCT ?item ?label ?sitelink WHERE {\n" + " ?article schema:about ?item.\n" + " ?article schema:isPartOf <https://ar.wikipedia.org/>.\n" + " ?article schema:name ?sitelink.\n" + " ?item rdfs:label ?label.\n" + " ?item wdt:P31 wd:Q27020041.\n" + " FILTER((LANG(?label)) = \"ar\")\n" + " FILTER(?sitelink != ?label)\n" + " FILTER(\"false\"^^xsd:boolean = (CONTAINS(?sitelink, \")\")))\n" + "}"; HashMap rs = sp.query(querySelect); printResult(rs,30); }catch(EndpointException eex) { System.out.println(eex); eex.printStackTrace(); } } public static void printResult(HashMap rs , int size) { for (String variable : (ArrayList) rs.get("result").get("variables")) { System.out.print(String.format("%-"+size+"."+size+"s", variable ) + " | "); } System.out.print("\n"); for (HashMap value : (ArrayList>) rs.get("result").get("rows")) { //System.out.print(value); /* for (String key : value.keySet()) { System.out.println(value.get(key)); }*/ for (String variable : (ArrayList) rs.get("result").get("variables")) { //System.out.println(value.get(variable)); System.out.print(String.format("%-"+size+"."+size+"s", value.get(variable)) + " | "); } System.out.print("\n"); } } }
By running queries you agree to the
Cloud Services Terms of Use
and you irrevocably agree to release your SQL under
CC0 License
.
Submit Query
Stop Query
All SQL code is licensed under
CC0 License
.
Checking query status...