Cant get openllet running on Fuseki - jena

yesterday i was trying to get Pellet and/or Openllet to run on my Fuseki Server.
Im am doing Requests over the Web-Interface. Without reasoners its working fine.
This is my configuration:
#prefix : <http://base/#> .
#prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix fuseki: <http://jena.apache.org/fuseki#> .
<http://jena.apache.org/2016/tdb#DatasetTDB>
rdfs:subClassOf ja:RDFDataset .
ja:DatasetTxnMem rdfs:subClassOf ja:RDFDataset .
tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
tdb:GraphTDB rdfs:subClassOf ja:Model .
<http://jena.apache.org/2016/tdb#GraphTDB2>
rdfs:subClassOf ja:Model .
ja:MemoryDataset rdfs:subClassOf ja:RDFDataset .
ja:RDFDatasetZero rdfs:subClassOf ja:RDFDataset .
<http://jena.apache.org/text#TextDataset>
rdfs:subClassOf ja:RDFDataset .
:service_tdb_all a fuseki:Service ;
rdfs:label "TDB FOOT" ;
fuseki:dataset :tdb_dataset_readwrite ;
fuseki:name "FOOT" ;
fuseki:serviceQuery "query" , "" , "sparql" ;
fuseki:serviceReadGraphStore "get" ;
fuseki:serviceReadQuads "" ;
fuseki:serviceReadWriteGraphStore
"data" ;
fuseki:serviceReadWriteQuads "" ;
fuseki:serviceUpdate "" , "update" ;
fuseki:serviceUpload "upload" .
:tdb_dataset_readwrite
a ja:RDFDataset;
ja:defaultGraph <#model_inf> ;
tdb:location "C:\\etc\\fuseki/databases/FOOT" .
<#model_inf> a ja:InfModel ;
ja:baseModel <#graph> ;
ja:reasoner [
ja:reasonerClass "openllet.jena.PelletReasonerFactory";
] .
<#graph> rdf:type tdb:GraphTDB ;
tdb:dataset :tdb_dataset_readwrite .
Error-Log in the Tomcat Directory:
ERROR Exception in initialization: the class 'openllet.jena.PelletReasonerFactory' required by the object 7c374328cddba9fa8091dcebd77a7598 [ja:reasoner of file:///C:/etc/fuseki/configuration/FOOT.ttl#model_inf] could not be loaded
I had been copying the Openllet Jar-Files (openllet-query-2.6.5.jar and things) everywhere, but no chance.
Btw is this the right action anyway?!
In my Apache Jena project (and Snarp Sparql Protege Plugin) i got Openllet to run and it gets me the right results.
I got a few rules that are all of this type
[ rdf:type owl:Class ;
owl:unionOf ( [ owl:intersectionOf ( [ rdf:type owl:Restriction ;
owl:onProperty food:hasIngredient ;
owl:someValuesFrom food:Dairy
]
[ rdf:type owl:Restriction ;
owl:onProperty food:hasIngredient ;
owl:someValuesFrom [ rdf:type owl:Restriction ;
owl:onProperty food:hasFood ;
owl:someValuesFrom food:Meat
]
]
) ;
rdf:type owl:Class
]
[ rdf:type owl:Restriction ;
owl:onProperty food:hasIngredient ;
owl:someValuesFrom [ rdf:type owl:Restriction ;
owl:onProperty food:hasFood ;
owl:someValuesFrom food:Pork
]
]
)
]
) ;
rdf:type owl:Class ;
rdfs:subClassOf [ rdf:type owl:Restriction ;
owl:onProperty food:violatesRestriction ;
owl:hasValue food:kosherReligious
]
] .
"Not kosher if there is pork in a recipe or meat in combination with a dairy product."
The reasoning is horrible slow (8 seconds on a 25000 triple database). If i extract the model before it runs fast but the extraction of the model takes 3 minutes.
I just want to have a way where the user can query recipes with the inferences of a reasoner in a reasonable time (< 2 seconds) :(
Are there any more (better?) reasoners who can work with blank nodes (Hermit cant...) ??
My questions are:
How can i get Fuseki to run with Pellet/Openllet
Reasoner alternatives?
Is there a better way to infer rules like the one above?
Am i completely wrong and do i have to let the reasoner to be run only one time at the start of the program and not for every query?
Best regards ;)

