本文整理汇总了Python中rdflib.graph.ConjunctiveGraph.default_context方法的典型用法代码示例。如果您正苦于以下问题:Python ConjunctiveGraph.default_context方法的具体用法?Python ConjunctiveGraph.default_context怎么用?Python ConjunctiveGraph.default_context使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rdflib.graph.ConjunctiveGraph
的用法示例。
在下文中一共展示了ConjunctiveGraph.default_context方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse
# 需要导入模块: from rdflib.graph import ConjunctiveGraph [as 别名]
# 或者: from rdflib.graph.ConjunctiveGraph import default_context [as 别名]
def parse(self, source, graph):
# we're currently being handed a Graph, not a ConjunctiveGraph
assert graph.store.context_aware # is this implied by formula_aware
assert graph.store.formula_aware
conj_graph = ConjunctiveGraph(store=graph.store)
conj_graph.default_context = graph # TODO: CG __init__ should have a default_context arg
# TODO: update N3Processor so that it can use conj_graph as the sink
conj_graph.namespace_manager = graph.namespace_manager
sink = Sink(conj_graph)
if False:
sink.quantify = lambda *args: True
sink.flatten = lambda *args: True
baseURI = graph.absolutize(source.getPublicId() or source.getSystemId() or "")
p = N3Processor("nowhere", sink, baseURI=baseURI) # pass in "nowhere" so we can set data instead
p.userkeys = True # bah
p.data = source.getByteStream().read() # TODO getCharacterStream?
p.parse()
for prefix, namespace in p.bindings.items():
conj_graph.bind(prefix, namespace)