JSON-LD 中顶级仅索引键的上下文
A context for a top level index-only key in JSON-LD
我正在尝试使用 JSON-LD 使遗留 JSON 文件机器可读。有问题的 JSON 文件有一个顶级对象,其中 item
成员引用包含实际相关数据的对象。
{
"item": {
"id": "123",
"name": "Test"
}
}
当我现在介绍如下上下文时:
{
"@context": {
"name": "https://example.org/name"
}
}
没有提取任何知识,这意味着无法从中解释任何三元组。为了让它发挥作用,我意识到我可以做到以下几点:
{
"@context": {
"item": "https://example.org/exists",
"name": "https://example.org/name"
}
}
这个有效,意味着可以很好地提取名称为 predicate 的三元组。然而,这种方法的问题是,还提取了带有 exists
谓词的不必要的三元组。
因此我尝试将顶级对象标记为索引容器,从而完全忽略 item
键。我只是找不到不需要为 item
术语分配 IRI 的方法来执行此操作,如果我分配一个,再次提取不必要的三元组。
{
"@context": {
"name": "https://example.org/name"
}
}
没有提取任何知识,这意味着无法从中解释任何三元组。为了让它发挥作用,我意识到我可以做到以下几点:
这根本不起作用(因为 item
术语没有 IRI):
{
"@context": {
"item": {
"@container": "@index"
},
"name": "https://example.org/name"
}
}
这确实有效,但又出现了不必要的三元组:
{
"@context": {
"@container": "@index",
"item": "https://example.org/exists",
"name": "https://example.org/name"
}
}
我在这里错过了什么?如何创建仅提取 name
三元组的上下文?
对照您的 JSON-LD 处理器检查:
{
"item": {
"id": "123",
"name": "Test"
} ,
"@context": {
"@base": "http://example.com/id/",
"id": "@id",
"item": "@nest",
"name": "https://example.org/name"
}
}
在 JSON-LD Playground 中,此上下文 produces 以下单个 RDF 三元组:
<http://example.com/id/123> <https://example.org/name> "Test" .
JSON-LD 使用的特征:
- 4.1.6 Keyword Aliasing (
"id": "@id"
);
- 4.4 Nested Properties (
"item": "@nest"
) — new 在 JSON-LD 1.1.
您可能也对 RML 感兴趣。
我正在尝试使用 JSON-LD 使遗留 JSON 文件机器可读。有问题的 JSON 文件有一个顶级对象,其中 item
成员引用包含实际相关数据的对象。
{
"item": {
"id": "123",
"name": "Test"
}
}
当我现在介绍如下上下文时:
{
"@context": {
"name": "https://example.org/name"
}
}
没有提取任何知识,这意味着无法从中解释任何三元组。为了让它发挥作用,我意识到我可以做到以下几点:
{
"@context": {
"item": "https://example.org/exists",
"name": "https://example.org/name"
}
}
这个有效,意味着可以很好地提取名称为 predicate 的三元组。然而,这种方法的问题是,还提取了带有 exists
谓词的不必要的三元组。
因此我尝试将顶级对象标记为索引容器,从而完全忽略 item
键。我只是找不到不需要为 item
术语分配 IRI 的方法来执行此操作,如果我分配一个,再次提取不必要的三元组。
{
"@context": {
"name": "https://example.org/name"
}
}
没有提取任何知识,这意味着无法从中解释任何三元组。为了让它发挥作用,我意识到我可以做到以下几点:
这根本不起作用(因为 item
术语没有 IRI):
{
"@context": {
"item": {
"@container": "@index"
},
"name": "https://example.org/name"
}
}
这确实有效,但又出现了不必要的三元组:
{
"@context": {
"@container": "@index",
"item": "https://example.org/exists",
"name": "https://example.org/name"
}
}
我在这里错过了什么?如何创建仅提取 name
三元组的上下文?
对照您的 JSON-LD 处理器检查:
{
"item": {
"id": "123",
"name": "Test"
} ,
"@context": {
"@base": "http://example.com/id/",
"id": "@id",
"item": "@nest",
"name": "https://example.org/name"
}
}
在 JSON-LD Playground 中,此上下文 produces 以下单个 RDF 三元组:
<http://example.com/id/123> <https://example.org/name> "Test" .
JSON-LD 使用的特征:
- 4.1.6 Keyword Aliasing (
"id": "@id"
); - 4.4 Nested Properties (
"item": "@nest"
) — new 在 JSON-LD 1.1.
您可能也对 RML 感兴趣。