-
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
Output RDF/JS terms #80
Output RDF/JS terms #80
Conversation
Looks good indeed!
For the tests, you might want to inject a factory that gives the old output back; then you don't have to adjust any of the tests. |
Updated. The approach mostly works, but there's a problem with literals, more specifically
Some hack is required there to distinguish between lang and datatype literals. |
So can we change |
I guess first we need to have 2 methods
also needs wrapping into RDF/JS structure, correct? And current |
Can't we just delegate to Thanks for all the work so far! |
lib/sparql.jison
Outdated
| 'true' -> XSD_TRUE | ||
| 'false' -> XSD_FALSE | ||
| 'true' -> createLiteral('true', XSD_BOOLEAN) | ||
| 'false' -> createLiteral('false', XSD_BOOLEAN) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to create new literals every time; we can just reuse constants.
I've updated one more time, hopefully now it's easier to see the issue. See how now there are 2 methods in JISON for literals: The core issue is that both of them call
Does that make sense? I don't see a very straightforward fix here, that can differentiate between the two cases. |
function literal(value, tag) {
if (tag)
tag = (tag.length < 10 ? '@' : '^^') + tag;
return '"' + value + '"' + tag;
} |
👍 let me know if you’re stuck, then I can take it from there
|
I'm pretty much stuck now :) |
After a few extra changes all 349 tests pass for me locally. But Travis still fails for some reason. |
Great job, thanks. Seems like you need n3 in package.json 😉
|
Which version of n3? |
1.0 or up
|
@RubenVerborgh so what does this still need in order to be merged? |
The TypeScript bindings probably need updating too? |
An hour or two on my side to check everything; planning that this week. Thanks for the work! |
Passing N3.DataFactory into the Parser constructor jison grammar terms wrapped into DataFactory calls
… having to change test files
Renamed createLiteral() to createTypedLiteral() in JISON
…g and datatype based on tag length
I would strongly suggest to reconsider this for several reasons:
|
We are breaking backward compatibility in any case; this is a semver major change.
It would behave the same way as a term, so serialization to JSON would be thee same.
Agreed, so there should not be a reliance on object identity; but rather on I think homogeneity (all objects, instead of some objects and some strings) weighs more strongly. |
@rubensworks I agree, it should be OK to use a non-identity comparison. For consistency with other nodes it may look as simple as this (in TypeScript syntax):
|
👍 but with |
May I also suggest to add Here are the current typings: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/d2d3a685fe949a4e938fe2913597e49d1e703ef5/types/sparqljs/index.d.ts It would be great to make these changes:
This will simplify query AST traversal/rewriting, e.g. like here: https://github.com/researchspace/researchspace/blob/master/metaphactory/web/src/main/api/sparql/QueryVisitor.ts |
@RubenVerborgh What does this mean for the implementation of Wildcard? Currently Wildcard has termType only |
@simonvbrae |
@simonvbrae All good from your side? |
@RubenVerborgh Wildcard support has been added, as far as I'm concerned this is ready for review and possibly to merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff, just minor nits. You're almost off the hook, @simonvbrae 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! Will be merged, pending approval by @rubensworks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Only a few minor comments.
Can be merged after those have been resolved.
509f3db
to
fa2f7a7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ready to merge! :-)
Thanks all 🎉 |
v3.0.0-beta.0 is out! |
@RubenVerborgh my partial attempt at #73. Is it something along the lines?
I'm not familiar with the setup, just stabbing in the dark here really. So I won't be able to fix the tests easily.
Also not sure if all of
Literal
grammar is covered (wherecreateLiteral()
is not called).XSD_TRUE
/XSD_FALSE
constants might not be required anymore.But otherwise I ran some queries through
sparql-to-json
and I'm getting what I think is expected output.