On 14/04/16 17:47, Andy Seaborne wrote:
1) Is there a way to create a unionized graph at query time? If
yes,is there a way to run an inference engine over this query-
 >> time-created unionized graph?

I think one of the problems is that the "forward" part of the reasoning
is going execute once when the graph is created as the server starts and
then update only if data goes through the reasoner.

Actually, it'll only be triggered by the first query. But that first query will invoke a prepare() on the InfGraph which will indeed run all the forward rules.

Just updating via a
different route, direct to the named graph, bypasses the reasoner to
trigger changes.

Exactly.

A pure backward rules reasoner will do the calculations art query time
except for any caching it might do (tabling).  That will at least not do
any work until the first query.

Dave knows more about this than I do.

Sorry to have missed this question. I took it to be a question about assemblers which I don't understand :)

Ideas:

1/ Load the graphs with data first , then run the server so the data is
in place when the server starts.

2/ Run one named graph and have an associated named graph with the
reasoner of choice.


2) If the above is not an option, is there a way have an inference
 >> engine run over the unionized default graph from a set of named
 >> graphs?

I don't know if several different reasoners on the same data will work.
  I suspect updates have to go through a reasoner to trigger
recalulation of reasoner datastructures.  Only fully backwards seems to
be able to not need that but I don't know the details.

You can have separate InfGraphs over the same base graph. Nothing is written back to the base graph, all the inferences and intermediate state are in memory associated with each InfGraph. But as Andy says, if there are forward rules then the updates have to made via the InfGraph which is hard if there's several of them.

It seems like you have two problems to deal with - how to create a dynamic union over some subset of the graphs, then how to set up a reasoner over that union where you can control the state.

For the first part of the problem then the reasoners are simply not dataset-aware so there's no option to configure them to work over some subset of named graphs. In code you can create dynamic union models then create a reasoner over that union but that's more than just an assembler config. In any case reasoner performance over a persistent model can be poor.

For the second part of the problem you either need to work with just backward rules (with no tabling (= caching) so no state) or you have to call reset() on the InfModels after an edit, that will mean that the next query will re-consult the base models. Again that needs code.

The other alternative is for someone to write a new reasoner - one that's data set aware and works by query rewriting without state - but I'm not aware of such a thing for Jena.

Dave


On 12/04/16 19:05, Woodward, Arthur E CTR (US) wrote:
Sure, forwarding the message to the users list again.


Hello Users,

I have been having difficulty finding a solution to the problem of
building a modular system for ontological query expansion in Fuseki.

My goal is to be able to run a query over a unionized default graph,
while maintaining the ability to edit the individual named graphs
either from the same dataset or a different dataset.

I have tried many variations of the Fuseki assembler, and after
combing through the documentation and previous e-mails I believe I
have constructed an assembler specification that should be working,
but it is not. From an e-mail by Rohana Rajapakse on Jan 24, 2014 1:52
am it was indicated that a structure like the one in my file below
should allow for an inference engine to be run over a unionized
default graph.

Data added via Fuseki GUI::
DID NOT WORK
Dataset -- Data
Graphs -- default -- (empty, with unionDefaultGraph:true in the
Data.ttl and Reasoner.ttl assembler files)
               Entities --
                             @prefix ex:    <http://example.org/>.
                             @prefix owl:
<http://www.w3.org/2002/07/owl#> .
                             @prefix rdf:
<http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
                             @prefix rdfs:
<http://www.w3.org/2000/01/rdf-schema#> .
                             @prefix zoo:   <http://example.org/zoo/>.

                             ex:dog1  a      ex:animal .
                             ex:cat1  a      ex:cat .
                             ex:zoo1  zoo:host  ex:cat2 .
                             ex:cat3  owl:sameAs  ex:cat2 .

             Ontology --
                             @prefix ex:    <http://example.org/>.
                             @prefix owl:
<http://www.w3.org/2002/07/owl#> .
                             @prefix rdf:
<http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
                             @prefix rdfs:
<http://www.w3.org/2000/01/rdf-schema#> .
                             @prefix zoo:   <http://example.org/zoo/>.

                             ex:cat  rdfs:subClassOf  ex:animal .
                             zoo:host  rdfs:range  ex:animal .
Dataset -- Reasoner
             default - (no manually entered data)

Query -- Run over the Reasoner Dataset
PREFIX ex: <http://example.org/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX : <http://localhost:3030/Test/data/>
PREFIX http: <http://www.w3.org/2011/http#>
SELECT ?animal
WHERE {
   ?animal a ex:animal .
}
LIMIT 10

