ruby-rdf / json-ld

Ruby JSON-LD reader/writer for RDF.rb
The Unlicense
232 stars 27 forks source link

Supporting Multiple External Contexts #27

Closed tpendragon closed 8 years ago

tpendragon commented 8 years ago

https://bibdata.princeton.edu/bibliographic/4609321/jsonld

Running this through the reader doesn't parse anything from the first context, only the second. There are callouts in the spec for supporting multiple contexts, and http://rdf-translator.appspot.com/ seems to work how I'd expect.

gkellogg commented 8 years ago

Running through script/parse --expand in the gem directory indicates that it is processing both contexts and generates the following:

[
  {
    "@id": "http://bibdata.princeton.edu/bibliographic/4609321",
    "http://id.loc.gov/vocabulary/relators/bnd": [
      {
        "@value": "Fogel, Johannes, active 1455-1462"
      }
    ],
    "http://id.loc.gov/vocabulary/relators/fmo": [
      {
        "@value": "Predigerkirche (Erfurt, Germany)"
      },
      {
        "@value": "Brinley, George, 1817-1875"
      },
      {
        "@value": "Ives, Brayton, 1840-1914"
      },
      {
        "@value": "Cole, Hamilton"
      },
      {
        "@value": "Ellsworth, James W. (James William), 1849-1925"
      }
    ],
    "http://id.loc.gov/vocabulary/relators/pbl": [
      {
        "@value": "[Mainz : Johann Gutenberg and Johann Fust, before August 1456]."
      }
    ],
    "http://id.loc.gov/vocabulary/relators/prt": [
      {
        "@value": "Gutenberg, Johann, 1397?-1468"
      }
    ]
  }
]

Ran with script/parse --expand https://bibdata.princeton.edu/bibliographic/4609321/jsonld. Add --dbg to get a full accounting or processing steps.

RDF output gives me the following:

@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://bibdata.princeton.edu/bibliographic/4609321> <http://id.loc.gov/vocabulary/relators/bnd> "Fogel, Johannes, active 1455-1462";
   <http://id.loc.gov/vocabulary/relators/fmo> "Ellsworth, James W. (James William), 1849-1925",
     "Ives, Brayton, 1840-1914",
     "Brinley, George, 1817-1875",
     "Predigerkirche (Erfurt, Germany)",
     "Cole, Hamilton";
   <http://id.loc.gov/vocabulary/relators/pbl> "[Mainz : Johann Gutenberg and Johann Fust, before August 1456].";
   <http://id.loc.gov/vocabulary/relators/prt> "Gutenberg, Johann, 1397?-1468" .
tpendragon commented 8 years ago

@gkellogg I may be misunderstanding what you're saying. Are we agreeing that it's not working? Because I would have expected to see, for example, the title element in the expanded JSON-LD.

gkellogg commented 8 years ago

I'll need to look at the contexts more explicitly; it's definitely loading both contexts. Note that it doesn't work through the json-ld.org/playground either, but for different reasons. The fact that apspot processes it doesn't make it right. I'll let you know when I've found out more, but the contexts are definitely being processed.

gkellogg commented 8 years ago

This does seem to be a regression; it parses both contexts, but seems to drop the first one found. I'll have a fix sometime tomorrow.

gkellogg commented 8 years ago

Released in 2.0.0.beta3 and 1.99.2. Also fixed an issue with BNode naming in the JSON-LD to RDF writer.