digitalbazaar / jsonld.js

A JSON-LD Processor and API implementation in JavaScript
https://json-ld.org/
Other
1.66k stars 195 forks source link

how to define key in context such that its value is a string and each word resolves to its uri #308

Closed sanuann closed 5 years ago

sanuann commented 5 years ago
{
    "@context": {
          "@version": 1.1,
          "item1": {
               "@id": "http://ex.org/item1.jsonld",
              "@type: "@id"
         },
         "item2": {
               "@id": "http://ex.org/item2.jsonld",
              "@type: "@id"
         },
         "score": {
              "@type": "xsd:string"
        }
    },
    "@id": "http://ex.org/1",
    "score": "item1 + item2"
}

the value for score key is a string (which is basically the formula to score). How can I define score key in the context such that item1 and item2 resolves to its URI? Is it possible?

davidlehn commented 5 years ago

Are you asking if the processor could do some sort of string interpolation and expand "score" to "http://ex.org/item1.jsonld + http://ex.org/item2.jsonld"? I'm afraid that looks to be beyond the scope of JSON-LD processing. Certainly beyond the capabilities of jsonld.js. If there were a strong demand for this sort of functionality, it might be possible to expose some internal plumbing to let custom hooks do their own processing for terms. But this seems a little beyond common use cases.

sanuann commented 5 years ago

yes, i was asking that. Thanks for the clarification.