【问题标题】:JSON-LD Frame: framed object properties as term only (not as IRI)JSON-LD 框架:框架对象属性仅作为术语(不作为 IRI)
【发布时间】:2018-09-22 18:17:14
【问题描述】:

我正在学习如何使用 Node jsonld.js 使用 JSON-LD 帧,我想知道为什么有些属性被标记为 IRI 而其他属性被标记为术语,而我可以'看不出造成这种差异的明显原因。

这是sample

例如,在该示例中,name 属性被标记为预期,而在其他情况下,它被标记为http://www.schema.org/name,与urlhttp://www.schema.org/url 相同;我不知道为什么:

{
  "@context": "https://schema.org/docs/jsonldcontext.json",
  "@graph": [
    {
      "id": "_:b0",
      "type": "MusicRecording",
      "byArtist": {
        "id": "_:b1",
        "type": "http://www.schema.org/MusicGroup",
        "http://www.schema.org/name": "Snoop Dogg",
        "http://www.schema.org/sameAs": "/Snoop-Dogg/"
      },
      "name": "Paper'd Up",
      "schema:sameAs": "/Snoop-Dogg/Paper%27d-Up/",
      "url": "../Snoop-Dogg/Paper%27d-Up/",
      "http://www.schema.org/duration": "PT3M55S",
      "http://www.schema.org/image": "/static/track_images_200/lr1734_2009720_1372375126.jpg",
      "http://www.schema.org/inAlbum": {
        "id": "_:b2",
        "type": "http://www.schema.org/MusicAlbum",
        "http://www.schema.org/albumRelease": {
          "id": "_:b4",
          "type": "http://www.schema.org/MusicRelease",
          "http://www.schema.org/datePublished": "2001",
          "http://www.schema.org/recordLabel": "Priority"
        },
        "http://www.schema.org/name": "Paid the Cost to Be the Bo$$"
      },
      "http://www.schema.org/producer": {
        "id": "_:b3",
        "type": "http://www.schema.org/Person",
        "http://www.schema.org/name": "Fredwreck",
        "http://www.schema.org/sameAs": "/Fredwreck/",
        "http://www.schema.org/url": {
          "id": "../Fredwreck/"
        }
      },
      "http://www.schema.org/thumbnailUrl": {
        "id": "../static/track_images_100/mr1734_2009720_1372375126.jpg"
      }
    }
  ]
}

如何使用名为 type 而不是 IRI 的属性检索树(使用 jsonld.js)?

【问题讨论】:

    标签: parsing json-ld


    【解决方案1】:

    该术语必须与您用于属性的 IRI 相匹配。例如,schema.org 将name 定义为http://schema.org/name。在您的示例中,您有 http://www.schema.org/name

    还有几个地方应该是 IRI(URL)的值被视为文本,为此您想使用类似 "http://schema.org/image": {"@id": "/static/track_images_200/lr1734_2009720_1372375126.jpg"}

    部分术语选择旨在确保某个值与上下文中适当的@type 定义相匹配。例如,image 设置为 {"@type": "@id"},所以它只会匹配看起来像这样的东西。

    这是updated example on the playground

    【讨论】:

    • 谢谢,我错过了。实际上,数据是使用 microdata-node:toJsonld/1WhoSampled 中提取的,而SchemaOrg 的引用并不总是一致的,例如:itemtype="http://schema.org/MusicRecording"itemtype="http://www.schema.org/MusicGroup"。是否有任何标准化 SchemaOrg URI 的策略?或者我应该在解析之前对它们进行正则表达式吗?或许可以使用 microdata-node config.registry 选项。
    • 附录:如何处理 4 种潜在情况:http://schema.orghttps://schema.orghttp://www.schema.orghttps://www.schema.org?虽然我遇到过这 4 个案例,但不知道应该在哪个级别处理这些差异以及如何处理它们。
    • 作为检索资源的 URL,它们可能都可以。但是对于已定义术语的命名空间,它们必须都在schema.org 中。不确定您使用的节点工具,但也有将 Microdata 转换为 RDF 的标准,但如果源数据错误,那可能无济于事。
    • 好吧,使用RDF Distiller 进行测试并不会捕获所有属性,而Google Structure Data testing tools 不会产生任何错误或警告,并且能够捕获所有属性。 Google 工具结果看起来是否符合规范?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-13
    • 2011-10-02
    相关资源
    最近更新 更多