Instead of Openllet i tried the OWLMicroFBRuleReasoner, it worked! And its fast!
<#model_inf> a ja:InfModel ;
ja:baseModel <#graph> ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLMicroFBRuleReasoner>
] .

Related

How to configure fuseki jena to use a reasoner and TDB + tdb:UnionDefaultGraph

Context
i am new to fuseki, i am currently using it in a project, the main idea is:
start the server with a pre-defined ontology (turtle file) + a reasoner
I process files with python, and for each file, I generate an rdf graph that I put in a named graph
finally, I would like to query on all the subgraphs
My current configuration
#prefix : <#> .
#prefix fuseki: <http://jena.apache.org/fuseki#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
#prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
[] rdf:type fuseki:Server ;
fuseki:services (
<#lmdrservice>
) .
# TDB
tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
tdb:GraphTDB rdfs:subClassOf ja:Model .
<#lmdrservice> rdf:type fuseki:Service ;
fuseki:name "lmdr" ; # http://host/inf
fuseki:serviceQuery "query" , "sparql" ;
fuseki:serviceUpdate "update" ;
fuseki:serviceUpload "upload" ;
fuseki:serviceReadWriteGraphStore "data" ;
fuseki:serviceReadGraphStore "get" ;
fuseki:dataset <#dataset> ;
.
<#dataset> rdf:type ja:RDFDataset ;
ja:defaultGraph <#model> ;
ja:namedGraph
[ ja:graphName <http://www.example.com/ontology> ;
ja:graph <#ontology> ] ;
.
<#ontology> rdf:type ja:MemoryModel ;
ja:content [ja:externalContent <file:/fuseki/lmdr.ttl> ] ;
.
<#model> a ja:InfModel ;
ja:baseModel <#tdbGraph> ;
ja:reasoner [
ja:rulesFrom <file:/fuseki/configuration/lmdr_rules.rules> ;
] ;
.
<#tdbGraph> rdf:type tdb:GraphTDB ;
tdb:dataset <#tdbDataset>
.
<#tdbDataset> rdf:type tdb:DatasetTDB ;
tdb:location "/fuseki/databases/lmdr" ;
tdb:unionDefaultGraph true
.
What doesn't work
Sparql queries are not executed on all named graphs,the problem probably comes from the argument :
tdb:unionDefaultGraph true
What i've tried
I tried many other different configurations, for example:
specify this in the server description part
fuseki:endpoint [
fuseki:operation fuseki:query ;
fuseki:name "sparql-union" ;
ja:context [ ja:cxtName "tdb:unionDefaultGraph" ; ja:cxtValue true ] ;
] ;
Using urn:x-arq:UnionGraph as the name of the graph, which means that it is the union of the named graphs
:g rdf:type tdb:GraphTDB ;
tdb:dataset :tdbDataset ;
tdb:graphName <urn:x-arq:UnionGraph> ;
.

Named Graphs v Default Graph behaviour in Apache Jena Fuseki

We are running Apache Jena Fuseki.
If we upload graphA and graphB
SELECT (COUNT(*) as ?count)
FROM <graphA>
FROM <graphB>
WHERE { ?s ?p ?o . }
gives 100
If we upload triples in A and B into Default
SELECT (COUNT(*) as ?count)
WHERE { ?s ?p ?o . }
gives 200
It seems there is no inferencing happening between graphA and graphB in the FROM example?
How do we fix this?
Found Reasoning with Fuseki, TDB and named graphs? but dont understand if it is the same problem.
Example data:
Graph A:
Mdworking:Measure
a owl:Class ;
mdmm:elementName "Measure" .
Graph B:
Mddemobank:Account_Balance
a owl:Class ;
rdfs:subClassOf Mdworking:Measure ;
mdmm:elementName "Account_Balance" .
Mddemobank:Sub_Account_Balance
a owl:Class ;
rdfs:subClassOf Mddemobank:Account_Balance ;
mdmm:elementName "Sub_Account_Balance" .
Query:
SELECT ?subject ?predicate ?object
FROM <A>
FROM <B>
WHERE {
?subject ?predicate ?object
}
does not give the inferred
Mddemobank:Sub_Account_Balance subClassOf Mdworking:Measure
Tried the query
SELECT *
{
{ ?s ?p ?o } UNION { GRAPH ?g { ?s ?p ?o } }
}
which returns triples from A, B and default, but does not show infered tripples.
Environment:
* Tested version 2.6.0 on Ubuntu
* Tested version 3.4.0. on Windows 10
* Loaded the test files using the browser
Here is the assembler file
#prefix : <http://base/#> .
#prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix fuseki: <http://jena.apache.org/fuseki#> .
#prefix : <http://base/#> .
#prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix fuseki: <http://jena.apache.org/fuseki#> .
# THE SERVICE
<service1> a fuseki:Service ;
fuseki:dataset <#dataset> ;
fuseki:name "xxx" ;
fuseki:serviceQuery "query" , "sparql" ;
fuseki:serviceReadGraphStore "get" ;
fuseki:serviceReadWriteGraphStore "data" ;
fuseki:serviceUpdate "update" ;
fuseki:serviceUpload "upload" .
# DATASET for the service
<#dataset> rdf:type ja:RDFDataset ;
rdfs:label "xxx" ;
ja:defaultGraph <#model_inf>
.
# MODEL for dataset
<#model_inf> a ja:InfModel ;
ja:baseModel <#tdbGraph> ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner>
] .
# Graph for the default Model
<#tdbGraph> rdf:type tdb:GraphTDB;
tdb:dataset <#tdb_dataset_readwrite> .
# Dataset for the Graph
<#tdb_dataset_readwrite>
a tdb:DatasetTDB ;
tdb:unionDefaultGraph true ;
#if you want all data to available in the default graph
#without 'FROM-NAMing them' in the SPARQL query
tdb:location "C:\\Programs_other\\apache-jena-fuseki-3.4.0\\apache-jena-fuseki-3.4.0\\run/databases/xxx" .

