Skip to content

Instantly share code, notes, and snippets.

@BruJu
Last active November 29, 2020 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BruJu/1bdab18aa96842e83424ccc84acb81c4 to your computer and use it in GitHub Desktop.
Save BruJu/1bdab18aa96842e83424ccc84acb81c4 to your computer and use it in GitHub Desktop.
Language Indexing

Language Indexing weird behaviour

If we use the following graph

[
   {
     "@id": "htp://example.org/Bob",
     "http://schema.org/name": [
         {
           "@value": "Bob",
           "@language": "en"
         },
         {
           "@value": "ぼぶ",
           "@language": "ja"
         }
       ]
   }
]

If we compact with a context without @value redefinition

Context

{
   "@context": {
     "@base": "http://example.com/",
     "lang": "@language",
     
     "name": {
      "@id": "http://schema.org/name",
      "@container": [ "@language", "@set" ]
    }
   }
}

Compact result

{
  "@context": {
    "@base": "http://example.com/",
    "lang": "@language",
    "name": {
      "@id": "http://schema.org/name",
      "@container": [
        "@language",
        "@set"
      ]
    }
  },
  "@id": "htp://example.org/Bob",
  "name": {
    "en": [
      "Bob"
    ],
    "ja": [
      "ぼぶ"
    ]
  }
}

If we compact with a context with @value redefinition

Context

{
   "@context": {
     "@base": "http://example.com/",
     "lang": "@language",
+    "val": "@value",
     
     "name": {
      "@id": "http://schema.org/name",
      "@container": [ "@language", "@set" ]
    }
   }
}

Compact result

{
  "@context": {
    "@base": "http://example.com/",
    "lang": "@language",
    "val": "@value",
    "name": {
      "@id": "http://schema.org/name",
      "@container": [
        "@language",
        "@set"
      ]
    }
  },
  "@id": "htp://example.org/Bob",
  "name": {
    "en": [
      {
        "lang": "en",
        "val": "Bob"
      }
    ],
    "ja": [
      {
        "lang": "ja",
        "val": "ぼぶ"
      }
    ]
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment