Comments (4)
Good idea, should be easy to implement.
In theory the only thing that we'd need to do is forward the prefix events from Comunica's quad stream and delegate it to our readable
.
from rdf-parse.js.
I am not sure what is going on: if it is my implementation error, or there is still something missing: I can already get working callbacks for the "prefix" and the "context" events (json+ld of course), but they seem to have no parameters specified:
rdfParser.parse(textStream, { contentType: syntax }) .on('prefix', (a) => { console.log(a) }) .on('context', (b) => { console.log(b) }) .on('data', (quad) => { data.push(quad) }) .on('error', (e) => { reject({ error: e} ) }) .on('end', () => { resolve({quads: data})
both functions get executed, and both print "undefined" on the console.
Can you help?
from rdf-parse.js.
@fvitali I'm surprised that prints anything to be honest.
In any case, this feature is not implemented yet, so it's normal that it's not working as intended.
You're welcome to submit a PR though! :-)
from rdf-parse.js.
I submitted two separate Pull requests, one here and another on N3.js, to fully enable support for prefix and context callbacks.
I am not really sure about the N3.js, as I was not able to fully follow the complex chain of required module. Anyway, this now works for me.
Working code:
async function parseRDF(text, syntax) { const textStream = streamify(text+""); try { var d = await new Promise( (resolve, reject) => { var data = [] rdfParser.parse(textStream, { contentType: syntax }) .on('prefix', (prefix,iri) => { console.log(prefix) }) .on('context', (c) => { console.log(c) }) .on('data', (quad) => { data.push(quad) }) .on('error', (e) => { reject( e ) }) .on('end', () => { resolve({quads: data}) } ); }) return d } catch (e) { return { error: e} } }
from rdf-parse.js.
Related Issues (20)
- An in-range update of @comunica/actor-rdf-parse-jsonld is breaking the build 🚨 HOT 2
- An in-range update of @comunica/actor-rdf-parse-html-rdfa is breaking the build 🚨 HOT 1
- An in-range update of @comunica/actor-rdf-parse-html is breaking the build 🚨 HOT 1
- An in-range update of @comunica/actor-rdf-parse-jsonld is breaking the build 🚨 HOT 1
- An in-range update of @comunica/actor-rdf-parse-xml-rdfa is breaking the build 🚨 HOT 1
- An in-range update of @comunica/actor-rdf-parse-n3 is breaking the build 🚨 HOT 1
- Needless circular import between index and engine-default HOT 1
- An in-range update of @types/n3 is breaking the build 🚨 HOT 1
- An in-range update of @types/jest is breaking the build 🚨 HOT 1
- Potential stream piping problem
- Action Required: Fix Renovate Configuration
- Dependency Dashboard
- browserify or webpack: action.input.on is not a function HOT 8
- Having trouble passing JSON-LD context using options HOT 2
- parse method is undefined HOT 9
- OWL support? HOT 1
- Listed RDF serialization support does not match `CONTENT_MAPPINGS` HOT 1
- Module causes Error when using Vite HOT 1
- Remove default export
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 rdf-parse.js.