0 Results.

If the data in the "Data" dataset is moved from the named graphs to
the default graph and the unionDefaultGraph:true option is commented
out from the Data.ttl file, and the same query above is run, there are
4 results.
{
   "head": {
     "vars": [ "animal" ]
   } ,
   "results": {
     "bindings": [
       {
         "animal": { "type": "uri" , "value": "http://example.org/dog1"; }
       } ,
       {
         "animal": { "type": "uri" , "value": "http://example.org/cat1"; }
       } ,
       {
         "animal": { "type": "uri" , "value": "http://example.org/cat2"; }
       } ,
       {
         "animal": { "type": "uri" , "value": "http://example.org/cat3"; }
       }
     ]
   }
}

Data.ttl::
       1 @prefix :      <http://base/#> .
       2 @prefix tdb:   <http://jena.hpl.hp.com/2008/tdb#> .
       3 @prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
       4 @prefix ja:    <http://jena.hpl.hp.com/2005/11/Assembler#> .
       5 @prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
       6 @prefix fuseki: <http://jena.apache.org/fuseki#> .
       7
       8 :service_tdb_all  a                   fuseki:Service ;
       9         rdfs:label                    "TDB Data" ;
      10         fuseki:dataset                :tdb_dataset_readwrite ;
      11         fuseki:name                   "Data" ;
      12         fuseki:serviceQuery           "query" , "sparql" ;
      13         fuseki:serviceReadGraphStore  "get" ;
      14         fuseki:serviceReadWriteGraphStore
      15                 "data" ;
      16         fuseki:serviceUpdate          "update" ;
      17         fuseki:serviceUpload          "upload" .
      18
      19 :tdb_dataset_readwrite
      20         a             tdb:DatasetTDB ;
      21         tdb:location
"/home/evan/Documents/apache-jena-fuseki-2.3.1/run/databases/Data" ;
      22        tdb:unionDefaultGraph true ;
      23         .
      24


Reasoner.ttl::
@prefix :      <http://base/#> .
       2 @prefix tdb:   <http://jena.hpl.hp.com/2008/tdb#> .
       3 @prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
       4 @prefix ja:    <http://jena.hpl.hp.com/2005/11/Assembler#> .
       5 @prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
       6 @prefix fuseki: <http://jena.apache.org/fuseki#> .
       7
       8 :service1  a                          fuseki:Service ;
       9         fuseki:dataset                :tdb_dataset_readwrite ;
      10         fuseki:name                   "Reasoner" ;
      11         fuseki:serviceQuery           "query" , "sparql" ;
      12         fuseki:serviceReadGraphStore  "get" ;
      13         fuseki:serviceReadWriteGraphStore
      14                 "data" ;
      15         fuseki:serviceUpdate          "update" ;
      16         fuseki:serviceUpload          "upload" .
      17
      18 tdb:GraphTDB rdfs:subClassOf ja:Model .
      19 tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
      20
      21 :tdb_dataset_readwrite  a          ja:RDFDataset ;
      22         ja:defaultGraph :model2 ;
      23         ja:namedGraph
      24            [ ja:graphName "Data" ;
      25              ja:graph     :graph ] ;
      26         .
      27
      28 :tdb_intermediate_dataset a tdb:DatasetTDB ;
      29     tdb:location
"/home/evan/Documents/apache-jena-fuseki-2.3.1/run/databases/Data";
      30     tdb:unionDefaultGraph true ;
      31     .
      32
      33 :graph rdf:type tdb:GraphTDB ;
      34     tdb:dataset :tdb_intermediate_dataset
      35     .
      36
      37 :model2 a ja:InfModel ;
      38         ja:reasoner  [ ja:reasonerURL
<http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>] ;
      39         ja:baseModel :graph ;
      40         .
      41
      42

What I have found is that if data is entered into the default graph in
the "Data" dataset without the unionDefaultGraph option, this
"Reasoner" dataset (above) will find the information and perform
inferences over it. However, if the data is instead entered into two
named graphs, with the unionDefaultGraph:true option selected, the
"Reasoner" dataset is unable to find the information in "Data".
Additionally, the "Reasoner" dataset has no access to read or write to
the "Data" dataset, which is why I set up a separate end-point to be
able to manipulate the data in "Data".

