Code Monkey home page Code Monkey logo

Comments (5)

jacoscaz avatar jacoscaz commented on June 2, 2024 1

Basically can't be parsed by any of the streaming-type parsers such as N3 without the blank nodes all becoming separated from each other / getting different labels?

If we're talking about a single parsing run, this is not correct as per @jeswr 's comment. However, based on my own experience as a newcomer to linked data, I fear you might have stumbled into the fact that multiple parsing runs of the same document may (and often will) result in different sets of quads with different blank nodes, although each set will still correctly reflect the relationships described in the original document.

If this is not the case, then I apologize for the noise. If this is the case, however, let me know and I'd gladly clarify why that is happening to try and spare you the inevitable headaches.

from n3.js.

mikeyhogarth avatar mikeyhogarth commented on June 2, 2024 1

@jacoscaz I wonder if this is the case - I'm doing the parsing run from a frontend framework that may be running the parse multiple times due to reactivity hooks. Thank you for the lead, I will look into this!

@jeswr - that's not what I'm seeing, I'm basically seeing all blank nodes coming back with different numbers regardless, although I don't really want to bother anyone with any more questions until I've looked into @jacoscaz' comment as I think they may be onto something :)

from n3.js.

mikeyhogarth avatar mikeyhogarth commented on June 2, 2024 1

Just to close this one off - I've done some checks myself also and you are right, n3 is parsing these just fine. My issue was that after the parse, I use the resultant N3 Store as a Comunica data source and Comunica is the thing that's making the blank nodes go out of whack (they're fine in the store, it's just after running a comunica query that they get corrupted).

The bug does appear to have been fixed a few weeks ago but they've not put out a release yet, so I guess my issue will just go away once that's out!

from n3.js.

jeswr avatar jeswr commented on June 2, 2024

You should be perfectly fine parsing this with N3.js and maintaining blank node references. In the parser they will be assigned blank node identifiers to reference them; and you will receive a set of statements that looks like the following (as RDF/JS quads)

_:b1 foaf:name "Alice" .
_:b1 foaf:knows _:b2 .
_:b2 foaf:name "Bob" .
_:b2 foaf:knows _:b3 .
...

Closing the issue - but feel free to re-open if you have follow up questions.

from n3.js.

jeswr avatar jeswr commented on June 2, 2024

Just did a sanity check on my end. Indeed bnodes are correctly preserved with your file when parsing in N3 mode.

In particular running the following

const { Parser } = require('n3');

const parser = new Parser({ format: 'text/n3' });

console.log(parser.parse(`
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

[ foaf:name "Alice" ] foaf:knows [
    foaf:name "Bob" ;
    foaf:knows [
        foaf:name "Eve" ] ;
    foaf:mbox <[email protected]> ] .
`));

Gives

[
  Quad {
    id: '',
    _subject: BlankNode { id: '_:n3-0' },
    _predicate: NamedNode { id: 'http://xmlns.com/foaf/0.1/name' },
    _object: Literal { id: '"Alice"' },
    _graph: DefaultGraph { id: '' }
  },
  Quad {
    id: '',
    _subject: BlankNode { id: '_:n3-1' },
    _predicate: NamedNode { id: 'http://xmlns.com/foaf/0.1/name' },
    _object: Literal { id: '"Bob"' },
    _graph: DefaultGraph { id: '' }
  },
  Quad {
    id: '',
    _subject: BlankNode { id: '_:n3-2' },
    _predicate: NamedNode { id: 'http://xmlns.com/foaf/0.1/name' },
    _object: Literal { id: '"Eve"' },
    _graph: DefaultGraph { id: '' }
  },
  Quad {
    id: '',
    _subject: BlankNode { id: '_:n3-1' },
    _predicate: NamedNode { id: 'http://xmlns.com/foaf/0.1/knows' },
    _object: BlankNode { id: '_:n3-2' },
    _graph: DefaultGraph { id: '' }
  },
  Quad {
    id: '',
    _subject: BlankNode { id: '_:n3-1' },
    _predicate: NamedNode { id: 'http://xmlns.com/foaf/0.1/mbox' },
    _object: NamedNode { id: '[email protected]' },
    _graph: DefaultGraph { id: '' }
  },
  Quad {
    id: '',
    _subject: BlankNode { id: '_:n3-0' },
    _predicate: NamedNode { id: 'http://xmlns.com/foaf/0.1/knows' },
    _object: BlankNode { id: '_:n3-1' },
    _graph: DefaultGraph { id: '' }
  }

I suspect @jacosaz is correct in stating that the cause of your error is from parsing the file multiple times.

from n3.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.