繁体   English   中英

在JSON-LD中使用相同谓词消除歧义资源

[英]Disambiguating resources with same predicate in JSON-LD

我无法预先确定如何消除使用相同谓词的资源的歧义。 我是RDF的新手,所以请原谅我的术语:我会试着用例子来解释我的意思。

我有一个带有(简化)上下文的Interview资源/模型,如下所示:

{
  "id": {
    "@id": "http://purl.org/dc/terms/identifier"
  },
  "interviewers": {
    "@id": "http://purl.org/dc/terms/contributor",
    "@type": "@id",
    "@container": "@set"
  },
  "title": {
    "@id": "http://purl.org/dc/terms/title"
  },
  "interviewees": {
    "@id": "http://purl.org/dc/terms/contributor",
    "@type": "@id",
    "@container": "@set"
  }
}

我的InterviewerInterviewee资源有这样的背景:

{
  "id": {
    "@id": "http://purl.org/dc/terms/identifier"
  },
  "name": {
    "@id": "info:repository/ive/name"
  }
}

然后我创建一个如下所示的资源:

{
  "id": "06bad25f-83c1-4ee5-b055-0cb87d4c06be",
  "interviewers": [
    {
      "id": "b0c262ce-7eb3-47f2-b212-a0e71cca0c92",
      "name": "Somebody",
      "@context": {
        ...
      },
      "@id": "urn:uuid:b0c262ce-7eb3-47f2-b212-a0e71cca0c92",
      "@type": [
        "http://id.loc.gov/vocabulary/relators/ivr"
      ]
    }
  ],
  "title": "Interview with So and So",
  "interviewees": [
    {
      "id": "bd6bb9ec-f417-4f81-af69-e3d191e3f73b",
      "name": "A third person",
      "gender": "male",
      "@context": {
        ...
      },
      "@id": "urn:uuid:bd6bb9ec-f417-4f81-af69-e3d191e3f73b",
      "@type": [
        "http://id.loc.gov/vocabulary/relators/ive"
      ]
    }
  ],
  "@context": {
    ...
  },
  "@id": "urn:uuid:06bad25f-83c1-4ee5-b055-0cb87d4c06be",
  "@type": [
    "info:repository/interview"
  ]
}

一切都很好,我可以将这个“对象”存储到我的存储库(我正在使用RDF.rb库)。 但是,当我尝试提取对象并“重新序列化”它时,会出现问题。 例如(借用Ruby代码),

query = repository.query(:subject => RDF::URI(uri))
JSON.parse(query.dump(:jsonld, :context => Interview.context))

这些行从存储库中提取相关语句,然后将它们混合到具有适当上下文的JSON-LD“资源”中。 然而,受访者和访调员都被转移到了interviewees属性中。

当然,这是完全合理的,因为interviewersinterviewees都与dc:contributor谓词的interview资源相关(他们只能通过各自的类型来区分)。

我需要让dump过程知道相关的资源类型,但我不知道有什么方法可以将这些信息添加到面试的上下文中。

根据目前的JSON-LS规范,我不知道这是否可行。 这个问题似乎可能是相关的,但我对RDF / JSON-LD的了解还不是很清楚。

我可以为interviewersinterviewees使用不同的谓词,但似乎我不应该这样做。 有什么建议么?

注意:我也在answers.semanticweb.com上提出了这个问题。

附加信息

