On 12/10/2020 01:02, Marcelo Machado wrote:
Thank you Andy, however the error persists.

Let me send you a part of the data I'm trying to upload:

:model_inf a ja:InfModel ;
     ja:baseModel :tdbGraph ;
     ja:reasoner [
     ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
     ja:rule "[
         #-*-mode: conf-unix-*-
         @prefix time: <http://www.w3.org/2006/time#>
         @include <owlmicro>

         -> table(owl:sameAs).


#---------------------------------------------------------------------------
         # Equality

#---------------------------------------------------------------------------

         sameAs_symmetry:
         (?x owl:sameAs ?y)
         -> (?y owl:sameAs ?x) .
     ]";
]
.

There are a couple of things wrong with the syntax:


1/ Use """ to enclose the rules because it is a multiple line string in Turtle.

2/ Comments in rules are # in column 1 and the
"# Equality" and "#-*-mode: conf-unix-*-" are not in col 1.

3/ ....] go round a single rule

this works for me:

===== Extract ====================
 ja:reasoner [
    ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
    ja:rule """
        @prefix time: <http://www.w3.org/2006/time#>
        @include <owlmicro>

        -> table(owl:sameAs) .

# Equality
        [sameAsSymmetry: (?x owl:sameAs ?y) -> (?y owl:sameAs ?x) ]

    """;
]
.
==================================

    Andy



The error:

20:52:05 WARN  Admin           :: [2] RC = 500 : caught: Expected '(' at
start of clause, found @prefix

At '[ #-*-mode: conf-unix-*- @prefix '

org.apache.jena.assembler.exceptions.AssemblerException: caught: Expected
'(' at start of clause, found @prefix

At '[ #-*-mode: conf-unix-*- @prefix '

at
org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.openBySpecificType(AssemblerGroup.java:165)
~[fuseki-server.jar:3.17.0-SNAPSHOT]


At.te,

Marcelo de Oliveira Costa Machado


Em dom., 11 de out. de 2020 às 07:52, Andy Seaborne <[email protected]>
escreveu:



On 09/10/2020 18:42, Marcelo Machado wrote:
I just downloaded the binary distribution of Fuseki2 and used the
./fuseki_server command to start a server. But I will get the development
build.

Build ready:


https://repository.apache.org/content/groups/snapshots/org/apache/jena/apache-jena-fuseki/3.17.0-SNAPSHOT/

look for the latest

At least dated:

Sun Oct 11

apache-jena-fuseki-3.17.0-20201011



Just pointing out, I believe that the problem is not only with prefix but
with any directives other than the rules, for example, @include
<owlmicro>

That's covered as well.

      Andy


Thank you very much.

At.te,

Marcelo de Oliveira Costa Machado


Em sex., 9 de out. de 2020 às 11:11, Andy Seaborne <[email protected]>
escreveu:



On 09/10/2020 13:46, Marcelo Machado wrote:
Yes, that is the problem, ja:rule does not accept some directives. If
the
problem was just prefixes I could resolve that by parsing the entire
content, however, I use some directives like @include to add other owl
rules.

If I use ja:rulesFrom with <file://...> everything works fine. But in
that
case, I have to save the file in my server and I would not like to do
that.
If not ja:rule I don't know what to do so, I didn't find any doc about
that
(actually seams that what I want is not possible with fuseki).

I've created a ticket
https://issues.apache.org/jira/browse/JENA-1977

and also a tried a quick hack that didn't cause the test suite to
complain so it may be possible to add the header @-directs (and
incidently comments) processing.

How are you getting Fuseki? If it is one of the downloads, could you
test a development build which would speed getting a fix done in time
for the next release.

       Andy



At.te,

Marcelo de Oliveira Costa Machado


Em sex., 9 de out. de 2020 às 08:47, Andy Seaborne <[email protected]>
escreveu:



On 08/10/2020 19:22, Marcelo Machado wrote:
Hello Andy,

I manually escaped \n and " characters and some errors were
corrected,
thanks.  However, consider that I want to use the following string
rules
(
string_rules_variable):

I think (maybe someone can confirm) ja:rule is one or more rules, but
not a full rules file with features of prefixes and other directives.

Does a rule if you use URIs?

        Andy


#-*-mode: conf-unix-*-
@prefix time: <http://www.w3.org/2006/time#>
@include <owlmicro>

-> table(owl:sameAs).

#-----------------------------

sameAs_symmetry:
(?x owl:sameAs ?y)
-> (?y owl:sameAs ?x).

And as I said before this is how I am using in fuseki:
:model_inf a ja:InfModel ;
         ja:baseModel :tdbGraph ;
         ja:reasoner [
             ja:reasonerURL <
http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
             ja:rule "[string_rules_variable]"`;

But Fuseki is not recognizing prefix:


org.apache.jena.assembler.exceptions.AssemblerException: caught:
Expected '(' at start of clause, found @prefix



Do you have any thoughts on how to solve this?

Thanks in advance!






At.te,

Marcelo de Oliveira Costa Machado


Em qui., 8 de out. de 2020 às 05:47, Andy Seaborne <[email protected]>
escreveu:



On 08/10/2020 07:41, Marcelo Machado wrote:
I am trying to create my own property rules in fuseki. To do so I
am
using
the Generic Rule Reasoning that allows me to use my own rules.
When I
use
this strategy with my rules in a file everything works fine:

:model_inf a ja:InfModel ;
         ja:baseModel :tdbGraph ;
         ja:reasoner [
             ja:reasonerURL <
http://jena.hpl.hp.com/2003/GenericRuleReasoner>
;
             ja:rulesFrom <file://...> ;
         ] .

However, I would not want to use a file but add the rules directly
as a
string. I tried just to copy the content of the rule files that
worked
in
the example above, but the repository was not created, apparently
due
to
special characters (e.g. #, \n...):

:model_inf a ja:InfModel ;
         ja:baseModel :tdbGraph ;
         ja:reasoner [
             ja:reasonerURL <
http://jena.hpl.hp.com/2003/GenericRuleReasoner>
;
             ja:rule "[${string_rules_variable}]"`;

At a minimum that will need Turtle escapes for newlines. A
NodeFormatter
      formst outout - the Turtle rules are available directly via
EscapeStr.stringEsc(string).

The full grammar details are here:
https://www.w3.org/TR/turtle/#terminals

If you need to be it your self, it'll need newline  and " handling,
two
character \n and \"

         Andy

         ] .
where ${string_rules_variable} (javascript string interpolation)
contains
the rules read from the file.

So, what am I doing wrong? I believe this is about escaping special
characters, if so, what would be the way to resolve it?

At.te,

Marcelo de Oliveira Costa Machado









Reply via email to