【发布时间】:2014-01-17 19:19:13
【问题描述】:
我无法弄清楚如何预先消除使用相同谓词的资源的歧义。我是 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"
}
}
我的Interviewer 和Interviewee 资源具有这样的上下文:
{
"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 属性中。
当然,这是完全合理的,因为 interviewers 和 interviewees 都通过 interview 谓词与 interview 资源相关联(它们仅通过各自的类型进行区分)。
我需要让dump 进程知道相关的资源类型,但我不知道有什么方法可以将该信息添加到采访的上下文中。
根据当前的 JSON-LS 规范,我什至不知道这是否可能。 This issue 看起来可能是相关的,但我对 RDF/JSON-LD 的了解还不够,无法确定。
我可以对interviewers 和interviewees 使用不同的谓词,但我似乎不必这样做。有什么建议吗?
注意:我也在 answers.semanticweb.com 上问过这个问题。
其他信息
我已经根据推荐的用于限定 DC 属性的方法之一以这种方式建模了我的 contributor 关系(其中 interviewer 是 contributor 类型为 http://id.loc.gov/vocabulary/relators/ivr)。例如,可以在如下资源上表达 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“属性”,其中lcsh_subjects 表示与dc:subject 和类型为dcterms:LCSH 的资源相关的那些节点。但是,我意识到我可能以错误的方式考虑 JSON-LD 模型。
【问题讨论】:
-
AFAIK
"@type": "@id"在您的上下文中意味着该属性具有字符串类型,其值应被解释为 IRI。http://purl.org/dc/terms/contributor似乎是一种类型(对象)而不是属性名称(谓词)。所以我认为你的上下文有缺陷。但我也是 JSON-LD 的新手...... -
我猜
@type相当于rdf:type谓词,而@id至少在属性定义上相当于实际主语,但很难找到任何关于此的信息。 .. :S