RE: @context vs. Turtle @prefix

Adrian, just a very quick answer before I'll call it a day :-)

On Thursday, September 05, 2013 11:04 PM Adrian Gschwend
> In the samples on the homepage I found the compacted versions, the node
> demo did a nice sample on the payswarm URI. But after having a look at
> the specs I fail to understand if this really provides what I would
> like to have:

I think the answer is yes :-)


> - can I get JSON-LD in the style of the prefixed turtle output which
> gets rid of the URIs?

Yes. The JSON-LD context maps prefixes or term to URIs. You can look at as
Turtles @prefix++ :-)


> - in the samples I found mostly one URI in @context, can I have
>   multiple shortcuts in a way like multiple @prefix in turtle?

Yeah, as many you want. In most cases one won't be enough.


> - How do I get a compacted sample with the commandline node tools from
> my basic JSON-LD version? I tried this:
> 
> ../jsonld.js/bin/jsonld compact -c
> "http://data.admin.ch/bfs/municipality/" 12099.jsonld
> 
> jsonld.CompactError: Could not process context before compaction.

I'll leave that to Dave but you can use the playground to get started:

  http://json-ld.org/playground/ or
  http://www.markus-lanthaler.com/jsonld (which also allows you to enter
N-Quads)

Enter your data in the left input field and the context in the right. The
playground will then compact your data using the supplied context. To get
started, you could use a context like this:

{
  "@context": {
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "dac": "http://data.admin.ch/vocab/",
    "dbp": "http://dbpedia.org/property/",
    "xsd": "http://www.w3.org/2001/XMLSchema#",
    "geo": "http://www.w3.org/2003/01/geo/wgs84_pos#",
    "foaf": "http://xmlns.com/foaf/0.1/",
    "dbo": "http://dbpedia.org/ontology/",
    "dbpedia": "http://dbpedia.org/resource/",

    "canton": "dac:canton",
    "cantonAbbreviation": "dac:cantonAbbreviation",
    "district": "dac:district",
    "districtHistId": "dac:districtHistId",
    "historyMunicipalityId": "dac:historyMunicipalityId",
    "municipalityAdmissionDate": "dac:municipalityAdmissionDate",
    "municipalityAdmissionMode": "dac:municipalityAdmissionMode",
    "municipalityAdmissionNumber": "dac:municipalityAdmissionNumber",
    "municipalityDateOfChange": "dac:municipalityDateOfChange",
    "municipalityEntryMode": "dac:municipalityEntryMode",
    "municipalityId": "dac:municipalityId",
    "municipalityLongName": "dac:municipalityLongName",
    "municipalityShortName": "dac:municipalityShortName",
    "municipalityStatus": "dac:municipalityStatus",
    "neighboringMunicipality": "dac:neighboringMunicipality",
    "abstract": "dbo:abstract",
    "thumbnail": "dbo:thumbnail",
    "imagepathCoa": "dbp:imagepathCoa",
    "map": "dbp:map",
    "neighboringMunicipalities": "dbp:neighboringMunicipalities",
    "lat": "geo:lat",
    "long": "geo:long",
    "depiction": "foaf:depiction",
    "homepage": "foaf:homepage"
  }
}

I hope it is clear what it does.  Then you can make the various definitions
more explicit. For example, you can say that all values of "canton" are
IRIs, i.e., @id-objects in JSON-LD:

    "canton": { "@id": "dac:canton", "@type": "@id" },

That will transform

    "canton": {
      "@id": "http://data.admin.ch/bfs/canton/GE"
    },

to just

    "canton": "http://data.admin.ch/bfs/canton/GE",

The same applies for all your datatyped values, e.g.

    "districtHistId": { "@id": "dac:canton", "@type": "xsd:integer" },

and so on.


Hope this helps,
Markus


--
Markus Lanthaler
@markuslanthaler

Received on Friday, 6 September 2013 17:49:40 UTC