jena

get base namespace from an OWL ontology

混江龙づ霸主 提交于 2019-12-23 02:38:08
问题 Is there a way to get the base namespace from a OWL ontology file, without using DOM or similar, but just using Jena's API? E.g., from an OWL file: <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:protege="http://protege.stanford.edu/plugins/owl/protege#" xmlns="http://www.owl-ontologies.com/Ontology1254827934.owl#" xmlns:xsp="http://www.owl-ontologies.com/2005/08/07/xsp.owl#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns

Problems with inference examples from Apache Jena framework

孤者浪人 提交于 2019-12-23 02:36:10
问题 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;

How to use Jena TDB to store local version of Linked Movie Database

懵懂的女人 提交于 2019-12-23 02:19:59
问题 I have a local version of LinkedMDB that is in N-Triples format and want to query it. Now, I want to use Jena TDB, which can store the data that can be used for querying later. I checked the documentation for TDB Java API, but was unable to load the N-Triples file and then query with SPARQL. I've used the following code: String directory = "E:\\Applications\\tdb-0.8.9\\TDB-0.8.9\\bin\\tdb"; Dataset dataset = TDBFactory.createDataset(directory); // assume we want the default model, or we could

how to use cidoc-crm in jena

别来无恙 提交于 2019-12-23 01:11:36
问题 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? 回答1: Jena's OntModel interface provides a convenient way of working with ontologies (including RDFS ontologies). The following code

Merging multiple RDF documents into one

北城以北 提交于 2019-12-22 11:04:58
问题 I have got two RDF documents: http://dublincore.org/2012/06/14/dcterms.rdf http://xmlns.com/foaf/spec/index.rdf I would like to merge them into one file, e.g., purl_foaf.rdf . I am working in Java; how can I do this with Jena? 回答1: Jena has a built-in command line utility to do this: rdfcat. So, to join those two RDF files together and write the results as Turtle in the file purl_foaf.rdf , do the following from your command line. It should be on one line, but I've split it up for readability

how to convert model checking logic query to SPARQL query?

萝らか妹 提交于 2019-12-22 10:27:01
问题 Suppose I have the following RDF data: @prefix : <urn:ex:> :m :A "a" :m :A "b" :m :A "c" :m :B "a" :m :B "b" What SPARQL query could I use to check whether the RDF model satisfies the following logical formula? ∀x A(X) → B(x) 回答1: SPARQL doesn't have conditionals or universal quantification, but does have existentials (does anything match this?), (implicit) conjunction and negation (in the 'absence' sense). So rewrite the question: ∀x A(x) → B(x) ⇒ ∀x ¬ ( A(x) ∧ ¬ B(x) ) ⇒ ¬ ∃x A(x) ∧ ¬ B(x)

Saving and reusing the result of a SPARQL query

萝らか妹 提交于 2019-12-22 09:18:20
问题 I am using Jena to query an owl file through Eclipse. I want to do some successive queries and every new query will use the results of the previous query. I want to do it in different ?SELECT and save every time the result of a query in order to use it again in a new query. I dont want to insert the values of the variables by myself but automatically occur from the queries. Any ideas whats a suitable way to achieve this? Thanks in advance 回答1: I think that there are two primary options here:

How to validate a RDF with your RDF schema

拟墨画扇 提交于 2019-12-22 08:34:13
问题 I'm using the Jena framework to manipulate RDF files, but I can't find a way to validate a RDF with your respective RDFSchema. I'm trying this method bellow: Model mod1 = new ModelMem(); Model modSchema = new ModelMem(); String baseURI = "http://iec.ch/TC57/2007/network"; String rdfPath = "file:D:\\modelo.rdf"; InputStream model = FileManager.get().open(rdfPath); String rdfPathSchema = "file:D:\\Schema.rdf"; InputStream modelSchema = FileManager.get().open(rdfPathSchema); mod1.read(model,

How to extract RDF triples from XML file using an existing ontology?

孤街醉人 提交于 2019-12-22 06:49:03
问题 I am trying to extract RDF triples from XML files by using an existing ontology. I am using Java, and can use XPath to extract data from XML and Jena to read and write RDF documents and ontologies. How can I extract the relevant triples from the XML according to the existing ontology? 回答1: Forget about XPath to extract triples, it way easier and less problematic with Jena. You can use the interface SimpleSelector together with model.listStatements from Jena. In this example I am using

Programmatically generating OWL class hierarchy with Jena

天涯浪子 提交于 2019-12-21 23:26:47
问题 I want to programmatically generate an ontology using OWL by supplying a vector. My goal is to be able to open the produced OWL file in Protégé and make use of Jena. Input Vector The vector which i want to pass: [[layer, network layer, data link layer, physical layer], [network, computer network], [data link], [ontology, ontology extraction]]. Expected Output The output should have the following tree-like hierarchy structure: layer -network layer -data link layer -physical layer network