Closed RubenVerborgh closed 7 years ago
The confusing part of it is inconsistency - there's only two types of URIs in play here: http://www.wikidata.org/prop/direct/P and http://www.wikidata.org/prop/P - and they are resolved properly with @context
clause. However how they are treated in main body looks strange - sometimes it's just P, sometimes it's prefixed P.
@smalyshev replied:
After thinking a bit about it I think I've found the logic behind it: when it encounters first P-statement, it uses only suffix and puts the full URL in @context. However when it encounters second URI with the same suffix, it uses the prefix and then there's no need in @context. Since the statements can be encountered in any order in the DB, it's not consistent which of the two gets @context and which gets prefix.
The algorithm for parsing it would be checking if the key has :, if yes, resolve against prefix, if not - resolve against @context.
This is a Java server issue?
Yes.
Will investigate.
The JSON-LD is generated by Jena (https://github.com/LinkedDataFragments/Server.Java/blob/master/src/main/java/org/linkeddatafragments/views/RdfWriterImpl.java#L51), so we are depending on whatever serialization technique they use. I suggest filing an issue there. However, if we would encounter such issues in other serializations, it might be a datasource problem (but that doesn't seem the case).
Reported by Lucas Werkmeister on the Wikidata mailing list
I tried playing with it a bit and noticed an oddity in the JSON format: if the predicate and object are both left unspecified, "P_" keys will sometimes refer to full statement nodes and sometimes to truthy values. An example item with not too many statements where you can witness this is Q26536085:
Right now, I get the following results:
As you can see, the "P" key sometimes refers to the full statement node ("wds:") and sometimes to the direct, truthy value ("wd:Q"). Where "P" points to the statement node, there’s also a "wdt:P" entry (sometimes pointing directly at a string containing the ID, sometimes pointing to an { "@id": } object); conversely, where "P" points to the truthy value, there’s a "p:P" entry to an { "@id": _ } object.
Is there any reason why different representations are chosen? Is this predictable? Is this a bug? Or is this just something you have to work around using the @context information if you want to use the JSON format? (The other data formats don’t seem to have this problem, since they don’t use unprefixed "P_" keys.)