我以这种方式模拟了我的contributor关系(其中一位interviewer是一个类型为http://id.loc.gov/vocabulary/relators/ivrcontributor ),这是基于推荐的DC资格认证方式之一。 例如,可以在以下资源上表达MESH主题:

<rdf:Description>
  <dc:subject>
    <dcterms:MESH>
      <rdf:value>D08.586.682.075.400</rdf:value>
      <rdfs:label>Formate Dehydrogenase</rdfs:label>
    </dcterms:MESH>
  </dc:subject>
</rdf:Description>

假设我有:

<rdf:Description>
  <dc:subject>
    <dcterms:MESH>
      <rdf:value>D08.586.682.075.400</rdf:value>
      <rdfs:label>Formate Dehydrogenase</rdfs:label>
    </dcterms:MESH>
  </dc:subject>
  <dc:subject>
    <dcterms:LCSH>
      <rdf:value>Formate Dehydrogenase</rdf:value>
    </dcterms:LCSH>
  </dc:subject>
</rdf:Description>

我希望能够引用lcsh_subjects “property”,其中lcsh_subjects表示与dc:subject AND的资源相关的节点,其类型为dcterms:LCSH 但是,我意识到我可能以错误的方式思考JSON-LD模型。

您可能会对@id用于面试官和受访者感到困惑。 您已使用相同的@id定义它们,这意味着它们是相同的谓词。 它们被定义为资源的贡献者,但没有什么可以使它们彼此区分开来。 您可能会认为“访问者”的含义是一个谓词,它是dc:贡献者的子属性,对于“受访者”也是如此。 选择一个已经具有访调员和受访者概念的现有词汇可能会更好。 或者,创建自己的词汇表,定义您需要的术语,并使用它来创建上下文类型。

您还要转义对象中使用的URI(例如,“http://purl.org/dc/terms/identifier”),这可能不会产生您想要的内容,只需使用常规URI,例如“ http:// purl.org/dc/terms/identifier “。

(另外,使用“info”前缀,这是未定义的。并且,没有必要在每个级别声明@context)。

例如,您可以考虑创建http://example.foo/my-vocab#并在其中定义属性(当然,使用您自己的dereferencable IRI):

{
  "@context": {
    "dc": "dc:identifier",
    "rdf": "URI:http:/www.w3.org/1999/02/22-rdf-syntax-ns#",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#"
  },
  "@graph": [
    {
      "@id": "http://example.foo/interviewees",
      "@type": "rdf:Property",
      "rdfs:comment": "Interviewee",
      "rdfs:subPropertyOf": {
        "@id": "dc:contributor"
      }
    },
    {
      "@id": "http://example.foo/interviewers",
      "@type": "rdf:Property",
      "rdfs:comment": "Interviewer",
      "rdfs:subPropertyOf": {
        "@id": "dc:contributor"
      }
    }
  ]
}

然后,您可以将此与对象的上下文一起使用,如下所示:

{
  "@context": {
    "id": "http://purl.org/dc/terms/identifier",
    "myvocab": "http://example.foo/myvocab#",
    "info": "http://example.foo/info#",
    "interviewers": {
      "@id": "myvocab:interviewers",
      "@type": "@id",
      "@container": "@set"
    },
    "title": "http://purl.org/dc/terms/title",
    "interviewees": {
      "@id": "myvocab:interviewees",
      "@type": "@id",
      "@container": "@set"
    }
  },
  "id": "06bad25f-83c1-4ee5-b055-0cb87d4c06be",
  "interviewers": [
    {
      "id": "b0c262ce-7eb3-47f2-b212-a0e71cca0c92",
      "name": "Somebody",
      "@id": "urn:uuid:b0c262ce-7eb3-47f2-b212-a0e71cca0c92",
      "@type": [
        "http://id.loc.gov/vocabulary/relators/ivr"
      ]
    }
  ],
  "title": "Interview with So and So",
  "interviewees": [
    {
      "id": "bd6bb9ec-f417-4f81-af69-e3d191e3f73b",
      "name": "A third person",
      "gender": "male",
      "@id": "urn:uuid:bd6bb9ec-f417-4f81-af69-e3d191e3f73b",
      "@type": [
        "http://id.loc.gov/vocabulary/relators/ive"
      ]
    }
  ],
  "@id": "urn:uuid:06bad25f-83c1-4ee5-b055-0cb87d4c06be",
  "@type": [
    "info:repository/interview"
  ]
}

(另外,请在JSON-LD操场上查看

如果你把它变成像龟一样的东西(试试http://rdf.greggkellogg.net/ ),你会得到以下结果:

@prefix dc: <http://purl.org/dc/terms/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<urn:uuid:06bad25f-83c1-4ee5-b055-0cb87d4c06be> a <http://example.foo/info#repository/interview>;
   dc:title "Interview with So and So";
   <http://example.foo/myvocab#interviewees> <urn:uuid:bd6bb9ec-f417-4f81-af69-e3d191e3f73b>;
   <http://example.foo/myvocab#interviewers> <urn:uuid:b0c262ce-7eb3-47f2-b212-a0e71cca0c92>;
   dc:identifier "06bad25f-83c1-4ee5-b055-0cb87d4c06be" .

<urn:uuid:b0c262ce-7eb3-47f2-b212-a0e71cca0c92> a <http://id.loc.gov/vocabulary/relators/ivr>;
   dc:identifier "b0c262ce-7eb3-47f2-b212-a0e71cca0c92" .

<urn:uuid:bd6bb9ec-f417-4f81-af69-e3d191e3f73b> a <http://id.loc.gov/vocabulary/relators/ive>;
   dc:identifier "bd6bb9ec-f417-4f81-af69-e3d191e3f73b" .

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM