Naive JSON for next WD?
Markus Demleitner
msdemlei at ari.uni-heidelberg.de
Tue Mar 17 15:11:24 CET 2020
Dear Semantics,
I'm about to revise Vocabularies 2 for the next WD, and I'm
contemplating a major change with respect to the current requirement
2.2.8 "Simple cases do not require RDF tooling".
So far, we're covering this requirement by restricting our RDF-XML in
all sorts of ways to be reasonably easy to parse with just a common XML
parser. That's still tricky enough, as you can see in the subsections
on "Usage with plain XML tooling", 3.1.3, 3.2.3, and 3.3.3 (e.g.,
http://ivoa.net/documents/Vocabularies/20190905/WD-Vocabularies-2.0-20190905.html#tth_sEc3.2.3).
To see if that works at all, I've written a little python module,
revovo[1], and it turned out that all these recipes are still about 200
lines of moderately tricky python. Hmpf.
But then I noticed that as far as its later clients are concerned, all
that this module does is expose a relatively plain class that lets you:
* figure out the terms, their labels and descriptions,
* see what terms are deprecated and
* which are preliminary,
* inspect the hierarchy of terms, and
* for nerds that perhaps want to peek into RDF, get the base URI and the
flavour of the vocabulary.
The nice thing about this is that you don't have to know anything about
RDF and all its magic to use this. And so I thought: Why have 200 lines
of code to produce some native python class when I can just
distribute... well, JSON that gives that info as well and have the
information in pretty much that form immediately in essentially all
languages that are out there.
Of course, I'm always skeptical about "look, JSON, it's simple", and,
worse, there are already of order 10^1 serialisations of RDF in JSON
(which, worse, I've not even seriously investigated). Adding another
mogrification of some specific sort of RDF into some rather specialised
sort of JSON sounds like something I would condemn and curse if it
didn't happen to be me who's seriously considering to propose it.
But then: I've grown convinced that isolating adopters from RDF to
the point that what they see isn't RDF any more more will help
adoption (and I'd really like to see Datalink client authors try if
they like this proposal and will finally exploit the hierarchy
induced by semantics).
I therefore went ahead and did a prototype implemenation, and
therefore you can now get all Voc2-compliant vocabularies (which are
all except UCD at this point) in a format I've tentatively christened
desise, dead simple semantics[2]. To get it, just add an
accept: text/json;content=desise
header to your request, as in
curl --header "accept: text/json;content=desise" -L \
http://localhost/rdf/datalink/core
or
requests.get("http://localhost/rdf/datalink/core",
headers={"accept": "text/json;content=desise"})
(Java, Prolog, APL, Go, and Rust versions left as an exercise to the
reader).
What you'll get is something like:
{
"uri": "http://www.ivoa.net/rdf/datalink/core",
"flavour": "RDF Property",
"terms": {
"this": [
"the data itself",
"the primary (as opposed to related) data of the identified resource"
],
"progenitor": [
"Progenitor",
"data resources that were used to create this dataset (e.g. input raw data)"
],
...
},
"deprecated_terms": [],
"preliminary_terms": [
"sibling"
],
"wider_terms": {
"weight": [
"auxiliary"
],
"error": [
"auxiliary"
],
...
}
}
[Yeah, I'm not overly happy about the lists in the wider_terms values,
but we need them for SKOS].
So... What do people think about this?
If there's serious protest, I'll go back to the drawing board and
investigate existing RDF JSON serialisations (with just a hint of
trepidation).
If there's encouragement or, even better, suggestions for how to
improve this scheme, I'll go ahead.
If I hear nothing... I'll go ahead and also put it in. Compared to the
ugly recipes in the "without RDF tooling" sections, I find this so much
nicer.
Thanks for making it to here,
Markus
[1] http://ivoa.net/documents/Vocabularies/20190905/revovo.py
[2] Also marketed as 'Did you mean "desire"?'.
More information about the semantics
mailing list