-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes for CLI + Getting Started examples using DBpedia and Wikidata
Fixes for CLI * fix bundling of logging backend in binary distribution * fix initialization of default prefix Examples * GettingStartedDemo: java example * CLi: ./cli.sh -d examples/DBpediaWikidata.ttl @q examples/q_gettingStarted.txt
- Loading branch information
Andreas Schwarte
committed
May 21, 2019
1 parent
79ef7bf
commit 997c24f
Showing
7 changed files
with
89 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@prefix sd: <http://www.w3.org/ns/sparql-service-description#> . | ||
@prefix fedx: <http://www.fluidops.com/config/fedx#> . | ||
@prefix foaf: <http://xmlns.com/foaf/0.1/> . | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix owl: <http://www.w3.org/2002/07/owl#> . | ||
|
||
<http://DBpedia> a sd:Service ; | ||
fedx:store "SPARQLEndpoint"; | ||
sd:endpoint "http://dbpedia.org/sparql" ; | ||
fedx:supportsASKQueries false . | ||
|
||
<http://Wikidata> a sd:Service ; | ||
fedx:store "SPARQLEndpoint"; | ||
sd:endpoint "https://query.wikidata.org/sparql" ; | ||
fedx:supportsASKQueries false . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
PREFIX wd: <http://www.wikidata.org/entity/> | ||
PREFIX wdt: <http://www.wikidata.org/prop/direct/> | ||
SELECT * WHERE { | ||
?country a <http://dbpedia.org/class/yago/WikicatMemberStatesOfTheEuropeanUnion> . | ||
?country <http://www.w3.org/2002/07/owl#sameAs> ?countrySameAs . | ||
?countrySameAs wdt:P2131 ?gdp . | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package demos; | ||
|
||
import org.eclipse.rdf4j.query.BindingSet; | ||
import org.eclipse.rdf4j.query.TupleQuery; | ||
import org.eclipse.rdf4j.query.TupleQueryResult; | ||
import org.eclipse.rdf4j.repository.RepositoryConnection; | ||
|
||
import com.fluidops.fedx.Config; | ||
import com.fluidops.fedx.FedXFactory; | ||
import com.fluidops.fedx.repository.FedXRepository; | ||
|
||
public class GettingStartedDemo { | ||
|
||
public static void main(String[] args) { | ||
|
||
Config.initialize(); | ||
|
||
Config.getConfig().set("debugQueryPlan", "true"); | ||
|
||
FedXRepository repository = FedXFactory.newFederation() | ||
.withSparqlEndpoint("http://dbpedia.org/sparql") | ||
.withSparqlEndpoint("https://query.wikidata.org/sparql") | ||
.create(); | ||
|
||
try (RepositoryConnection conn = repository.getConnection()) { | ||
|
||
String query = | ||
"PREFIX wd: <http://www.wikidata.org/entity/> " | ||
+ "PREFIX wdt: <http://www.wikidata.org/prop/direct/> " | ||
+ "SELECT * WHERE { " | ||
+ " ?country a <http://dbpedia.org/class/yago/WikicatMemberStatesOfTheEuropeanUnion> ." | ||
+ " ?country <http://www.w3.org/2002/07/owl#sameAs> ?countrySameAs . " | ||
+ " ?countrySameAs wdt:P2131 ?gdp ." | ||
+ "}"; | ||
|
||
TupleQuery tq = conn.prepareTupleQuery(query); | ||
try (TupleQueryResult tqRes = tq.evaluate()) { | ||
|
||
int count = 0; | ||
while (tqRes.hasNext()) { | ||
BindingSet b = tqRes.next(); | ||
System.out.println(b); | ||
count++; | ||
} | ||
|
||
System.out.println("Results: " + count); | ||
} | ||
} | ||
|
||
repository.shutDown(); | ||
|
||
} | ||
|
||
} |