pchampin / sophia_rs

Sophia: a Rust toolkit for RDF and Linked Data
Other
210 stars 23 forks source link

JSON-LD #88

Closed fimbault closed 8 months ago

fimbault commented 3 years ago

Hi,

It's great to get json-ld 1.1 support, at least for serialization and parsing. Even if it's early stage, it could be interesting to list it on https://json-ld.org What's the long term objective in terms of compliance with the rest of the spec? (flattening, compaction, framing)

Fabien

pchampin commented 3 years ago

What's the long term objective in terms of compliance with the rest of the spec? (flattening, compaction, framing)

Most algorithms in the spec take JSON as input and return JSON as output, so I consider them as slightly out-of-scope for Sophia (which is centered on the notion of RDF Graph). The only relevant algorithms for Sophia are therefore toRdf (i.e. a JSON-LD parser) and fromRdf (i.e. a JSON-LD serializer).

That being said, these two algorithms are not totally independant from the others:

The way I see things:

roper79 commented 1 year ago

Hi, is there any progress/plans with a JSON-LD parser front? Thanks!

pchampin commented 10 months ago

at long (long) last, there is indeed some progress! d6d73d7

Long story short: there is now a sophia_jsonld crate providing a JSON-LD parser and a JSON-LD serializer (producing only the expanded form at the moment).

damooo commented 9 months ago

@pchampin Could you release the update to crates.io?

pchampin commented 9 months ago

Could you release the update to crates.io?

I still have a few adjustments to make, but I will eventually.

Note that you can still use the commit as a dependency in cargo with

sophia = { git = "https://github.com/pchampin/sophia_rs.git", rev = "d6d73d78" }

Of course, you don't want to release on crates.io a crate with this kind of dependencies (I guess the server won't let you, anyway), but for a work in progress, that's a good solution.

LuisOsta commented 8 months ago

@pchampin Trying out that commit but I wanted to let you know that if I try the latest commit instead I get an error due to a lack of the futures_util module being present in the library consumer. Here's more context on the error:

   Compiling predicates-tree v1.0.9
   Compiling chrono v0.4.31
   Compiling json-ld-compaction v0.15.0
   Compiling sophia_resource v0.8.0-alpha.3 (https://github.com/pchampin/sophia_rs.git?rev=f16ec404cad433a8a7679ab991b5d7189da76ffe#f16ec404)
error[E0432]: unresolved import `futures_util`
 --> /Users/luisosta/.cargo/git/checkouts/sophia_rs-ca1fdaaafda2a8dd/f16ec40/resource/src/loader/_trait.rs:3:5
  |
3 | use futures_util::FutureExt;
  |     ^^^^^^^^^^^^ use of undeclared crate or module `futures_util`

   Compiling sophia_term v0.8.0-alpha.3 (https://github.com/pchampin/sophia_rs.git?rev=f16ec404cad433a8a7679ab991b5d7189da76ffe#f16ec404)
   Compiling pin-project v1.1.3
For more information about this error, try `rustc --explain E0432`.
error: could not compile `sophia_resource` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...
pchampin commented 8 months ago

@LuisOsta I noticed that, and it should now be fixed. The problem was :

With the latest commit, the crate should compile with or withour the jsonld feature enabled. But of course, in your case, you should enable it!

pchampin commented 8 months ago

@pchampin Could you release the update to crates.io?

@damooo by the way, I forgot to mention that the JSON-LD support was included in [version 0.8.0-alpha.3](https://crates.io/crates/sophia_api/0.8.0-alpha.3

Regarding the initial suggestion of this issue (adding Sophia to the list of JSON-LD implementations on json-ld.org): since Sophia is based on https://github.com/timothee-haudebourg/json-ld, and since that implementation is already mentioned there, I don't think it is appropriate to add Sophia to that list.

damooo commented 8 months ago

JSON-LD support was included in [version 0.8.0-alpha.3]

Saw that already /\\.

Now basic support is added in manas.

It also adds json-ld support to rdf_dynsyn crate (not yet updated in crates.io), to be dynamically specified. And also includes a custom http loader, that allows for caching/any-middleware, and fixes few issues in existing loader.

LuisOsta commented 8 months ago

Thanks!