json-ld / json-ld.org

JSON for Linked Data's documentation and playground site
https://json-ld.org/
Other
859 stars 152 forks source link

Collaborate on a JSON-LD hinter for CodeMirror #458

Open BigBlueHat opened 7 years ago

BigBlueHat commented 7 years ago

I started by attempting to extract the exiting JSON-LD hinter in use on the playground: https://github.com/json-ld/json-ld.org/blob/master/playground/jsonld-hint.js

However, I quickly found that it's tightly coupled with the playground's assumptions (depends on jQuery, uses global variables from the playground, etc).

Consequently, I've started a new, more narrowly focused one:

It's MIT licensed, and I'd love to make sure it provides the necessary extension points needed to provide a more widely usable JSON-LD linter--as I also have hopes of contributing this add-on upstream when it's "ready." 😸

So. Is there interest in such things? 😃

Thanks! 🎩

msporny commented 7 years ago

Oh sweet Jesus, yes, we love you, keep going!

BigBlueHat commented 7 years ago

Aw, thanks! 😁

I'm guessing things the Playground needs are:

Anything else?

(and again much thanks for the encouragement!)

gkellogg commented 7 years ago

Some other things the playground could use:

gkellogg commented 7 years ago

Also see #450 and #383. https://github.com/scienceai/jsonld-vis looks interesting.

BigBlueHat commented 7 years ago

These are great, @gkellogg! Replies below...

graphical display of data. I believe there's a Jason-ld D3 module that might work

Looks like you already found the one I was going to suggest.

output Turtle/TriG instead of NQuades. N3.js might help here

👍

RDF input as an alternative to JSON-LD. I get asked about this a lot.

Could you elaborate on this one? This is a JSON-LD playground after all. 😸 Are people expecting to drop Turtle (etc) into a field and see the JSON-LD output? I have often wanted to flip back and forth between RDF expressions...but that leads us into a larger work...maybe. 💭's?

gkellogg commented 7 years ago

One of the core JSON-LD algorithms is fromRdf, which requires RDF input to create expanded JSON-LD. Of course, this can be combined with compact and/or framing to get framed output. As JSON-LD is an RDF serialization, being able to start from some other serialization (at least N-Quads) is a key feature that the playground has not supported to date.

Either some mode could be set to change the input from JSON-LD to Turtle/TriG, or it could be content sniffed easily enough (although possible, TriG will never start with {, none start with [, usually start with @prefix or @base, absolute IRI <..>, or Node _:..). Note that N3.js supports N-Triples, N-Quads, Turtle and TriG.

BigBlueHat commented 7 years ago

Great to know @gkellogg! I do want to see all of these things start to lean into each other.

Also, checkout #459 which solves (I hope) #383. It looks like #450 handles the remaining two items you mentioned. So we're on the right track! 🚆

I'll try and work the hinter toward a (to-be-upstreamed) replacement for the current one...and we can refocus that issue on that if that works. 🔨 👷 🔧

BigBlueHat commented 7 years ago

Also, if anyone can help me narrow this issue down, I'd be most grateful: https://github.com/WileyLabs/codemirror-jsonld-hint/issues/1 🙇

BigBlueHat commented 7 years ago

Just an FYI. The http://github.com/WileyLabs/codemirror-jsonld-hint project now supports standard @ prefixed JSON-LD terms and context-based terms (passed in via a config param).

The demo sports Web Annotation as the default vocab (available by typing :) as well as Schema.org terms prefixed by schema: (typing the : after schema opens just those terms). Here's the demo link: https://wileylabs.github.io/codemirror-jsonld-hint/

I'm now working on a "distribute" project for packaging these bits into npm and/or cdn available libraries: https://github.com/WileyLabs/codemirror-jsonld-hint/projects/1

Would love feedback on the overall approach and plans if anyone here has a moment. 😸

Thanks! 🎩

dlongley commented 7 years ago

@BigBlueHat, the hinter is really cool! My one critique at the moment would be its use of CURIEs ... we want to discourage those and encourage simple terms only. I imagine the hinter should just pop up all possible terms when you type the opening quote (") for a key rather than waiting for a prefix or colon.

BigBlueHat commented 7 years ago

@dlongley ah. Good to know, and completely understandable. I'll give that a look soon--that's obviously the ideal anyhow vs. having to type : for the default vocab. 😛 Thanks for the feedback!

msporny commented 7 years ago

+1, just tried it, super awesome. Agree w/ @dlongley on killing CURIEs with fire.

gkellogg commented 7 years ago

I wouldn't kill compact IRIs, just not promote them. In particular, people using JSON-LD as an RDF serialization format, rather than as a native API, are often coming from environments that use PName/CURIEs. In many cases terms are defined for 1st class entries that are actually used in an API and compact IRIs remain for completeness of statements that exist in the graph, but are not of primary use. Compact IRIs should just fall out of the support for terms, with the part after the : not affecting anything else.

Also, values of @type (or it's alias) should use the same term hints.

BigBlueHat commented 7 years ago

@gkellogg no worries. To be clear the : prefix stuff won't go away. It just (hopefully) won't be necessary for the default key/value names. Research and coding to prove that theory. :wink:

msporny commented 7 years ago

@gkellogg sorry, I was mostly joking. :)

Non-LD people tend to get confused when they see JSON data that contains colons in the keys and values. While CURIEs have their uses, we've been suggesting for a long time that most Web developer facing systems should not use CURIEs in their output as people tend to fixate on how strange it looks and that ends up dominating the conversation vs. talking about the other benefits of Linked Data. Follow the path of least surprise, and all that. :)

BigBlueHat commented 7 years ago

Done. https://github.com/WileyLabs/codemirror-jsonld-hint/issues/2

BigBlueHat commented 6 years ago

Happy New Year! 😁

I'd love to help get this over the fence...if y'all are still interested.

Cheers! 🎩

davidlehn commented 6 years ago

Sure, I think people are still interested. Who wouldn't want better tools? ;-) Are things at a point where PRs could be made?

I imagine at this point everything may need upgrades. CodeMirror and other libs are all using rather old versions. The JSON-LD support will need an upgrade to support 1.1 features at some point as well. If hinter code works without upgrades, that's fine too.