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

possible serialization issue #208

Closed
giacomociti opened this issue Mar 24, 2023 · 5 comments
Closed

possible serialization issue #208

giacomociti opened this issue Mar 24, 2023 · 5 comments

Comments

@giacomociti
Copy link

the following rule works fine in the browser but gives no result using node.

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

:a :b :c, :d .

{
    (?x
     {:a :b ?x }
     ?list) log:collectAllIn _:x .
}
=>
{
  :result :is ?list
} .

Apparently, its serialization in the temporary file is missing {:a :b ?x }

<http://ex.org/a> <http://ex.org/b> <http://ex.org/c> . 
<http://ex.org/a> <http://ex.org/b> <http://ex.org/d> . 

{
 _:n3-1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> ?x . 
 _:n3-1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:n3-3 . 
 _:n3-1 <http://www.w3.org/2000/10/swap/log#collectAllIn> _:n3-0.x . 
 _:n3-3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> ?list . 
 _:n3-3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> . 
 } => {<http://ex.org/result> <http://ex.org/is> ?list . } . 
@jeswr
Copy link
Member

jeswr commented Mar 24, 2023

the following rule works fine in the browser but gives no result using node.

I'm assuming that if you use strings in node it works fine but if you give RDF/JS input and request string output then you get this problem?

@jeswr
Copy link
Member

jeswr commented Mar 24, 2023

The fix should be easy - we just need the same logic as

if (isQuoted(entity, store)) {
return `{${this.quadsStoreToString(store, entity)}}`
}
in the _encodePredicate method in lib/n3Writer.temp.ts.

Could you make a PR with the changes?

@giacomociti
Copy link
Author

the following rule works fine in the browser but gives no result using node.

I'm assuming that if you use strings in node it works fine but if you give RDF/JS input and request string output then you get this problem?

exactly

@giacomociti
Copy link
Author

Actually, I think the problem is not in eye-js but in the N3 parser:

import { Parser } from 'n3'

const text = `
@prefix : <http://ex.org/> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .

:a :b :c, :d .

{
    (?x {:a :b ?x } ?list) log:collectAllIn _:x .
}
=>
{
  :result :is ?list
} .
`
const quads = new Parser({ format: 'text/n3' }).parse(text)
console.log(quads.map(x => `${x.subject.value} ${x.predicate.value} ${x.object.value} ${x.graph.value}`))

// 'http://ex.org/a http://ex.org/b http://ex.org/c ',
// 'http://ex.org/a http://ex.org/b http://ex.org/d ',
// 'n3-1 http://www.w3.org/1999/02/22-rdf-syntax-ns#first x n3-0',
// 'http://ex.org/a http://ex.org/b x n3-2',
// 'n3-1 http://www.w3.org/1999/02/22-rdf-syntax-ns#rest n3-3 n3-0',
// 'n3-3 http://www.w3.org/1999/02/22-rdf-syntax-ns#first list n3-0',
// 'n3-3 http://www.w3.org/1999/02/22-rdf-syntax-ns#rest http://www.w3.org/1999/02/22-rdf-syntax-ns#nil n3-0',
// 'n3-1 http://www.w3.org/2000/10/swap/log#collectAllIn n3-0.x n3-0',
// 'http://ex.org/result http://ex.org/is list n3-4',
// 'n3-0 http://www.w3.org/2000/10/swap/log#implies n3-4 '

here the list links n3-1 directly to n3-3,skipping n3-2

@giacomociti
Copy link
Author

rdfjs/N3.js#342

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

2 participants