Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recursive @reverse framing #647

Closed
eroux opened this issue Apr 27, 2018 · 6 comments
Closed

recursive @reverse framing #647

eroux opened this issue Apr 27, 2018 · 6 comments
Labels

Comments

@eroux
Copy link

eroux commented Apr 27, 2018

I would like to use a @reverse property to build a tree structure in JSON-LD but it doesn't seem to work on the dev-playground nor on the distiller. My initial file is:

{
  "@graph" : [ {
    "@id" : "bdr:O9TAXTBRC201605",
    "@type" : "Taxonomy"
  }, {
    "@id" : "bdr:O9TAXTBRC201605_0001",
    "@type" : "Taxonomy",
    "taxSubclassOf" : "bdr:O9TAXTBRC201605"
  }, {
    "@id" : "bdr:O9TAXTBRC201605_0002",
    "@type" : "Taxonomy",
    "taxSubclassOf" : "bdr:O9TAXTBRC201605_0001"
  }, {
    "@id" : "bdr:O9TAXTBRC201605_0010",
    "@type" : "Taxonomy",
    "taxSubclassOf" : "bdr:O9TAXTBRC201605"
  } ],
  "@context" : {
    "taxSubclassOf" : {
      "@id" : "http://purl.bdrc.io/ontology/core/taxSubclassOf",
      "@type" : "@id"
    },
    "@vocab" : "http://purl.bdrc.io/ontology/core/",
    "bdr" : "http://purl.bdrc.io/resource/"
  }
}

my frame is:

{ 
  "@id": "bdr:O9TAXTBRC201605",
  "@context" : {
    "children": { "@reverse": "http://purl.bdrc.io/ontology/core/taxSubClassOf" }, 
    "taxSubclassOf" : {
      "@id" : "http://purl.bdrc.io/ontology/core/taxSubclassOf",
      "@type" : "@id"
    },
    "@vocab" : "http://purl.bdrc.io/ontology/core/",
    "bdr" : "http://purl.bdrc.io/resource/"
  }
}

I would expect the result to be:

{
  "@graph": [
    {
      "@id": "bdr:O9TAXTBRC201605",
      "@type": "Taxonomy",
      "children": [
        {
          "@id": "bdr:O9TAXTBRC201605_0001",
          "@type": "Taxonomy",
          "children": {
            "@id": "bdr:O9TAXTBRC201605_0002",
            "@type": "Taxonomy"
          }
        },
        {
          "@id": "bdr:O9TAXTBRC201605_0010",
          "@type": "Taxonomy"
        }
      ]
    }
  ]
}

but instead I'm getting:

{
  "@graph": [
    {
      "@id": "bdr:O9TAXTBRC201605",
      "@type": "Taxonomy"
    }
  ]
}

(I removed the @context for the sake of clarity). Is it possible to get the result I want?

@pjohnston-wiley
Copy link
Contributor

pjohnston-wiley commented Apr 28, 2018

You have a typo in the definition of children - subclass vs subClass. Try:

{ 
  "@id" : "bdr:O9TAXTBRC201605",
  "@context" : {
    "children": { "@reverse": "http://purl.bdrc.io/ontology/core/taxSubclassOf" }, 
    "taxSubclassOf" : {
      "@id" : "http://purl.bdrc.io/ontology/core/taxSubclassOf",
      "@type" : "@id"
    },
    "@vocab" : "http://purl.bdrc.io/ontology/core/",
    "bdr" : "http://purl.bdrc.io/resource/"
  },
  "children": {
    "children": {"children": {}}
  }
}

It also seems that you need to be explicit about how deep you want your children to go....

chz
p

@eroux
Copy link
Author

eroux commented May 7, 2018

Thanks for the correction! But my graph is pretty deep and I can't know in advance how deep it is... so I guess that's the main problem

@azaroth42
Copy link
Contributor

Propose close, working as expected (modulo not having typos :) ) @eroux?

@eroux
Copy link
Author

eroux commented May 7, 2018

well, should I open a new ticket for not having to specify the number of levels of recursion?

@azaroth42
Copy link
Contributor

Sure :) That seems an orthogonal issue to @reverse. Thanks!

@eroux
Copy link
Author

eroux commented May 7, 2018

well, not really : in the normal mode, infinite recursion is possible, in reverse mode, it has to be specified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants