jena

JSON-LD blank node to nested object in Apache Jena

送分小仙女□ 提交于 2019-12-19 21:54:35
问题 I have the following example Turtle document: @prefix dct: <http://purl.org/dc/terms/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix example: <http://example.com/vocabulary/> . @prefix dcat: <http://www.w3.org/ns/dcat#> . <http://example.com/datasets/1> a dcat:Distribution ; example:props [ example:prop1 "hello" ; example:prop2 "1" ] ; dct:description "test data" . I converted it into JSON-LD with the Apache Jena (RDFDataMgr with JSONLD_COMPACT_PRETTY) to JSON-LD: { "

Parameterized SPARQL query with JENA

元气小坏坏 提交于 2019-12-19 17:37:46
问题 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

SPARQL Query “COUNT” in Virtuoso Jena API - QueryParseException

主宰稳场 提交于 2019-12-19 11:57:05
问题 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

Jena read from turtle fails

…衆ロ難τιáo~ 提交于 2019-12-19 08:05:31
问题 I have just imported jena libraries to eclipse to work on rdf-s and it is my first try, but I cannot read a turtle (.ttl) file. I tried it in the following way: import java.io.*; import java.util.*; import com.hp.hpl.jena.rdf.model.*; public class Simpsons { public static void main(String[] args) throws IOException { Model model=ModelFactory.createDefaultModel(); model.read(new FileInputStream("simpsons.ttl"),null); } } The error I get is the following: Exception in thread "main" org.apache

How I can use Fuseki with Jena TDB

三世轮回 提交于 2019-12-19 04:05:01
问题 I have a question for you. I have a triplestore "Jena TDB" and I have read that I can set up a SPARQL endpoint for locally stored RDF data. In particular, I saw that in the literature together with Jena TDB is used Fuseki. I loaded my files rdf in Jena TDB in this way: public void store(){ String directory = "C:\\tdb"; String source = "C:\\file1.rdf"; String source1 = "C:\\file2.rdf"; Dataset dataset = openTDB(directory); Model tdb = loadModel(source, dataset); dataset.addNamedModel("File1",

how can i add some triple to my Ontology by Jena?

笑着哭i 提交于 2019-12-18 13:39:24
问题 I have instance1 of class1 and instance2 of class2 . Also I have defined HasName(object property) in my ontology. Now, how can I add the triple ( instance1 HasName instance2 ) to my ontology by jena? 回答1: Here's a way without dealing with intermediate Statements . // RDF Nodes -- you can make these immutable in your own vocabulary if you want -- see Jena's RDFS, RDF, OWL, etc vocabularies Resource class1 = ResourceFactory.createResource(yourNamespace + "class1"); Resource class2 =

Using SPARQL to locate a subject with multiple occurrences of same property

笑着哭i 提交于 2019-12-18 06:54:33
问题 I am trying to use SPARQL to return triples where the same subject has multiple objects for the same property, like so: example:subject1 example:property example:object1 example:subject1 example:property example:object2 I feel like such a query should make use of property paths: SELECT ?subject WHERE { ?subject example:property{2} ?object . } I'm running this property-path query using Jena 2.6.4, but I'm not getting any results. Is this due to Jena? Or am I phrasing the query incorrectly? The

How can I easily convert RDF triples to/from an idiomatic Java POJO business object?

谁说胖子不能爱 提交于 2019-12-18 05:17:36
问题 I'm a Java developer just getting started with linked data/RDF. I can create triples, put them in a triple store, query them, etc, but it's very awkward. Most of my code is focused on the mechanics of RDF and I'd really like to work with this data in a way that's more idiomatic Java. How can I convert a POJO to/from RDF triples with Jena without hand-coding everything? I'd like something that can convert a pile of triples with a defined structure back and forth between a Java POJO and RDF.

Load DBpedia locally using Jena TDB?

梦想的初衷 提交于 2019-12-18 03:35:35
问题 I need to perform a query against DBpedia: SELECT DISTINCT ?poi ?lat ?long ?photos ?template ?type ?label WHERE { ?poi <http://www.w3.org/2000/01/rdf-schema#label> ?label . ?poi <http://www.w3.org/2003/01/geo/wgs84_pos#lat> ?lat . ?poi <http://www.w3.org/2003/01/geo/wgs84_pos#long> ?long . ?poi <http://dbpedia.org/property/hasPhotoCollection> ?photos . OPTIONAL {?poi <http://dbpedia.org/property/wikiPageUsesTemplate> ?template } . OPTIONAL {?poi <http://www.w3.org/1999/02/22-rdf-syntax-ns

Once I've written a builtin, what do I need to do to make the reasoners aware of it?

五迷三道 提交于 2019-12-17 17:05:57
问题 I have written a custom builtin to use in my Project but I do not really know how I can use it. I have written two classes. In one of them there is the builtin I have made (using BaseBuiltin ) and in the other one I have registered the new builtin (using BuiltinRegistry ). I have already tried to use default builtins, writing rules that use them in a text file readable from Eclipse using Java. In this case I do not have any problems. How can I use the builtin I have built? Should I import (or