jena

How to get a list of resources linked to a resource in Jena?

半世苍凉 提交于 2019-12-02 12:40:08
问题 I created a Model using the Jena APIs: public static void main(String[] args) { Model model = ModelFactory.createDefaultModel(); Resource alice = ResourceFactory.createResource("http://example.org/alice"); Resource bob = ResourceFactory.createResource("http://example.org/bob"); Resource charlie = ResourceFactory.createResource("http://example.org/charlie"); model.add (alice, RDF.type, FOAF.Person); model.add (alice, FOAF.name, "Alice"); model.add (alice, FOAF.mbox, ResourceFactory

Writing SPARQL queries with Jena to query for IRIs like: http://pt.dbpedia.org/

我是研究僧i 提交于 2019-12-02 12:16:14
I'm using Jena to write a SPARQL query to get the rdfs:label property from a URI received as a method parameter. That method only receives URIs like: http://pt.dbpedia.org/.. It should return me the rdfs:label , but it doesn't return me anything. I checked and it doesn't enter the while block supposed to iterate the results. I even made a test with the URI: <http://pt.dbpedia.org/resource/Brasil> , but it didn't work. What may be the problem? public String getLabel(String uri, String label) { Model model = ModelFactory.createDefaultModel().read( uri ); RDFNode node; String queryString =

errors in transaction in jena tdb?

爷,独闯天下 提交于 2019-12-02 10:11:23
I am trying to write propreties into a model and then query it.This part of mycode: String directory = "EMAILADDRESS" ; //create the dataset for the tdb store Dataset ds = TDBFactory.createDataset(directory) ; //create default rdf model ds.begin(ReadWrite.WRITE); Model model = ds.getDefaultModel() ; //write to the tdb dataset When I write this and then query the query shows no result ...but when I interchange the order of model and begin i.e. Model model = ds.getDefaultModel() ; //write to the tdb dataset ds.begin(ReadWrite.WRITE); Then it works fine!! but it sometimes gives this error: com.hp

How to generate all triples that fit a particular node type or/and edge type using SPARQL query?

自作多情 提交于 2019-12-02 10:00:50
It is a follow up question to : How to list and count the different types of node and edge entities in the graph data using SPARQL query? So assuming I have the different node entities and edge entities of a given graph, how do I go about listing all triples, given a node-edge-node pattern? And how do I generate ALL node-edge-node patterns given the node and edge entities? Example: If there is a network consisting of papers(nodes), authors(nodes), conferences(nodes), iswrittenby(edge), ispublishedin(edge), presentsin(edge) and so on , I'd have node entity type : papers authors conferences and

when i Use MySQL Database System with Jena2,i got java.lang.NoSuchMethodError

百般思念 提交于 2019-12-02 09:41:23
here is my code import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.sql.SQLException; import com.hp.hpl.jena.db.DBConnection; import com.hp.hpl.jena.db.IDBConnection; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelMaker; public class myontoly { public static final String MYSQL_DB_CLASSNAME = "com.mysql.jdbc.Driver"; public static final String MYSQL_DB_URL =

how to do reasoning in Jena via Sparql Query

拥有回忆 提交于 2019-12-02 09:31:46
I'm using Jena and Sparql to query the ontology file. I have class Tag with two subclasses : C++ and Java. class Subject with several subclasses, which stand for particular University subjects: "C++ programming","System programming", "Java programming" etc. ObjectProperty "hasTags" domain:Subject range:Tag. Each class subject has some tag like "Java", "C++" When executing query SELECT ?subject WHERE { ?subject owl:equivalentClass ?restriction . ?restriction owl:onProperty ont:hasTags . ?restriction ?restrictType ont:Java } which stands for receiving all subjects with tag "Java" I succeed. So,

SPARQL parse error with Jena, but DBpedia accepts the query

青春壹個敷衍的年華 提交于 2019-12-02 09:31:19
I'm using Jena to launch a SPARQL query. I have this code, which produces an error. I don't understand the reason for this error, since putting the query into the DBpedia SPARQL endpoint works! I think that I wrote the query string correctly. What's the error? Code String sparqlQueryString= "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "+ "select ?sub ?super (count(?mid) as ?length) where {"+ "values ?sub { <http://dbpedia.org/ontology/Writer> }" + "?sub rdfs:subClassOf* ?mid ."+ "?mid rdfs:subClassOf+ ?super .}"+ "group by (?sub ?super)"+ "order by (?length)"; query = QueryFactory

Querying named RDF graphs in TDB using tdbquery

走远了吗. 提交于 2019-12-02 09:25:27
问题 I am trying to query my newly created TDB database use the tdbquery program. However, I am having a hard time writing a query that targets the correct named graph. I am doing the following: First a create a new dataset and add a name graph called "facts" Dataset dataset = TDBFactory.createDataset("/tdb/"); dataset.begin(ReadWrite.WRITE) ; try { Model facts = RDFDataMgr.loadModel("lineitem.ttl") ; dataset.addNamedModel("facts", facts); dataset.commit(); TDB.sync(dataset); dataset.end(); }

Generating TDB Dataset from archive containing N-TRIPLES files

牧云@^-^@ 提交于 2019-12-02 09:12:30
Apologies, in advance, for a possible duplicate. I have an archive containing 117,426 files (each in the N-TRIPLES format) that I wish to load into the default graph of a TDB dataset. Due to the large number of files, I need to be able to perform this import without manually selecting individual files for upload. I am in Bash, with Jena and Fuseki distributions at my disposal. If possible, I want to avoid the worst-case scenario of just writing a java application to do this. If I have to write a java application for this, what hooks exist in RIOT/TDB to perform programmatic bulk-loading? As a

How do I start a Fuseki server from Jena API Eclipse project?

戏子无情 提交于 2019-12-02 08:53:30
Hi I am new to the Semantic Web domain and Apache Jena enviroments too, which is why I am posting this question. I have a project that makes use of Jena API. And when I run it, it shows output in the console. I did run Fuseki server from cmd line and it ran as a local server and I could do some playing around with queries and all that. My question is, is it possible to run the project on the server through my project that makes use of the API, and if so, why it should be done? I am confused as to the reason why we have a Fuseki server but aren't starting it through the API. Like any java