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

Missing @type in expanded form when an id map is used in conjunction with @type in a term definition #165

Closed
keyvan-m-sadeghi opened this issue Apr 23, 2019 · 2 comments

Comments

@keyvan-m-sadeghi
Copy link

keyvan-m-sadeghi commented Apr 23, 2019

Building on the example from the specs with 3 changes marked by // Here!:

{
  "@context": {
    "@version": 1.1,
    "schema": "http://schema.org/",
    "name": "schema:name",
    "body": "schema:articleBody",
    "words": "schema:wordCount",
    "post": {
      "@id": "schema:blogPost",
      "@container": "@id",
      "@type": "schema:BlogPosting" // Here!
    }
  },
  "@id": "http://example.com/",
  "@type": "schema:Blog",
  "name": "World Financial News",
  "post": {
    "http://example.com/posts/1/en": {
      "body": "World commodities were up today with heavy trading of crude oil...",
      "words": 1539
    },
    "http://example.com/posts/1/de": {
      "body": "Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl...",
      "@type": "schema:BlogPosting",  // Here!
      "words": 1204
    },
    "http://example.com/posts/2/en": "hello" // Here!
  }
}

Open in playground

The expanded form includes the @type for the simple key-value pair "http://example.com/posts/2/en": "hello", but not for "http://example.com/posts/1/en":

[
  {
    "@id": "http://example.com/",
    "@type": [
      "http://schema.org/Blog"
    ],
    "http://schema.org/name": [
      {
        "@value": "World Financial News"
      }
    ],
    "http://schema.org/blogPost": [
      {
        "@type": [
          "http://schema.org/BlogPosting"  // Here!
        ],
        "http://schema.org/articleBody": [
          {
            "@value": "Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl..."
          }
        ],
        "http://schema.org/wordCount": [
          {
            "@value": 1204
          }
        ],
        "@id": "http://example.com/posts/1/de"
      },
      {
        "http://schema.org/articleBody": [
          {
            "@value": "World commodities were up today with heavy trading of crude oil..."
          }
        ],
        "http://schema.org/wordCount": [
          {
            "@value": 1539
          }
        ],
        "@id": "http://example.com/posts/1/en"  // Not Here!
      },
      {
        "@type": "http://schema.org/BlogPosting",  // Here!
        "@value": "hello",
        "@id": "http://example.com/posts/2/en"
      }
    ]
  }
]

@type is manually added for "http://example.com/posts/1/de" for the sake of comparison, which produces the expected result IMHO.

Is this my wrong understanding or is it missing from the expansion algorithm?

Thanks in advance.

@azaroth42
Copy link
Contributor

azaroth42 commented Apr 23, 2019

Yup, this is a common misunderstanding unfortunately. One that I have had in the past from reading the specs! You can't add an @type value into a context where the type is a class, and thus have the class added to the triples. That level of transformation of content is outside of the scope of JSON-LD in its currently chartered work.

See also: #76 and #31. Similarly #7 and #15 are transformations, though not around @type.

Thanks!

@keyvan-m-sadeghi
Copy link
Author

Makes perfect sense. Thanks @azaroth42

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

No branches or pull requests

2 participants