The goal of this experiment is to be able to run different Owl
ontologies over the same entity data, so ideally there would be a way
to create a unionized graph from two named graphs in "Data" and query
time, and then run the inference engine over this graph. So my
questions are,

1) Is there a way to create a unionized graph at query time? If yes,
is there a way to run an inference engine over this query-time-created
unionized graph?

2) If the above is not an option, is there a way have an inference
engine run over the unionized default graph from a set of named graphs?

If you have any questions or need more information please feel free to
reach out to me at any time.


Thank you for your help,
Evan Woodward

________________________________________
From: Andy Seaborne [[email protected]] on behalf of Andy
Seaborne [[email protected]]
Sent: Tuesday, April 12, 2016 5:13 PM
To: Woodward, Arthur E CTR (US)
Subject: Re: FW: [Non-DoD Source] Fuseki issue - Reasoner over Unioned
Graph

Hi there,

You are subscribed to the [email protected] but not the
[email protected] list.

For usage questions, please use the [email protected] list.

Please could you re-send the message so that you receive replies.

      Andy



On 12/04/16 18:00, Woodward, Arthur E CTR (US) wrote:

Hello Developers,


I have been having difficulty finding a solution to the problem of
building a modular system for ontological query expansion in Fuseki.


My goal is to be able to run a query over a unionized default graph,
while maintaining the ability to edit the individual named graphs
either from the same dataset or a different dataset.


I have tried many variations of the Fuseki assembler, and after
combing through the documentation and previous e-mails I believe I
have constructed an assembler specification that should be working,
but it is not. From an e-mail by Rohana Rajapakse on Jan 24, 2014
1:52 am it was indicated that a structure like the one in my file
below should allow for an inference engine to be run over a unionized
default graph.


Data added via Fuseki GUI::

DID NOT WORK

Dataset -- Data

Graphs -- default -- (empty, with unionDefaultGraph:true in the
Data.ttl and Reasoner.ttl assembler files)

                Entities --

                              @prefix ex:
<Caution-http://example.org/> .
                              @prefix owl:
<Caution-http://www.w3.org/2002/07/owl#> .
                              @prefix rdf:
<Caution-http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
                              @prefix rdfs:
<Caution-http://www.w3.org/2000/01/rdf-schema#> .
                              @prefix zoo:
<Caution-http://example.org/zoo/> .



                              ex:dog1  a      ex:animal .

                              ex:cat1  a      ex:cat .

                              ex:zoo1  zoo:host  ex:cat2 .

                              ex:cat3  owl:sameAs  ex:cat2 .



              Ontology --

                              @prefix ex:
<Caution-http://example.org/> .
                              @prefix owl:
<Caution-http://www.w3.org/2002/07/owl#> .
                              @prefix rdf:
<Caution-http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
                              @prefix rdfs:
<Caution-http://www.w3.org/2000/01/rdf-schema#> .
                              @prefix zoo:
<Caution-http://example.org/zoo/> .



                              ex:cat  rdfs:subClassOf  ex:animal .

                              zoo:host  rdfs:range  ex:animal .

Dataset -- Reasoner

              default - (no manually entered data)



Query -- Run over the Reasoner Dataset

PREFIX ex: <Caution-http://example.org/>
PREFIX owl: <Caution-http://www.w3.org/2002/07/owl#>
PREFIX rdf: <Caution-http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <Caution-http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <Caution-http://www.w3.org/2001/XMLSchema#>
PREFIX : <Caution-http://localhost:3030/Test/data/>
PREFIX http: <Caution-http://www.w3.org/2011/http#>

SELECT ?animal
WHERE {
    ?animal a ex:animal .
}
LIMIT 10



0 Results.



If the data in the "Data" dataset is moved from the named graphs to
the default graph and the unionDefaultGraph:true option is commented
out from the Data.ttl file, and the same query above is run, there
are 4 results.

{
    "head": {
      "vars": [ "animal" ]
    } ,
    "results": {
      "bindings": [
        {
          "animal": { "type": "uri" , "value":
"Caution-http://example.org/dog1"; }
        } ,
        {
          "animal": { "type": "uri" , "value":
"Caution-http://example.org/cat1"; }
        } ,
        {
          "animal": { "type": "uri" , "value":
"Caution-http://example.org/cat2"; }
        } ,
        {
          "animal": { "type": "uri" , "value":
"Caution-http://example.org/cat3"; }
        }
      ]
    }
}



Data.ttl::

        1 @prefix :      <Caution-http://base/#> .
        2 @prefix tdb:   <Caution-http://jena.hpl.hp.com/2008/tdb#> .
        3 @prefix rdf:
