jena

How I can write SPARQL query that uses similarity measures in Java Code

北城余情 提交于 2019-12-06 08:48:05
I would like to know a simple method to write this SPARQL query in Java Code: select ?input ?string (strlen(?match)/strlen(?string) as ?percent) where { values ?string { "London" "Londn" "London Fog" "Lando" "Land Ho!" "concatenate" "catnap" "hat" "cat" "chat" "chart" "port" "part" } values (?input ?pattern ?replacement) { ("cat" "^x[^cat]*([c]?)[^at]*([a]?)[^t]*([t]?).*$" "$1$2$3") ("Londn" "^x[^Londn]*([L]?)[^ondn]*([o]?)[^ndn]*([n]?)[^dn]*([d]?)[^n]*([n]?).*$" "$1$2$3$4$5") } bind( replace( concat('x',?string), ?pattern, ?replacement) as ?match ) } order by ?pattern desc(?percent) This code

Using SWRL with Jena and Pellet

寵の児 提交于 2019-12-06 08:35:07
问题 I was unable to find some decent simple code examples of using SWRL and Jena with Pellet, or at least using SWRL? I have studied some examples in Pellet documentation, but there is no example about using SWRL. Most examples on the web are incomplete and confusing. The only solution I found was with the Jess Rule Engine but it is not free and is under commercial license. I found that Pellet support SWRL rules but could not find running example. The only example I found is this, but I do not

Explain inference in Jena

南楼画角 提交于 2019-12-06 06:51:39
In Jena, I have created an RDFS inference model using InfModel class: InfModel infmodel = ModelFactory.createRDFSModel(schema, data); Given an inferred statement from infmodel, how do we get the two statements that were used to infer it, similar to the the "explain inference" option in Protégé? For instance, if infModel contains the statement :a rdf:type :t , we might get two statements used to infer it, e.g., :a :p :b and :p rdfs:domain :t . According to the documentation (and testing with Jena 2.11.1) you can get access to a Derivation object which will allow you to create a textual

SPARQL Query Error with OPTION(TRANSITIVE) on Jena

江枫思渺然 提交于 2019-12-06 05:30:56
I have the following Query PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?type WHERE { { SELECT * WHERE { ?x rdfs:subClassOf ?type . } } OPTION (TRANSITIVE, t_distinct, t_in (?x), t_out (?type) ) . FILTER (?x = <http://dbpedia.org/ontology/Hospital>) } It works fine when i send it to Virtuoso endpoint but does not work on my Jena instance. In specific i get the following error: INFO [1] 400 Parse error: PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?type WHERE { { SELECT * WHERE { ?x rdfs:subClassOf ?type . } } OPTION (TRANSITIVE, t_distinct, t_in (?x), t_out (?type

Jena PrefixMapping: base namespace missing when model is a named model obtained from a dataset

匆匆过客 提交于 2019-12-06 05:07:23
This the code I am using to load OntModel to a Dataset as a Named Model. Then I try to retrieve the PrefixMapping for the same in two different ways: public static void loadDatasetwithNamedModels(){ OntModel namedModel = null; Dataset dataset = null; dataset = TDBFactory.createDataset("./path/to/TDB_DIR"); namedModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); dataset.begin(ReadWrite.WRITE); try{ namedModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); FileManager.get().readModel( namedModel, "./Path/to/OWLFile.owl"); dataset.addNamedModel("MyNamedModel", namedModel);

Sparql query running forever

…衆ロ難τιáo~ 提交于 2019-12-06 01:52:26
问题 I'm struggling with the execution of a SPARQL query in Jena, with a resulting behaviour that I don't understand... I'm trying to query the Esco ontology (https://ec.europa.eu/esco/download), and I'm using TDB to load the ontology and create the model (sorry if the terms I use are not accurate, I'm not very experienced). My goal is to find a job position uri in the ontology that matches with the text I have previously extracted: ex: extracted term : " acuponcteur " -> label in ontology:

OutOfMemoryError using Pellet as Reasoner

拟墨画扇 提交于 2019-12-05 22:13:20
I'm trying to infer data using Pellet, but my application always crashes during reasoning due to an "OutOfMemoryError: Java heap space". As suggested elsewhere I have already tried to increase heap size and currently I am using these VM arguments: "-XX:MaxPermSize=256m -Xmx6144m". Furthermore I've to set 'PelletOptions.USE_CONTINUOUS = true', but so far I was only able delays the crashs for some minutes. (Longest run so far: 30 min.). I am storing data in a Jena TDB triplestore. Its total size is 170 mb and consists of 962117 statements. The ontology has been modelled in Protege and there are

Using Jena reasoner on Neo4J db

我的未来我决定 提交于 2019-12-05 20:52:44
it's my first time writing here but i'm really struck with a problem: is it possible to use the Jena reasoner on a No-SQL database, like Neo4J, already filled with data? I've a Neo4J's graph rappresenting a bunch of triples and I would like to use the Jena API and the Jena reasoner on them. I thought about using the SDB/TDB component of Jena but I don't get how to actually load the data into my model since the SDB component seems to work with just SQL databases and the go throught the whole TDB javadoc seems to be a bit too much. Should I define some kind of configuration file for the TDB

Saving and reusing the result of a SPARQL query

南笙酒味 提交于 2019-12-05 17:48:49
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 I think that there are two primary options here: a . if you're interested in just one QuerySolution from a ResultSet and you're running these queries locally

How to validate a RDF with your RDF schema

拈花ヽ惹草 提交于 2019-12-05 16:20:59
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, baseURI, "RDF/XML-ABBREV"); modSchema.read(modelSchema,baseURI, "RDF/XML-ABBREV"); InfModel infmodel =