jena

Create a library for new built-ins Jena

匆匆过客 提交于 2019-12-25 02:22:14
问题 I have made some new built-ins for Jena. I would like to create a library where I can put all of them. How can I do that ? And how can I create my rules in this case ? Need I to import some files in the rule file? 回答1: Please note that, as this question is extremely broad, my answer is merely a set of suggestions towards an overall design. First, we'll begin with how Jena does it. Apache Jena stores its rule files as classpath resources within its distribution jars. jena-core has a package

Jena; listDeclaredProperties semantics

为君一笑 提交于 2019-12-25 01:55:45
问题 Let's consider a (1) P Domain CSuper (2) CSub subClassOf CSuper Using Jena, I'm trying to list the declared properties for CSub . What I believe is that P mustn't be listed as a declared property for CSub . My justification: P is a declared property for CSub , iff CSub is a domain for P , from (1) CSuper is a domain for P which doesn't imply that CSub is also a domain; (1) means that if (x, y) is P , then x is CSuper , clearly x may (not) be CSub . The surprising thing is that Jena is listing

How to write Jena rule to query class and get individuals for a property

久未见 提交于 2019-12-25 01:15:00
问题 How to extract all actuators that are switched off when there are no users at home. I tried to write Jena rule but am unable to get proper output. I have added desired result that I want. Need help with writing rule. [rule1: noValue(:users :hasLocation :home) -> (:actuators :hasLocation :home) (:actuators :state "OFF"^^xsd:boolean)] [rule2: noValue(:users :hasLocation :home) -> (?x rdf:type :actuators) (?x :hasLocation :home) (?x :state "OFF"^^xsd:boolean)] { rulex: [noValue(:subject1

Federation query on Dbpedia and Wikidata

江枫思渺然 提交于 2019-12-24 20:44:44
问题 I'm doing federation query exercise. I want the list of films that stars with leonardio di caprio and also the list of directors that worked with him. I have to design federated SPARQL query over Wikidata and Dbpedia. I have to run the query through FEDx. Here's the query. This is done in Eclipse. Also tested on the wikidata endpoint. PREFIX wd: <http://www.wikidata.org/entity/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX dbr: <http:/

Write rdf file without Alphabetical

十年热恋 提交于 2019-12-24 17:14:11
问题 Write RDF I have a model RDF and I want write it in a file. This would be the result: @prefix dc: <http://purl.org/dc/elements/1.1/> . @prefix legal: <http://www.linked-usdl.org/ns/usdl-legal#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix vann: <http://purl.org/vocab/vann/> . @prefix org: <http://www.w3.org/ns/org#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix price: <http://www.linked-usdl.org/ns/usdl-price#> . @prefix usdl: <http://www.linked-usdl.org/ns/usdl#

How to preserve namespace prefixes in a Jena TDB dataset?

丶灬走出姿态 提交于 2019-12-24 16:54:29
问题 I am using Jena TDB (1.1.1) to store a set of named graphs. Everything works fine but whenever I retrieve a named graph from the the dataset, all the namespace prefix information is lost. Is there a way to preserve the namespace prefixes in the original RDF graph. Following code snippet shows the issue. @Test public void testPreserveNsPrefixes(){ String modelText = "@prefix ro: <http://purl.org/wf4ever/ro#> ." + "@prefix ore: <http://www.openarchives.org/ore/terms/> ." + "@prefix ldp: <http:/

Incremental dataload into Jena from multiple files

风格不统一 提交于 2019-12-24 15:34:30
问题 I want to use tdbloader2 to load multiple files into a TDB datastore. The first one goes fine, but any subsequent loads seem to delete the data that was loaded from previous files. How do I avoid this? 回答1: tdbloader (not tdbloader2) will incrementally load data. tdbloader2 only works for an empty store. Both accept multiple files as well. Or you can use the SPARQL Update to add data. Or you can use the SPARQL Graph Store Protocol with Fuseki to add data. 回答2: It turns out that tdbloader2

Synchronizing Jena OntModels with bnodes

瘦欲@ 提交于 2019-12-24 10:45:39
问题 This question relates to rcreswick's question on Serializing Jena OntModel Changes. I have Jena models on two (or more) machines that need to remain synchronized over sockets. The main issue that I need to address is that the models may contain anonymous nodes (bnodes), which can originate in any of the models. Question : Am I on the right track here, or is there a better, more robust approach that I'm failing to consider? I can think of 3 approaches to this problem: Serialize the complete

Adding an OPTIONAL clause to a SPARQL query using Jena ARQ

老子叫甜甜 提交于 2019-12-24 05:41:14
问题 Is it possible to programmatically add an OPTIONAL clause to a SPARQL query using the Jena ARQ API? I would like to programmatically take this query: select ?concept ?p ?o where {?s ?p ?o . } limit 10 To this: SELECT ?concept ?p ?o ?test WHERE { ?s ?p ?o OPTIONAL { ?concept <http://www.test.com/test> ?test } } LIMIT 10 Through ARQ it's simple to add the additional result variable ?test : Query q = QueryFactory.create(query) query.addResultVar(var); But from what I've found in the API docs and

Pull string from RDF node

时光毁灭记忆、已成空白 提交于 2019-12-24 03:13:02
问题 Im trying to get the data in a more readable format when using a SPARQL query with Jena, however I have no idea how to extract the data in a proper way. As for now, the output is: "http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SaucelitoCanyon" Where instead would like to just have the "SaucelitoCanyon" as a output. public JenaQuery() { String wineRegion = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + "PREFIX owl: <http://www.w3.org/2002/07/owl#>\n" + "PREFIX xsd: