-
Notifications
You must be signed in to change notification settings - Fork 66
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
Switch to RDF/JS representation #73
Comments
Thanks for volunteering.
I would propose the RDF/JS interface:
http://rdf.js.org
What you could do is pass in a factory to the parser constructor (RDF/JS
has this). That way, you can have your favorite JSON output, and others can
have their own.
Essentially, the needed changes should just be passing in the factory and
calling its methods to create terms and triples.
Good plan? If so, I can give you some suggestions on how to get started.
Ruben
|
Amazing one! Please do |
Something I miss in it is an explicit representation for a Prefixed URI. Do you know if it includes it? |
It does not, becaude that is only syntactical, not in RDF terms. But I have
a solution if you need it.
|
I think we should use the RDF/JSON as you suggested and additionally define a prefixed URI and variable types. What do you think? |
JSON-LD ? |
RDF/JS does have variables in there already. It purposely does not have a prefixed URI, because that is not a different term type.
|
The main function of the parse tree is to use it within JavaScript, not exchanging it across implementations. For exchange, I'd recommend the SPARQL query itself. |
Proposed plan of implementation (AKA how I would do it, but your opinion might differ):
|
FYI Linked to this in the README: 836017e |
How about using SPIN SPARQL syntax as RDF representation? https://www.w3.org/Submission/spin-sparql/ |
Because this is a JavaScript library it makes the most sense to use a spec made for JavaScript representation of RDF. Also, the main goal is to be able to easily distinguish between term types without further string parsing. |
@RubenVerborgh does the change require changing the JISON syntax file as well? |
You'll still need a vocabulary for the JSON representation. Why invent the bike? Stand on the shoulders of giants, and all that... |
We’re not looking for an RDF representation, but rather for a JavaScript in-memory representation. |
Yes, but only to its JavaScript parts that generate terms. |
I'd need help with that. Unfortunately, I have never written something like BISON or JISON |
It's pretty easy, as all the Jison stuff has been written already and you don't really have to touch it for this. All you need to alter is the JavaScript embedded within the Jison. For example: $$ = resolveIRI(expansion + $1.substr(namePos + 1)); will become something like var uriString = resolveIRI(expansion + $1.substr(namePos + 1));
$$ = factory.namedNode(uriString); |
How big of a task would this be? Is it only the s/p/o that need to be changed or more than that? |
Just the s/p/o; summary right above 🙂 Thanks for taking a stab at this. |
@RubenVerborgh What do you think? Is this worth it? and what solution do you recommend? |
Hmm, interesting case. @rubensworks is there something to be said for a superclass of Term (SparqlTerm?) of which WildcardTerm is an instance? |
I think if we go down the route of creating a new Term type, we may run into issues with packages downstream, as these will not know how to handle this special Term type. Simply making all values of the In any case, there is no one clean solution I'm afraid, other than changing the RDFJS spec, which would also not be very clean. |
Slight difference perhaps: I wrote superclass of Term. It could still implement all Term methods and properties (mainly equals to false), but would (strictly) not be a Term. |
Sure, we could try that. |
Keep in mind that changes will also propagate to TypeScript bindings: Type structure changes will break code. |
Hopefully TypeScript defs are versioned? Will be a semver major in any case.
|
I am not sure actually. They're simply on a Git repo. From this it looks like versioning is not supported: DefinitelyTyped/DefinitelyTyped#7719 Maybe @AlexeyMz could help, he's the author of the typings. Currently they say:
|
@namedgraph DefinitelyTyped covers this situation in the README:
So we should be fine with moving current typings into |
We extensively use Sparql.js in our projects and usually you don't want to treat |
This is very true. The tree should reflect the query |
SPARQLAlgebra will need rewriting after this update anyway. But in the conversion I immediately convert '*' to the correct variables so I won't be using much of this new term anyway. |
Released as 3.0.0-beta.0 via #80. |
Apologies for resurrecting an old issue but it seems to be the most appropriate place for me to point out what follows. It looks like the typings at https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/sparqljs/index.d.ts have not been updated after the transition to RDF/JS. I double-checked with @rubensworks on gitter.im to make sure I wasn't missing anything and this does seem to be the case. Has any work ever been put on this? |
Currently RDFTerms (Literals, IRIs and prefixed IRIs) are represented as strings.
I suggest to use the RDF/JSON representation for RDF values.
Also, prefixed IRIs should be distinguished from IRIs.
Should return
We'd be happy to offer a PR
The text was updated successfully, but these errors were encountered: