On Tue, Oct 21, 2025 at 9:57 AM Miel Vander Sande
<
miel.van...@meemoo.be> wrote:
>
> Hi Niklas,
Hi Miel,
Sorry for the late reply (some health issues got in the way)!
> What's the focus of the TRLD project? Just the algorithms or does it extend to a JSON-LD parser too? Of is TRLD a library that can be used by a JSON-LD library?
The focus is to implement the JSON-LD algorithms verbatim, mainly
expansion, compaction and flattening, and to be able to transpile
these into other languages (currently Java and JS). Some algorithm
issues have cropped up by doing that.
It has since been extended to do some extras, including automatic
framing of "object-only" linked blank nodes, and indexing by @id
and/or @type, TriG and N-quads parsing and serializing, and a
vocabulary mapper (based on RDFS and OWL). In some way, it functions
as a low-level RDF library, with the internal JSON-LD data model as an
"abstract syntax tree".
Library-wise, I have not stabilized the processor API, and it is still
at a semantic 0.x version, so I do not generally advocate it as
API-stable. I do use it daily, mainly through its `trld` CLI [1], but
also in some other tools, importing most things from trld.api [2] (I
think peeking into those can give a generally good glimpse of how to
use this in other tooling). The Java-transpiled code is also used in
the library system I work with on a daily basis, mainly for speedy
output of RDF (Turtle/Trig) for indexing and conneg, but in the recent
years also for mapping and compaction.
I have not deeply compared the PyLD implementation "step by step", so
I cannot fully say how TRLD differs, but I think I've heard that PyLD
isn't always 1:1 with the spec steps (which doesn't necessarily matter
if the same output is achieved). That said, TRLD also optimizes some
things in the context processing (to avoid reprocessing); something
that *might* be valuable to factor out in the specs as well (unless a
note about optimization is more appropriate).
I think PyLD maintenance being picked up by the RDFLib community is
very promising, and I'll think about what the best long-term strategy
is for avoiding duplicate work or fragmentation. Having multiple
implementations is hopefully healthy, but it also risks someone
"betting" on eventually unmaintained code. There are also differing
ideals, such as minimal components cooperating using stable API:s, vs.
efficiency through deeper integration. I will think more about this
too.
(The best I've hitherto been able to do is to publish this as 0BSD to
make it clear that copying chunks of any parts of the code, e.g. into
PyLD, is fully OK, without any licensing issues AFAICS, nor
attribution required (though still appreciated). This implementation
was made by looking at the spec, not other implementations. The TriG
parser and serializer are mainly made "the hacker way" by throwing
data at them until tests pass. I'm sure others, and maybe some LLMs,
have or will eventually do that much better.)
All the best,
Niklas
[1]: <
https://github.com/niklasl/trld/blob/main/trld/cli.py>
[2]: <
https://github.com/niklasl/trld/blob/main/trld/api.py>
PS. One of my more ambitious goals with the transpiler was initially
to generate the spec algorithms in pseudo-code (perhaps INFRA...). It
"should" be simpler than the other real languages, but I have not
dedicated much time on that yet.
> To view this discussion visit
https://groups.google.com/d/msgid/rdflib-dev/CAHeRLWuij2WACxAeXm4H9JLj40abSTX7eqPZxj%2B%3D-C6C9q-gkg%40mail.gmail.com.