Addshore closed this task as "Resolved".
Addshore added a comment.
// https://github.com/eclipse/rdf4j
import org.eclipse.rdf4j.query.resultio.sparqljson.SPARQLResultsJSONWriter;
import org.eclipse.rdf4j.repository.RepositoryException;
import org.eclipse.rdf4j.repository.sparql.SPARQLRepository;
import java.util.Collections;
/**
* Wikidata RDF4J SPARQL example
*/
public class App
{
public static void main( String[] args )
{
String sparqlEndpoint = "https://query.wikidata.org/sparql";
SPARQLRepository repo = new SPARQLRepository(sparqlEndpoint);
String userAgent = "Wikidata RDF4J Java Example/0.1
(https://query.wikidata.org/)";
repo.setAdditionalHttpHeaders(
Collections.singletonMap("User-Agent", userAgent ) );
String querySelect = "#Cats\n" +
"SELECT ?item ?itemLabel \n" +
"WHERE \n" +
"{\n" +
" ?item wdt:P31 wd:Q146.\n" +
" SERVICE wikibase:label { bd:serviceParam
wikibase:language \"[AUTO_LANGUAGE],en\". }\n" +
"}";
try{
repo.getConnection().prepareTupleQuery(querySelect).evaluate(new
SPARQLResultsJSONWriter(System.out));
} catch ( Exception exception ) {
exception.printStackTrace();
}
}
}
TASK DETAIL
https://phabricator.wikimedia.org/T259900
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: toan, Addshore
Cc: Addshore, Ladsgroup, Manuel, Lucas_Werkmeister_WMDE, Aklapper, Biggs657,
Invadibot, Lalamarie69, MPhamWMF, maantietaja, Juan90264, Alter-paule,
Beast1978, CBogen, Un1tY, Akuckartz, Hook696, Iflorez, Kent7301, alaa_wmde,
joker88john, CucyNoiD, Nandana, Namenlos314, Gaboe420, Giuliamocci, Cpaulf30,
Lahi, Gq86, Af420, Bsandipan, GoranSMilovanovic, Mahir256, QZanden, EBjune,
merbst, LawExplorer, Salgo60, Lewizho99, Maathavan, _jensen, rosalieper,
Scott_WUaS, Jonas, Xmlizer, jkroll, Wikidata-bugs, Jdouglas, aude, Tobias1984,
Manybubbles, Lydia_Pintscher, Mbch331
_______________________________________________
Wikidata-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]