-
Notifications
You must be signed in to change notification settings - Fork 11
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
Simple literals are masked #127
Comments
From the RDF 1.1 specification:
Which means that a simple literal with no datatype is semantically equivalent to a literal (with the same lexical form) typed with |
Well, then the SPARQL spec is inconsistent, or at least confusing in respect to this matter. Thanks for the prompt reply. |
Btw, graphy will let you know whether or not you parsed the literal from a simple literal, see here: https://github.com/blake-regalia/graphy.js/blob/master/README.md#literal-extends-term-implements-rdfjs-literal |
@blake-regalia that's an interesting approach, i believe in rdf-data-model it would work as well. It's not quite robust, but it's something! |
What is not robust about it? Can you give an example? I'd be curious to hear more. |
The moment serializing and deserializing is done, or any library in a data pipeline would in any way, shape, or form just copy the datatype, this cool trick would no longer work. |
Sure, but at that point it's sort of out of the hands of the parser anyways. Would you find it more appropriate if there was a meta-data flag on the Literal object as well, such as |
It's a syntactical difference; this should not end up in the model. For all purposes, |
Yes, we're not discussing incorporating this in the model -- just a conversation about a library feature that tracks syntactic metadata. |
Yeah, so I would advice against |
Looking at references to SPARQL 1.1 spec, I agree it seems to have certain lack of clarity https://www.w3.org/TR/sparql11-query/#func-strings
Section above seems to distinguish between https://www.w3.org/TR/sparql11-query/#func-regex
https://www.w3.org/TR/sparql11-query/#func-langMatches
Seems to expect only a On the other hand, If needed we could try to ask @blake-regalia in what scenarios to you need to know if serialization used simple literal or one with explicit |
It is possibly worth noting that the SPARQL 1.1 specification predates the RDF 1.1 specification by about a year. And so a SPARQL 1.1 compliant endpoint is not necessarily compliant with RDF 1.1, which would affect how simple vs. typed string literals are matched. |
@elf-pavlik Moreover, graphy simply tries to preserve syntactic information from the document in case the user can find it handy. This may seem silly at first glance, but when you consider the incredible performance boost from using the @RubenVerborgh why does it matter if a library extends the interface spec with its own properties? |
There's a difference between preserving syntactic information in the in-memory representation versus emitting events as they are parsed (which indeed is an interesting idea). The graph event is only meaningful because of the temporal context, which is absent with the original case under discussion here.
It doesn't, but you could equally maintain whether the string was single, double, or triple-quoted: each of these differences have as much meaning as whether or not But actually, given how V8 is implemented, I'm suspect you'll see performance differences in functions accepting a literal as argument, because there will be two different underlying internal classes: one where |
@blake-regalia you are very correct that at one point the it will be 'out of the hands of the parser'. That's exactly why I wouldn't base (my use case) a small library on this neat trick, as I make no assumptions about the incoming data, except that it conforms to the rdfjs model. I feel the issue at hand (for me atleast) is the SPARQL spec being inconsistent with the RDF spec, so i'll just work around that (and tbh, the issue is quite minimal actually). |
As of 2004, the RDF model had an abstract syntax:
or more succinctly:
In 2008, SPARQL asserted that [
but you could still see the difference with the In 2014, the RDF 1.1 WG decided that the pain of maintaining a distinction between simple literal and xsd:string-typed literal exceeded the pain of migration to a model where everything had a datatype. In the latter model, parsers that appeared to have a simple literal form were expected to produce literals with type |
I could not have wished for a better explanation. Thanks :) |
Due to https://github.com/rdfjs/representation-task-force/blob/master/interface-spec.html#L231-L233
you can't create simple literals, as they would automatically become typed literals with a xsd:string datatype.
I can see why this makes sense from a usability perspective (or some spec stuff I don't know about), but wouldn't it also make sense to not do this? As the RDFJS data model arguably is an interop and representation format, information that is lost like this is might not be recoverable (eg. if you don't control the parsing of the query/expression/triples/...).
Relevant problem: some functions in the SPARQL spec, specifically those on strings explicitly only take simple literals (eg: regex, langMatches) as arguments.
What is the argumentation behind this choice?
The text was updated successfully, but these errors were encountered: