Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No output from log:callWithOptional or log:bound #82

Open
tpluscode opened this issue Mar 15, 2023 · 12 comments
Open

No output from log:callWithOptional or log:bound #82

tpluscode opened this issue Mar 15, 2023 · 12 comments

Comments

@tpluscode
Copy link

Based on a discussion, we created a rule similar to that below.

It works in eye but there is not output when switched to eye-js.

@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix : <http://example.com/>.

:object1 :Title :title1.
:title1 :Type :type1.
:object2 :Title :title2.
:object3 :Title :title3.
:title3 :Type :type3.

{
  {
    ?object :Title ?title.
  } log:callWithOptional {
    ?title :Type ?type.
  }.
  ?type log:bound false.
} => {
  ?object :TitleWithoutType ?title.
}.

https://n3-editor.herokuapp.com/n3/editor/s/QjFkNFED

@josd
Copy link
Collaborator

josd commented Mar 15, 2023

@william-vw would it be possible to work with the latest eye-js that is https://eyereasoner.github.io/eye-js/latest/index.js instead of https://eyereasoner.github.io/eye-js/3/latest/index.js ?
Or if not possible, then at least work with https://eyereasoner.github.io/eye-js/4/latest/index.js

@tpluscode
Copy link
Author

Oh, the UI is using an old version? That's a red herring apparently

We are still having issues with the JS lib, but as it turns out, only when passing in quads:
https://runkit.com/embed/xa0qvolbwp7s

When the input is an n3 string, the output is as expected: https://runkit.com/embed/aywnzamumxq0

Problem with n3 parser?

@tpluscode
Copy link
Author

AHA, got it. Here's what happens. When we pass in parsed quads, they get serialised by the JS in a different order

{
  ?type <http://www.w3.org/2000/10/swap/log#bound> false .
  {
    ?object <http://example.com/Title> ?title .
  }
  <http://www.w3.org/2000/10/swap/log#callWithOptional> {
    ?title <http://example.com/Type> ?type .
  } .
} => {
  ?object <http://example.com/TitleWithoutType> ?title .
} .

<http://example.com/object1> <http://example.com/Title> <http://example.com/title1> .
<http://example.com/title1> <http://example.com/Type> <http://example.com/type1> .
<http://example.com/object2> <http://example.com/Title> <http://example.com/title2> .
<http://example.com/object3> <http://example.com/Title> <http://example.com/title3> .
<http://example.com/title3> <http://example.com/Type> <http://example.com/type3> .

Written this way, the output of eye is also wrong: https://n3-editor.herokuapp.com/n3/editor/s/LEtH5WsO

@josd
Copy link
Collaborator

josd commented Mar 16, 2023

You are right, this is indeed order dependent and we added a log:call to impose an order: first call subject, then call object.
So with

{
    {
        {
            ?object <http://example.com/Title> ?title .
        } <http://www.w3.org/2000/10/swap/log#callWithOptional> {
            ?title <http://example.com/Type> ?type .
        } .
    } <http://www.w3.org/2000/10/swap/log#call> {
        ?type <http://www.w3.org/2000/10/swap/log#bound> false .
    } .
} => {
  ?object <http://example.com/TitleWithoutType> ?title .
} .

<http://example.com/object1> <http://example.com/Title> <http://example.com/title1> .
<http://example.com/title1> <http://example.com/Type> <http://example.com/type1> .
<http://example.com/object2> <http://example.com/Title> <http://example.com/title2> .
<http://example.com/object3> <http://example.com/Title> <http://example.com/title3> .
<http://example.com/title3> <http://example.com/Type> <http://example.com/type3> .

and EYE v3.10.0 it should just give

<http://example.com/object2> <http://example.com/TitleWithoutType> <http://example.com/title2>.

@tpluscode
Copy link
Author

So log:call is something new added only in 3.10?

@josd
Copy link
Collaborator

josd commented Mar 16, 2023

Yes indeed it is added in EYE v3.10.0 and PH2 v1.1.0

@william-vw
Copy link

@william-vw would it be possible to work with the latest eye-js that is https://eyereasoner.github.io/eye-js/latest/index.js instead of https://eyereasoner.github.io/eye-js/3/latest/index.js ? Or if not possible, then at least work with https://eyereasoner.github.io/eye-js/4/latest/index.js

Ok - I switched the editor to https://eyereasoner.github.io/eye-js/latest/index.js

@josd
Copy link
Collaborator

josd commented Mar 16, 2023

Great and thanks a lot @william-vw !
https://n3-editor.herokuapp.com/n3/editor/s/z8ZKamOl now works perfectly with eye-js

@tpluscode
Copy link
Author

You are right, this is indeed order dependent and we added a log:call to impose an order: first call subject, then call object.

I am slightly surprised by this. When parsed, triples have not order. I see how the graphs are chained together by log:call but should that be even necessary?

Given rule like the original above, wouldn't it be possible to determine that the value of ?title needs to be evaluated before the :TitleWithoutType pattern? Regardless of the order of triples...

@josd
Copy link
Collaborator

josd commented Mar 16, 2023

IMHO there is no general algorithm to do a reordering for any kind of premise triples.

@jeswr
Copy link
Collaborator

jeswr commented Mar 20, 2023

Written this way, the output of eye is also wrong: https://n3-editor.herokuapp.com/n3/editor/s/LEtH5WsO

@josd - should this issue be transferred to https://github.com/eyereasoner/eye?

@jeswr jeswr transferred this issue from eyereasoner/eye-js Mar 20, 2023
@josd
Copy link
Collaborator

josd commented Mar 20, 2023

The log:bound built-in is order dependent and the order can be imposed with log:call like done in #82 (comment)
For this particular case we could shift log:bound to the last position of the premis, but IMHO there is no general rule to fix order dependent issues. See also #25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants