rio icon indicating copy to clipboard operation
rio copied to clipboard

N3 parse support

Open damooo opened this issue 3 years ago • 12 comments

hello @Tpt , thanks for your work.

It would be great if rio supports n3 parser. n3 is also the format chosen for n3-patch format, by solid spec, to patch solid rdf resources.

Thanks again.

damooo avatar Jan 14 '22 12:01 damooo

Hi! thank you! It's great idea. I believe this parser should implement the community group spec and return generalized quads similarly to the current "GTrig" parser. Is it what you have in mind?

Tpt avatar Jan 17 '22 18:01 Tpt

Yes, indeed _/\_. Other advanced features of n3 for rule -systems are not that required to be modelled now. just generalized-quads support is great enough

damooo avatar Jan 18 '22 06:01 damooo

hello @tpt,

Solid's N3-patch depends on Cited Formulae, to quote a graph.

How should one proceed, if one want to parse n3 as such?

damooo avatar Apr 07 '22 13:04 damooo

Hi @damooo! That's a great question. A possible way is to parse Cited Formulae as RDF 1.1 named graph using a new blank node as graph identifier. It's what other parsers like N3.js are doing.

Tpt avatar Apr 07 '22 14:04 Tpt

thanks @tpt, Is it possible to have that quoted-graph syntax-extension be supported in gtrig parser, as a blank named graph (By default disabled)?

damooo avatar Apr 07 '22 14:04 damooo

@damooo It's definitely doable but with a bit of work. I would prefer to implement a clean N3 parser instead.

Tpt avatar Apr 07 '22 15:04 Tpt

@Tpt , That would be much more great if it is considered _/\_.

damooo avatar Apr 07 '22 15:04 damooo

Hello @Tpt ,

I would be soon open sourcing a modular rust implementation of solid server, that will allow running solid in wide range of contexts. And makes it possible to convert solid web apps into native apps using rust + tauri, etc.

But that requires N3 support for PATCH operation over a graph using n3-patch as defined in protocol. solid heavily uses that, and all most all solid apps including solid-os make heavy use of it. Thus servers need parser, and any rust clients need a serializer. Solid is major standard for practical rdf world. It would be very useful if rust has basic tools to work against it.

I am quite new to parsing technlogies. If you can guide me little on adapting GTrig parser for N3 parser as mentioned above, i could give it a try.

damooo avatar Aug 11 '22 17:08 damooo

I would be soon open sourcing a modular rust implementation of solid server, that will allow running solid in wide range of contexts. And makes it possible to convert solid web apps into native apps using rust + tauri, etc.

It's amazing! Congratulation!

I am quite new to parsing technlogies. If you can guide me little on adapting GTrig parser for N3 parser as mentioned above, i could give it a try.

If you prefer I am currently moving forward with the new parser able to support both sync and async I talked about in #98. I have something working for NTriples that is nearly twice as fast the current parser. I plan to add Turtle, TriG and N3 support to it. So if you are ok to wait a few weeks, I hope to have something working by then.

If not, copy/pasting the GTrig parser code and hacking on top of it should do the work. The rio_turtle crates work by parsing the input byte by byte using the LookAheadByteReader struct. If you manage to understand this struct then I hope the code won't be to hard to understand.

About formatting, Turtle is a subset of N3 so the Turtle serializer should output something compatible with N3.

Tpt avatar Aug 13 '22 10:08 Tpt

Sincere sorry for this nagging @Tpt .

If you don't take it as bad, can you give approximate ETA for N3, so that i will decide if i have to hack till then.

Thank you.

damooo avatar Sep 08 '22 18:09 damooo

If you don't take it as bad, can you give approximate ETA for N3, so that i will decide if i have to hack till then.

Sorry, I missed your message. I don't know, something like a month or two. So if you want something "soon" writing a quick&dirty parser might be the way to go.

Tpt avatar Sep 15 '22 08:09 Tpt

Thanks @Tpt , I feared it may involve some complex parsing expression graammers, etc. But GTrig parser is clear enough, that i adapted it to simple N3 quick enough. Thanks for great work.

damooo avatar Sep 16 '22 06:09 damooo

It's been a while since this was last discussed - and it seems like N3 support hasn't landed. I'd love to know if the idea was abandoned altogether or if building on top of rio might still be possible here at some point (I'm working on Solid support for a predominantly Rust-based project)?

Gearme avatar Apr 02 '23 08:04 Gearme

@Gearme Yes, it has been a while, sadly. The project is not abandonned but not high priority so it's moving slowly (this work is not funded at all so moves forward on my free time). I have a prototype working in the new-turtle branch. All tests but one in the N3 test suite works.

To use it add to your Cargo.toml

oxttl = { git = "https://github.com/oxigraph/oxigraph", branch = "new-turtle" }

And then a code like:

use use oxttl::n3::{N3Event, N3Parser};

for q in N3Parser::builder()
        .with_base_iri(BASE_IRI_IF_USEFUL)?
        .with_read(FILE_CONTENT)
    {
        match q {
          Ok(N3Event::Quad(quad)) => /* process quad, the "graph name" part might be a blank node identifying an N3 formula or default graph if not in a formula */
           Err(e) => /* error */
        }
    }

Tpt avatar Apr 02 '23 13:04 Tpt

Although very very late, released solid server at Manas. it uses customized n3 parser as of now. Will be great to have standard one. Thanks again for the support @Tpt.

damooo avatar Sep 28 '23 17:09 damooo

I finally cut a new release of my N3 parser: https://docs.rs/oxttl/0.1.0-alpha.1/oxttl/n3/struct.N3Parser.html

Tpt avatar Jan 04 '24 06:01 Tpt

That's great. _/\_

damooo avatar Jan 04 '24 13:01 damooo