【发布时间】:2015-09-20 05:49:50
【问题描述】:
我正在尝试对 OWL 本体进行可视化。我已将其转换为 JSON-LD,但现在需要将其转换为 D3 的节点/链接格式吗?作为参考,格式如下所示:
{
"nodes": [
{"x": 469, "y": 410},
{"x": 493, "y": 364},
{"x": 442, "y": 365},
{"x": 467, "y": 314},
{"x": 477, "y": 248},
{"x": 425, "y": 207},
{"x": 402, "y": 155},
{"x": 369, "y": 196},
{"x": 350, "y": 148},
{"x": 539, "y": 222},
{"x": 594, "y": 235},
{"x": 582, "y": 185},
{"x": 633, "y": 200}
],
"links": [
{"source": 0, "target": 1},
{"source": 1, "target": 2},
{"source": 2, "target": 0},
{"source": 1, "target": 3},
{"source": 3, "target": 2},
{"source": 3, "target": 4},
{"source": 4, "target": 5},
{"source": 5, "target": 6},
{"source": 5, "target": 7},
{"source": 6, "target": 7},
{"source": 6, "target": 8},
{"source": 7, "target": 8},
{"source": 9, "target": 4},
{"source": 9, "target": 11},
{"source": 9, "target": 10},
{"source": 10, "target": 11},
{"source": 11, "target": 12},
{"source": 12, "target": 10}
]
}
我知道我可以使用 d3.json 打开一个 json 文件,但我不确定如何从 JSON-LD 转换为上述格式。有什么解决办法吗?谢谢。
编辑:
我的猫头鹰本体可在此处的 pastebin 上找到(json-ld 格式):http://pastebin.com/g7ggDyFX。如果您在上下文中达到高峰,您可以看到我正在通过“isSubClass”属性对本体建模。
我知道要在 D3 中读取 json 文件,我可以使用 d3.json。我不确定如何准确转换为上述格式。
我发现这个 github 存储库 https://github.com/uf6/ottograf 说它应该能够转换为格式,但是我在运行它时遇到了很多麻烦,我也想将它保存在 javascript 中。任何提示/解决方案?谢谢!
【问题讨论】:
-
您能分享一份 JSON-LD 格式的数据样本吗?
-
您的 JSON-LD 数据子集:
{ "@id": "schema:Person", "@type": "owl:Class", "subClassOf": { "@id": "gr:BusinessEntity" } }是否可以转换为两个节点schema:Person和gr:BusinessEntity之间的一条边?
标签: javascript json node.js d3.js