當前位置: 首頁>>代碼示例>>Python>>正文


Python ConjunctiveGraph.default_context方法代碼示例

本文整理匯總了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
        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)
開發者ID:Ju2ender,項目名稱:watchdog,代碼行數:21,代碼來源:N3Parser.py


注:本文中的rdflib.Graph.ConjunctiveGraph.default_context方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。