簡體   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