Code Monkey home page Code Monkey logo

Comments (13)

gkellogg avatar gkellogg commented on September 21, 2024 1

It doesn't match because the Frame Matching Algorithm doesn't match any of the nodes which are a part of "char".

Consider a simplified use case (playground link):

Input:

{
  "@context": {
    "@base": "http://example.org/",
    "@vocab": "http://example.org/vocab#",
    "@version": 1.1
  },
  "characters": {
    "@id": "m3",
    "@type": "ContinuousCells",
    "label": "Continuous characters",
    "format": {
      "char": [
        {
          "@id": "ContinuousCharacter1",
          "label": "this is character 1"
        },
        {
          "@id": "ContinuousCharacter2"
        },
        {
          "@id": "ContinuousCharacter3"
        },
        {
          "@id": "ContinuousCharacter4"
        },
        {
          "@id": "ContinuousCharacter5"
        }
      ]
    }
  }
}

Frame:

{
  "@context": {
    "@base": "http://example.org/",
    "@vocab": "http://example.org/vocab#",
    "@version": 1.1
  },
  "characters": {
    "format": {
      "char": {
        "states": {
          "@default": {}
        }
      }
    }
  }
}

In this case, we have the sub-frame {"states": {"@default": {}}}, with each of the inputs with id "ContinuousCharacter?".

The algorithm matches if it has no properties (it has properties, @id), @type matches (no @type), or any property which isn't a keyword matches (only "ContinuousCharacter1" has a property, so it matches).

To get them to match you would need to add "@id": {} to wildcard match each node having an @id. With the updated frame it should work:

{
  "@context": {
    "@base": "http://example.org/",
    "@vocab": "http://example.org/vocab#",
    "@version": 1.1
  },
  "characters": {
    "format": {
      "char": {
        "@id": {},
        "states": {
          "@default": {}
        }
      }
    }
  }
}

It does work in my implementation, but doesn't in jsonld.js, which is a bug there.

The expected result is:

{
  "@context": {
    "@base": "http://example.org/",
    "@vocab": "http://example.org/vocab#",
    "@version": 1.1
  },
  "characters": {
    "@id": "m3",
    "@type": "ContinuousCells",
    "label": "Continuous characters",
    "format": {
      "char": [{
        "@id": "ContinuousCharacter1",
        "label": "this is character 1",
        "states": {}
      }, {
        "@id": "ContinuousCharacter2",
        "states": {}
      }, {
        "@id": "ContinuousCharacter3",
        "states": {}
      }, {
        "@id": "ContinuousCharacter4",
        "states": {}
      }, {
        "@id": "ContinuousCharacter5",
        "states": {}
      }]
    }
  }
}

The matching behavior may be different to that before, but that was never standardized.

from json-ld-framing.

dlongley avatar dlongley commented on September 21, 2024

I think this is just a bug in the jsonld.js implementation:

digitalbazaar/jsonld.js#323

I propose we close and fix it over there. If the fix results in any other tests breaking we can raise a new issue.

from json-ld-framing.

cboettig avatar cboettig commented on September 21, 2024

Thanks @gkellogg, that makes sense. The expected result as shown by your implementation looks good!

I had actually tried adding an "@id": {} to char but as you note, no look on the jsonld.js implementation in playground (which is also what I'm using via R).

from json-ld-framing.

cboettig avatar cboettig commented on September 21, 2024

@gkellogg I'm still not getting the expected behavior you document in #58 (comment) when I try your example at https://json-ld.org/playground/ . What's the process for #62 to show up in the playground instance?

from json-ld-framing.

gkellogg avatar gkellogg commented on September 21, 2024

The playground is not up to date, and is being worked on to conform. You might try http://rdf.greggkellogg.net/distiller, which is more up to date.

from json-ld-framing.

cboettig avatar cboettig commented on September 21, 2024

@gkellogg Wow, thanks Gregg. Everything is work exactly as expected when I use your version! This resolves a good handful issues I have been having with framing elsewhere.

In my use cases I'm mostly calling against the R bindings @jeroen has written to the javascript library (e.g as linked above). I think we'll just need to point that to the latest version of the 1.1. jsonld.js library -- what's the canonical location for the up-to-date js source?

from json-ld-framing.

jeroen avatar jeroen commented on September 21, 2024

For R we need a single JS bundle transpiled to ES5 (many servers run an old version of V8).

from json-ld-framing.

davidlehn avatar davidlehn commented on September 21, 2024

@cboettig jsonld.js is at https://github.com/digitalbazaar/jsonld.js. It's in the process of being updated to latest 1.1 spec. We'll be rolling out releases, and updating the playground, as features get finished. You can check the test runner for skipped tests now. We'll get a test conformance report out soon, I think, so people can more easily follow progress.

@jeroen Feel free to bring up issues over on the jsonld.js project. Not sure if the default bundle goes back to pure ES5. Newer V8 performance is much much better. Benchmarking reports are a work in progress.

from json-ld-framing.

cboettig avatar cboettig commented on September 21, 2024

Thanks @davidlehn, really appreciate it! It's wonderful how supportive and helpful Gregg and the rest of your community has been with all this. (From what I can tell, the travis logs there do seem to be running the test added in #62; https://travis-ci.org/digitalbazaar/jsonld.js/jobs/585843847#L1412, so I take that as a good sign it's already got the fix!).

@jeroen Do you think you can bundle this into the R package? Guess we can continue the discussion over at ropensci/jsonld#17

from json-ld-framing.

jeroen avatar jeroen commented on September 21, 2024

I have opened a PR that upgrades the R bindings to to jsonld.js 1.8.0: ropensci/jsonld#18. Can you test if this works for you?

from json-ld-framing.

cboettig avatar cboettig commented on September 21, 2024

@dlongley @gkellogg Using the 1.8 release from https://cdnjs.com/libraries/jsonld, I still get the same bug documented above (which I also see on the Playground but is all resolved on Gregg's http://rdf.greggkellogg.net/distiller. Perhaps I've done something wrong, or are there any other pointers to where we can get the sources where this has been fixed? Or should we just sit tight and this'll work it's way into the pipes?

from json-ld-framing.

davidlehn avatar davidlehn commented on September 21, 2024

@cboettig The distiller is using a server side ruby library, https://github.com/ruby-rdf/json-ld, and the playground is using a client side javascript library, https://github.com/digitalbazaar/jsonld.js. Unless you want to help port over fixes, you may have to wait. @gkellogg is in the process of helping to port over the ruby fixes to js and py. We'll get them released as soon as we can.

from json-ld-framing.

cboettig avatar cboettig commented on September 21, 2024

@davidlehn Thanks for the explanation, that makes sense! We'll keep an eye out then and thanks again for all you folks are doing.

from json-ld-framing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.