Comments (5)
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.
@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.
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.
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.
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)
- Remove `src/` export
- Any way to recover from unescaped double quotes? HOT 2
- N3.js is too lenient on string escapes
- Mark `readQuads` as deprecated
- Incorrect parsing of empty Notation3 graph terms HOT 1
- Incorrect parsing of a list containing a Notation3 graph term HOT 1
- Web Streams API support? HOT 4
- Can this write blank nodes with multiple predicate/object pairs? HOT 4
- README error on use of store.add() HOT 1
- N3 writer doesn't prefix correctly HOT 3
- `removeMatches` removes quads from `Store` asynchronously HOT 4
- @base set by baseIRI is not shown in the prefixes part of the document
- Store Token position in the produces quads HOT 1
- How to wait for parsing to be done? HOT 2
- How to use streams to write quads (without a ReadStream) HOT 2
- Usage of `import` as method names HOT 3
- Circular imports HOT 4
- Triples containing Variable result in invalid turtle HOT 3
- CURIE like s:a/b/c not supported HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from n3.js.