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

N3 writer doesn't prefix correctly #372

Open
gezever opened this issue Nov 15, 2023 · 3 comments
Open

N3 writer doesn't prefix correctly #372

gezever opened this issue Nov 15, 2023 · 3 comments

Comments

@gezever
Copy link

gezever commented Nov 15, 2023

const N3 = require('n3');
const { DataFactory } = N3;
const { namedNode, quad } = DataFactory;
const writer = new N3.Writer({ prefixes: {   ex1: 'http://example.org/' } });
writer.addQuad(
    namedNode('http://example.org/s1'),
    namedNode('http://example.org/p'),
    namedNode('http://example.org/1')
);
writer.addQuad(quad(
    namedNode('http://example.org/s2'),
    namedNode('http://example.org/p'),
    namedNode('http://example.org/_1')
));
writer.addQuad(quad(
    namedNode('http://example.org/s3'),
    namedNode('http://example.org/p'),
    namedNode('http://example.org/v1.0')
));
writer.end((error, result) => console.log(result));

expected results:

@prefix ex1: <http://example.org/>.

ex1:s1  ex1:p   ex1:1 .
ex1:s2  ex1:p   ex1:_1 .
ex1:s3  ex1:p   ex1:v1.0 .

results:

@prefix ex1: <http://example.org/>.

ex1:s1 ex1:p <http://example.org/1>.
ex1:s2 ex1:p ex1:_1.
ex1:s3 ex1:p <http://example.org/v1.0>.
@TallTed

This comment was marked as resolved.

@gezever gezever changed the title N3 writer doesn't prefix integers correctly N3 writer doesn't prefix correctly Nov 16, 2023
@gezever
Copy link
Author

gezever commented Nov 16, 2023

@TallTed
I edited the issue.

@RubenVerborgh
Copy link
Member

N3.js does not strive for the shortest form; it adds some prefixes but not exhaustively, and this for performance reasons. That said, in this case, the regex can easily be adjusted, presumably without performance impact.

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

3 participants