<Caution-http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
        4 @prefix ja:
<Caution-http://jena.hpl.hp.com/2005/11/Assembler#> .
        5 @prefix rdfs:
<Caution-http://www.w3.org/2000/01/rdf-schema#> .
        6 @prefix fuseki: <Caution-http://jena.apache.org/fuseki#> .
        7
        8 :service_tdb_all  a                   fuseki:Service ;
        9         rdfs:label                    "TDB Data" ;
       10         fuseki:dataset                :tdb_dataset_readwrite ;
       11         fuseki:name                   "Data" ;
       12         fuseki:serviceQuery           "query" , "sparql" ;
       13         fuseki:serviceReadGraphStore  "get" ;
       14         fuseki:serviceReadWriteGraphStore
       15                 "data" ;
       16         fuseki:serviceUpdate          "update" ;
       17         fuseki:serviceUpload          "upload" .
       18
       19 :tdb_dataset_readwrite
       20         a             tdb:DatasetTDB ;
       21         tdb:location
"/home/evan/Documents/apache-jena-fuseki-2.3.1/run/databases/Data" ;
       22        tdb:unionDefaultGraph true ;
       23         .
       24



Reasoner.ttl::

@prefix :      <Caution-http://base/#> .
        2 @prefix tdb:   <Caution-http://jena.hpl.hp.com/2008/tdb#> .
        3 @prefix rdf:
<Caution-http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
        4 @prefix ja:
<Caution-http://jena.hpl.hp.com/2005/11/Assembler#> .
        5 @prefix rdfs:
<Caution-http://www.w3.org/2000/01/rdf-schema#> .
        6 @prefix fuseki: <Caution-http://jena.apache.org/fuseki#> .
        7
        8 :service1  a                          fuseki:Service ;
        9         fuseki:dataset                :tdb_dataset_readwrite ;
       10         fuseki:name                   "Reasoner" ;
       11         fuseki:serviceQuery           "query" , "sparql" ;
       12         fuseki:serviceReadGraphStore  "get" ;
       13         fuseki:serviceReadWriteGraphStore
       14                 "data" ;
       15         fuseki:serviceUpdate          "update" ;
       16         fuseki:serviceUpload          "upload" .
       17
       18 tdb:GraphTDB rdfs:subClassOf ja:Model .
       19 tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
       20
       21 :tdb_dataset_readwrite  a          ja:RDFDataset ;
       22         ja:defaultGraph :model2 ;
       23         ja:namedGraph
       24            [ ja:graphName "Data" ;
       25              ja:graph     :graph ] ;
       26         .
       27
       28 :tdb_intermediate_dataset a tdb:DatasetTDB ;
       29     tdb:location
"/home/evan/Documents/apache-jena-fuseki-2.3.1/run/databases/Data";
       30     tdb:unionDefaultGraph true ;
       31     .
       32
       33 :graph rdf:type tdb:GraphTDB ;
       34     tdb:dataset :tdb_intermediate_dataset
       35     .
       36
       37 :model2 a ja:InfModel ;
       38         ja:reasoner  [ ja:reasonerURL
<Caution-http://jena.hpl.hp.com/2003/OWLFBRuleReasoner> ] ;
       39         ja:baseModel :graph ;
       40         .
       41
       42



What I have found is that if data is entered into the default graph
in the "Data" dataset without the unionDefaultGraph option, this
"Reasoner" dataset (above) will find the information and perform
inferences over it. However, if the data is instead entered into two
named graphs, with the unionDefaultGraph:true option selected, the
"Reasoner" dataset is unable to find the information in "Data".
Additionally, the "Reasoner" dataset has no access to read or write
to the "Data" dataset, which is why I set up a separate end-point to
be able to manipulate the data in "Data".



The goal of this experiment is to be able to run different Owl
ontologies over the same entity data, so ideally there would be a way
to create a unionized graph from two named graphs in "Data" and query
time, and then run the inference engine over this graph. So my
questions are,



1) Is there a way to create a unionized graph at query time? If yes,
is there a way to run an inference engine over this
query-time-created unionized graph?



2) If the above is not an option, is there a way have an inference
engine run over the unionized default graph from a set of named graphs?



I submitted this question to the users list a few weeks ago, but have
had no responses. If you have any questions or need more information
please feel free to reach out to me at any time.




Thank you for your help,

Evan Woodward




Reply via email to