Gist
.
Robot
班级和a
Rover
作为它的子类,使用
@graph
{
"@context": {
"schema": "https://schema.org/",
"blog": "https://blog.me/",
"ex": "https://example.org/",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#"
},
"@id": "blog:JSONLD-and-named-graphs",
"@type": "schema:blogPost",
"rdfs:label": "JSON-LD and Named Graphs",
"@graph": [
{
"@id": "ex:Robot",
"@type": "rdfs:Class"
},
{
"@id": "ex:Rover",
"rdfs:subClassOf": {
"@id": "ex:Robot"
}
}
]
}
使用Python
rdflib
,我们希望将所有这些导入指定为
https://myblog.net/rdf/
这样地:
...
graph = ConjunctiveGraph()
serialized_document = json.dumps(JSONLD_DOCUMENT)
graph.parse(
data=serialized_document,
format='json-ld',
# All the semantic data about my blog is stored in a particular
# named graph.
publicID='https://myblog.net/rdf/',
)
所有数据都应该在命名图下导入
https://myblog.net/rdf/
基于
publicID
实际结果
prescribes
.
{"@id": "badoom", "@graph": {...}}
意思是我们描述了一个
并提供其名称为
@id
.
问题
公共ID
争论?
软件版本:
Python 3.8.1
rdflib==5.0.0
rdflib-jsonld==0.5.0
PyLD==2.0.3