405 HTTP method PUT is not supported by this URL

I started Fuseki server using this configuration:
#prefix : <#> .
#prefix fuseki: <http://jena.apache.org/fuseki#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
#prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
#prefix sdb: <http://jena.hpl.hp.com/2007/sdb#> .
[] rdf:type fuseki:Server ;
fuseki:services (
<#memory>
<#tdb>
#<#mysql>
) .
# Custom code.
[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
#[] ja:loadClass "com.hp.hpl.jena.sdb.SDB" .
########################################################################
#In Memory
<#memory> rdf:type fuseki:Service ;
fuseki:name "memory" ; # http://host/inf
fuseki:serviceQuery "sparql" ; # SPARQL query service
fuseki:serviceUpdate "update" ;
fuseki:dataset <#dataset1> ; #select which set to
. #use
<#dataset1> rdf:type ja:RDFDataset ;
ja:defaultGraph <#model_inf_1> ;
.
<#model_inf_1> rdfs:label "Inf-1" ;
ja:reasoner
[ ja:reasonerURL
<http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>];
.
########################################################################
# TDB
<#tdb> rdf:type fuseki:Service ;
fuseki:name "tdb" ; # http://host/inf
fuseki:serviceQuery "sparql" ; # SPARQL query service
fuseki:serviceUpdate "update" ;
fuseki:dataset <#dataset2> ; #select which set to
. #use
tdb:GraphTDB rdfs:subClassOf ja:Model .
<#dataset2> rdf:type ja:RDFDataset ;
ja:defaultGraph <#model2>;
.
<#model2> a ja:InfModel;
ja:baseModel <#tdbGraph>;
ja:reasoner
[ ja:reasonerURL
<http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>];
.
<#tdbGraph> rdf:type tdb:GraphTDB;
tdb:location "DB";
.
Then I try to upload the ontology as follows:
./s-put http://localhost:3030/tdb/data default /home/gosper/Desktop/tools/jena-fuseki1-1.3.1/Data/pizza.owl
It gives me the following error:
405 HTTP method PUT is not supported by this URL http://localhost:3030/tdb/data?default
I also tried the following URLs but nothing works.:
http://localhost:3030/dataset/data
http://localhost:3030/dataset2/data
Any idea how to fix this issue?
You don't have an endpoint called data supporting the SPARQL Graph Store Protocol defined in your configuration.
Try adding fuseki:serviceReadWriteGraphStore "data" ;

How to define very simple own rule in fuseki step by step?

I'm asking your help to understand how to create my own property rules in fuseki.
I've read the documentation of Jena and Fuseki about reasoners and rules but I don't understand how to create (step by step) simple rules. And the examples that I've found are focus on OWL reasoners.
I don't clearly understand what write in the config.ttl file in order to fuseki takes into account my rules on my ontology. I use the Sparql point with python through a sparql-client, and I don't master java code and applications.
My purpose is to create the next rules:
#prefix rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
#prefix ex: http://example.com/
#prefix xs: http://www.w3.org/2001/XMLSchema#
#prefix ont: http://www.myownontolongy/ontology/
[dependsOfExchange:
(?e ont:refersToPriorActivityData ?a)
(?a ont:hasExchange ?es)
->
(?e rme:dependsOfExchange ?es)
]
The principle in SWRL syntax is:
refersToPriorActivityData(?e,?a) ^ hasExchange(?a,?es) => dependsOfExchange(?e,?es)
Thanks in advance.
EDIT with one solution
#prefix : <#> .
#prefix fuseki: <http://jena.apache.org/fuseki#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
#prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
tdb:GraphTDB rdfs:subClassOf ja:Model .
[] rdf:type fuseki:Server ;
# Timeout - server-wide default: milliseconds.
# Format 1: "1000" -- 1 second timeout
# Format 2: "10000,60000" -- 10s timeout to first result, then 60s timeout for the rest of query.
# See java doc for ARQ.queryTimeout
# ja:context [ ja:cxtName "arq:queryTimeout" ; ja:cxtValue "10000" ] ;
# ja:loadClass "your.code.Class" ;
fuseki:services (
<#reminer>
) .
## ---------------------------------------------------------------
## Updatable in-memory dataset.
<#reminer> rdf:type fuseki:Service ;
# URI of the dataset -- http://host:port/reminer
fuseki:name "name_of_your_database" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceQuery "query" ;
fuseki:serviceUpdate "update" ;
fuseki:serviceUpload "upload" ;
fuseki:serviceReadWriteGraphStore "data" ;
fuseki:serviceReadGraphStore "get" ;
fuseki:serviceReadGraphStore "" ;
fuseki:dataset <#myDataset> ;
.
## In-memory, initially empty.
## This database set-up allows OWL inference.
<#myDataset> rdf:type ja:RDFDataset ;
tdb:unionDefaultGraph true ;
ja:defaultGraph <#infGraph> .
<#infGraph> rdf:type ja:InfModel ;
ja:reasoner [ ja:rulesFrom <file:rules/inference_rules.rules> ; ] ; #the rules directory is in the "run" directory
ja:baseModel <#baseGraph> .
<#baseGraph> rdf:type tdb:GraphTDB;
tdb:location "path_of_your_database" .
And the inference_rules.rules for an example:
#prefix rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
#prefix ex: http://example.com/
#prefix xs: http://www.w3.org/2001/XMLSchema#
#prefix mO: http://www.semanticweb.org/myOntology/
[dependsOfExchange:
(?e mO:producedBy ?a)
(?a mO:hasExchange ?es)
->
(?e rme:dependsOf ?es)
]
The .ttl use through the cmd line: ./fuseki-server --config=/path/of/your/custom-config.ttl
#prefix : <#> .
#prefix fuseki: <http://jena.apache.org/fuseki#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
#prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
tdb:GraphTDB rdfs:subClassOf ja:Model .
[] rdf:type fuseki:Server ;
# Timeout - server-wide default: milliseconds.
# Format 1: "1000" -- 1 second timeout
# Format 2: "10000,60000" -- 10s timeout to first result, then 60s timeout for the rest of query.
# See java doc for ARQ.queryTimeout
# ja:context [ ja:cxtName "arq:queryTimeout" ; ja:cxtValue "10000" ] ;
# ja:loadClass "your.code.Class" ;
fuseki:services (
<#reminer>
) .
## ---------------------------------------------------------------
## Updatable in-memory dataset.
<#reminer> rdf:type fuseki:Service ;
# URI of the dataset -- http://host:port/reminer
fuseki:name "name_of_your_database" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceQuery "query" ;
fuseki:serviceUpdate "update" ;
fuseki:serviceUpload "upload" ;
fuseki:serviceReadWriteGraphStore "data" ;
fuseki:serviceReadGraphStore "get" ;
fuseki:serviceReadGraphStore "" ;
fuseki:dataset <#myDataset> ;
.
## In-memory, initially empty.
## This database set-up allows OWL inference.
<#myDataset> rdf:type ja:RDFDataset ;
tdb:unionDefaultGraph true ;
ja:defaultGraph <#infGraph> .
<#infGraph> rdf:type ja:InfModel ;
ja:reasoner [ ja:rulesFrom <file:rules/inference_rules.rules> ; ] ; #the rules directory is in the "run" directory
ja:baseModel <#baseGraph> .
<#baseGraph> rdf:type tdb:GraphTDB;
tdb:location "path_of_your_database" .
And the inference_rules.rules for an example:
#prefix rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
#prefix ex: http://example.com/
#prefix xs: http://www.w3.org/2001/XMLSchema#
#prefix mO: http://www.semanticweb.org/myOntology/
[dependsOfExchange:
(?e mO:producedBy ?a)
(?a mO:hasExchange ?es)
->
(?e rme:dependsOf ?es)
]

Command line grep gives wrong results

I have two files, one with the patterns of a grep search, and the other is the target file where I want to look for patterns.
File 1 looks like this:
Cre01.g001800
Cre01.g001950
g46
g46
Cre01.g002050
Cre01.g002150
RPB6
g51
Cre01.g002201
Cre01.g002201
Cre01.g002236
Cre01.g002236
Cre01.g002300
And my second file looks like this:
chromosome_12 scriptAPG exon 3691112 3693536 . + . gene_id "RPS11";transcript_id "RPS11"
chromosome_9 scriptAPG exon 3011840 3038275 . - . gene_id "Cre09.g387400";transcript_id "Cre09.g387400"
chromosome_9 scriptAPG exon 2571100 2572801 . + . gene_id "Cre09.g390678";transcript_id "Cre09.g390678"
chromosome_14 scriptAPG exon 3804470 3817534 . + . gene_id "Cre14.g632650";transcript_id "Cre14.g632650"
chromosome_3 scriptAPG exon 4400340 4417459 . + . gene_id "Cre03.g175600";transcript_id "Cre03.g175600"
scaffold_40 scriptAPG exon 36 2671 . + . gene_id "g18380";transcript_id "g18380"
chromosome_6 scriptAPG exon 7445801 7457337 . - . gene_id "Cre06.g300050";transcript_id "Cre06.g300050"
chromosome_17 scriptAPG exon 584317 595135 . + . gene_id "Cre17.g699950";transcript_id "Cre17.g699950"
My aim is to extract the rows in file2 that have some pattern in file1. So, I throw the following command:
grep -w -F -f ".$out."/localization/prep/translator.txt localization/prep/locations.gtf > localization/prep/genemodels.gtf
What I am not understanding is: why the output file from the grep search, genemodels.gtf, have lines without matching patterns? It prints all the lines!! Doing this:
grep Cre01.g003600 translator.txt
I do not obtain any results. However, doing this:
grep Cre01.g003600 genemodels.gtf
I obtain:
chromosome_1 scriptAPG exon 688996 690516 . + . gene_id "Cre01.g003600";transcript_id "Cre01.g003600"
Do you know what I am doing wrong? Could it be the point . that some patterns to look for (e. g. Cre01.g001950) have? Grep does not sees that as a literal point. How to avoid that?
Thanks.

Resources