jena

Parameterized SPARQL query with JENA

纵然是瞬间 提交于 2019-12-01 17:27:04
I'm trying to build a small semantic web application using Jena framework, JSP and JAVA. I have a remote SPARQL endpoint and I've already written a simple query which works fine but now I need to use some parameters. Here is my code so far: final static String serviceEndpoint = "http://fishdelish.cs.man.ac.uk/sparql/"; String comNameQuery = "PREFIX fd: <http://fishdelish.cs.man.ac.uk/rdf/vocab/resource/> " + "SELECT ?name ?language ?type" + "WHERE { ?nameID fd:comnames_ComName ?name ;" + "fd:comnames_Language ?language ;" + "fd:comnames_NameType ?type ." + "}"; Query query = QueryFactory

tbloader vs SPARQL INSERT - Why different behaviour with named graphs?

心不动则不痛 提交于 2019-12-01 17:14:49
问题 There is a strange behaviour in the connection of the commandline tools of ARQ, TDB and Named Graphs. If importing data via tdbloader in a named graph it can not be queried via GRAPH clause in a SPARQL SELECT query. However, this query is possible when inserting the data in the same graph with SPARQL INSERT. I have following assembler description file tdb.ttl : @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix ja:

SPARQL Query “COUNT” in Virtuoso Jena API - QueryParseException

本小妞迷上赌 提交于 2019-12-01 13:59:50
Same query works in DBpedia Endpoint( http://ko.dbpedia.org/sparql ), but not in my Java code. I am just trying to extract the frequency using "COUNT" function. VirtGraph set = new VirtGraph("http://ko.dbpedia.org", HOST, USERNAME, PASSWORD); Query freqsparql = QueryFactory.create("SELECT ?class count(distinct ?s) as ?count where{?s <http://ko.dbpedia.org/property/이름> ?o. ?s a ?class.} order by DESC(?count)"); VirtuosoQueryExecution freqvqe = VirtuosoQueryExecutionFactory.create(freqsparql, set); ResultSet freqresults = freqvqe.execSelect(); And the error is as follows. Exception in thread

Why some rdf files does not contain <rdf:Description rdf:about=…>?

别说谁变了你拦得住时间么 提交于 2019-12-01 13:37:28
I'm using Jena to write a rdf file that describes online posts. According to the sioc ontology/namespace that I'm using there is, for instance, the following: Class: sioc:Post Property: sioc:has_creator How can I, in Jena, include the sioc:Post in the file as <sioc:Post rdf:about="http://example.com/vb/1035092"> instead of <rdf:Description rdf:about="http://example.com/vb/1035092"> and what is the best practice? Joshua Taylor Both of the answers so far make good points: You should not pay much attention to the particular serialization of your RDF graph, because there are lots of different

How I can load a model in TDB TripleStore

独自空忆成欢 提交于 2019-12-01 11:33:55
问题 I have a question for you: I would like to load a file on my Jena TDB TripleStore. My file is very big, about 80Mb and about 700000 triples RDF. When I try to load it, the execution stops working or takes a very long time. I'm using this code that I do run on a Web Service: String file = "C:\\file.nt"; String directory; directory = "C:\\tdb"; Dataset dataset = TDBFactory.createDataset(directory); Model model = ModelFactory.createDefaultModel(); TDBLoader.loadModel(model, file ); dataset

Configure Eclipse for Log4j

喜欢而已 提交于 2019-12-01 11:12:49
I am working on an application using apache jena, to access dbpedia using sparql. Well I am very new to DBPedia and apache jena, I did some research and started with some sample code to create VCARD. public class DpPedia extends Object { static String personURI = "<!..http://def/JohnSmith..!>"; static String fullName = "John Smith"; static String Fullname = "Pulkit Gupta"; public static void main (String args[]) { // create an empty model Model model = ModelFactory.createDefaultModel(); // create the resource Resource johnSmith = model.createResource(personURI); Resource pulkitgupta=model

Configure Eclipse for Log4j

烂漫一生 提交于 2019-12-01 07:31:50
问题 I am working on an application using apache jena, to access dbpedia using sparql. Well I am very new to DBPedia and apache jena, I did some research and started with some sample code to create VCARD. public class DpPedia extends Object { static String personURI = "<!..http://def/JohnSmith..!>"; static String fullName = "John Smith"; static String Fullname = "Pulkit Gupta"; public static void main (String args[]) { // create an empty model Model model = ModelFactory.createDefaultModel(); //

Jena Sparql and construct

天大地大妈咪最大 提交于 2019-12-01 06:46:16
CONSTRUCT is an alternative SPARQL result clause to SELECT . Instead of returning a table of result values, CONSTRUCT returns an RDF graph. For instance, running this query in the following Java code produces an HttpException: 406 Unacceptable . But if instead of the CONSTRUCT block, I choose SELECT ?x , it's just fine. Does Jena support CONSTRUCT , and if so, how? Both queries are acceptable to the DBpedia endpoint . PREFIX : <http://dbpedia.org/resource/> PREFIX onto: <http://dbpedia.org/ontology/> CONSTRUCT { :France onto:anthem ?x } WHERE { :France onto:anthem ?x . } Query query =

Jena Sparql and construct

南笙酒味 提交于 2019-12-01 04:51:39
问题 CONSTRUCT is an alternative SPARQL result clause to SELECT . Instead of returning a table of result values, CONSTRUCT returns an RDF graph. For instance, running this query in the following Java code produces an HttpException: 406 Unacceptable . But if instead of the CONSTRUCT block, I choose SELECT ?x , it's just fine. Does Jena support CONSTRUCT , and if so, how? Both queries are acceptable to the DBpedia endpoint. PREFIX : <http://dbpedia.org/resource/> PREFIX onto: <http://dbpedia.org

SPARQL Querying Transitive

依然范特西╮ 提交于 2019-12-01 03:29:46
I am a beginner to SPARQL and was wondering if there was a query which could help me return transitive relations. For example the n3 file below I would want a query that would return "a is the sameas c" or something along those lines. Thanks @prefix : <http://websitename.com/links/> . @prefix owl: <http://www.w3.org/2002/07/owl#> . :a owl:sameas :b. :b owl:sameas :c. You can use property paths if you are using a suitably enabled SPARQL 1.1 engine, you've tagged your question Jena so I assume you are using its ARQ engine which supports this feature. So you can write a query like the following: