jena

Jena alternative of ModelBuilder in RDF4J

风流意气都作罢 提交于 2019-12-11 16:45:48
问题 Is there some Interface available in Apache Jena like ModelBuilder in RDF4J? I can see ModelMaker in Jena but that is not something similar to builder I suppose. Following is the function using rdf4j that need to be implemented in Jena: public static org.eclipse.rdf4j.model.Model convertGraph2RDFModel(Graph graph, String label) { ModelBuilder builder = new ModelBuilder(); GraphTraversalSource t = graph.traversal(); GraphTraversal<Vertex, Vertex> hasLabel = t.V().hasLabel(label); Vertex s; if

getLiteral returns null when reading RDF file using jena

别说谁变了你拦得住时间么 提交于 2019-12-11 16:45:33
问题 I have been reading about OWL ontology and RDF files all these days. I still can't understand this. Let's say I created a simple ontology using Protege. It has single class called Review with two data properties which are comment and rating. Now I want to create a separate RDF file written in xml which has some comments. The file I created look like <?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:c

Query DBpedia to get abstract for different inputs

空扰寡人 提交于 2019-12-11 16:26:09
问题 I have a question I need to build a single query to DBpedia such that, If I give any one of these as input like a City name or a person name or a Institute name or a Instrument name can I get its abstract as a output??? For instance, New York- New York is a state in the Northeastern and Mid-Atlantic regions of the United States...... Mars- Mars is the fourth planet from the Sun and the second smallest planet in the Solar System.... Michael Jackson- Michael Joseph Jackson was an American

Generating Jena Bnode IDs

喜夏-厌秋 提交于 2019-12-11 15:13:31
问题 Is there a way to override Jena's default method for generating anonymous node IDs? Ideally, I'd like to pass Jena a functor that would generate IDs so that I can make them globally unique (rather than just unique to the machine). The functor should be used whenever an AnonId is constructed. public interface IdGenerator { public String createId() { // create a globally unique ID ... return uid; } } This is somewhat related to my previous question. Edit : I realize that AnonId has a

tdbloader2 fails with classpath error

邮差的信 提交于 2019-12-11 14:56:34
问题 When I run the following command: bin/tdbloader2 --loc=/store/data/here /seed/data/serverfault-dump.nt And the response I get is: 10:52:31 -- TDB Bulk Loader Start 10:52:31 Data phase Error: Could not find or load main class com.hp.hpl.jena.tdb.store.bulkloader2.CmdNodeTableBuilder Which is most likely caused by a problem with my environment variables, somewhere, of something. The problem is, I don't often work with Java and so I don't know enough to know how to figure out what that class

Jena TDB , see how many triple stored during tdb creation

 ̄綄美尐妖づ 提交于 2019-12-11 14:25:19
问题 Hi is possible to see the number of triple in storing during tdb creation with java api? I run the TDB factory with a rar file in turtle , but during the creation of files in my directory i cant see how many triple it has stored. How can i solve this problem? 回答1: You can access the bulk-loader through java code (to view triples introduced) as follows: final Dataset tdbDataset = TDBFactory.createDataset( /*location*/ ); try( final InputStream in = /*get input stream for your large file*/) {

Jena TDB after reason then update

让人想犯罪 __ 提交于 2019-12-11 13:44:18
问题 I am using Jena and I want to update the new ontology into my tdb. For example. I have 100 rows in my ontology , after I add some rules and run the reasoner, there are 105 rows now. And I need to update these 5 additional rows in my tdb. How can I get this done ? I try to google it and I found two ways. One is using sparql to update , another is truncating the tdb and add the new model into it. Is there any other better solution? Thanks you -- code void after_reasoner(Model m) { String yago =

Specifying class equivalence in Jena rules

时光毁灭记忆、已成空白 提交于 2019-12-11 13:14:41
问题 Given an ontology with Class A and Class B I am stating a rule: [-> (ns:Class_A owl:equivalentClass ns:Class_B)] However the Jena generic rule reasoner is only applying the tag equivalentClass to Class A , i. e. it is not stating Class B equivalentClass Class A . Furthermore, I have an object A that is an individual of Class A , the reasoner is not applying Class B as a type of object A . Is there another way to specify class equivalence through Jena rules? And is it better to use the generic

Selecting multiple results from query

夙愿已清 提交于 2019-12-11 13:13:20
问题 I have this query for example which returns four results. What I am doing with this code is selecting one of those results through an integer, so that I can do another query for it later. What I have been trying to do, and haven't been able to yet, is select more than just one result, so that I can reuse them separately. For example this query would return: RESULT A RESULT B RESULT C RESULT D I can type, for example, 1 in the console and get that value in a string and reuse it. What is a

transform my rdf file to a named graph file

梦想与她 提交于 2019-12-11 12:49:13
问题 For a project I have to use Apache Jena as an API and Blazegraph as a triple store, I am trying to program a code that allows me to transform my dataset (N-Triples File) to a file that contains the NamedGraph of each statement. String APIUrl = "http://localhost:9999/bigdata/namespace/drugbank/sparql"; String req = "select * WHERE {?x ?y ?z}"; RDFConnection conn = RDFConnectionFactory.connect(APIUrl); FileManager.get().addLocatorClassLoader(Main.class.getClassLoader()); Model model =