jena

Add text search where clause to SPARQL query

不羁岁月 提交于 2019-12-07 05:17:30
问题 I have been given what I thought would be a simple task - take an existing SPARQL query and adapt the WHERE clause to restrict results to entities where a specific text field contains a specific search term. However, I am entirely new to the SPARQL language and nothing I've tried is working. It seems I need to use the text:query (rdfs:label 'word' 10) syntax, but I haven't managed to successfully integrate this into the query below. What I need is to further filter the results of the below

How to get all of the subjects of a Jena Query?

本秂侑毒 提交于 2019-12-06 23:55:34
问题 Suppose I have some jena query object : String query = "SELECT * WHERE{ ?s <some_uri> ?o ...etc. }"; Query q = QueryFactory.create(query, Syntax.syntaxARQ); What would be the best way to get all of the subjects of the triples in the query? Preferably without having to do any string parsing/manipulation manually. For example, given a query SELECT * WHERE { ?s ?p ?o; ?p2 ?o2. ?s2 ?p3 ?o3. ?s3 ?p4 ?o4. <http://example.com> ?p5 ?o5. } I would hope to have returned some list which looks like [?s,

Query Jena TDB store

限于喜欢 提交于 2019-12-06 22:54:36
I'm trying to query jena TDB in java. My code follows. It seems that my TDB dataset is empty because model.size() (where model is the dataset default model) return 0. I'm sure it isn't empty, though, because I can query it with Fuseki with my sparqlEndpoint. String directory = "//var//www//fuseki//TDB" ; Dataset dataset = TDBFactory.createDataset(directory) ; Model model = dataset.getDefaultModel(); String sparqlQueryString = "SELECT (count(*) AS ?count) { ?s ?p ?o }" ; Query query = QueryFactory.create(sparqlQueryString) ; QueryExecution qexec = QueryExecutionFactory.create(query, model);

How to turn a SPARQL/SPIN query/rule into an RDF structure from Java?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 16:15:09
问题 I have been using TopQuadrant Composer Free Edition (TBC FE) to embed SPARQL/SPIN rules (primarily SPIN constructors) in my OWL ontologies stored as RDF. Part of this process is that the SPARQL source code is tokenized/encoded in an RDF structure according to http://spinrdf.org/sp.html which the schema specified in http://spinrdf.org/sp. It is this structure that actually gets interpreted by RDF4J to run the SPIN rules. I'm also using RDF4J as my triple store, reasoner, SPARQL endpoint, and

how to use cidoc-crm in jena

这一生的挚爱 提交于 2019-12-06 15:38:44
Recently, I'm trying to approach semantic web using Jena to create RDF and make query. Now, I have successfully made a owl based RDF file in Jena. However, when I trying to use different ontologies (such as: cidoc-crm), I do not know how to import those ontologies to Jena. Does anyone know how to import them to Jena? Do I need to create a new ontology model? Jena's OntModel interface provides a convenient way of working with ontologies (including RDFS ontologies). The following code shows how you can get an OntModel that contains the data of the ontology. In this code, I then create another

Problems with inference examples from Apache Jena framework

帅比萌擦擦* 提交于 2019-12-06 14:46:21
I have a serious problem to get any reasoner up and running. Also the examples from the documentation: https://jena.apache.org/documentation/inference/ does not work here. I transferred the example into a unit test, so that the problem might be easier reproduced. Is reasoning limited to certain environment like a spatial JDK or so on, or am i getting something wrong? Thanks Here the example code (as java unit test): import static org.junit.Assert.assertNotNull; import java.io.PrintWriter; import java.util.Iterator; import org.junit.Before; import org.junit.Test; import com.hp.hpl.jena.rdf

Retrieving all paths in an OWL class hierarchy with SPARQL and Jena

丶灬走出姿态 提交于 2019-12-06 11:17:02
问题 I have an RDF graph of with a hierarchy three levels deep. I want to retrieve all the paths starting from the root of the class hierarchy (i.e., owl:Thing ) down to classes in the third level without using a reasoner. For instance, I would like the path C 1 &rightarrow; C 2 &rightarrow; C 3 is a path, where each C i is a class at the i th level of the hierarchy. I need to retrieve all the paths in the RDF graph using the breadth first search algorithm with no considerations to the object

Can I configure Jena Fuseki with inference and TDB?

孤街醉人 提交于 2019-12-06 10:39:37
I want to configure Fuseki with an inference model supported by TDB. I have been able to configure it with a Memory Model, but not with a TDB Model where I could update triples. I am using the following assembler description: @prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> . @prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> . [] ja:loadClass "com.hp.hpl.jena.tdb.TDB" . tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset . tdb

ontology with java(jena)

…衆ロ難τιáo~ 提交于 2019-12-06 09:51:14
I'm doing some project which is based on ontology.I want to identify semantic of the text that has entered by user. Is there any possible way to fulfill my task dealing with ontology through jena? Jena doesn't do Natural Language Processing. You want to look at APIs like Zemanta or OpenCalais , or tools like GATE . kurzum You might be looking for something like this: http://nlp2rdf.org The other answers are still correct: Jena is not NLP. But with NLP2RDF you can query NLP tool output with Jena . 来源: https://stackoverflow.com/questions/2919095/ontology-with-javajena

Can't PREFIX hierarchies with SPARQL

一笑奈何 提交于 2019-12-06 08:52:40
问题 I have a need to represent a hierarchy in my URL's like this: http://www.me.org/ -----------------root1/ -----------------------level1/ ------------------------------level2/etc I want to define PREFIX's and used them in a SPARQL query like this: PREFIX root1: <http://www.me.org/root1/> select * where { ?s ?p root1:level1/level2/etc . } limit 100 This will fail in ARQ with the following error: Encountered " "/" "/ "" at line 10, column 43. Was expecting one of: "values" ... "graph" ... ...