当前位置: 首页>>代码示例>>Python>>正文


Python Store.add方法代码示例

本文整理汇总了Python中rdflib.store.Store.add方法的典型用法代码示例。如果您正苦于以下问题:Python Store.add方法的具体用法?Python Store.add怎么用?Python Store.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rdflib.store.Store的用法示例。


在下文中一共展示了Store.add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add

# 需要导入模块: from rdflib.store import Store [as 别名]
# 或者: from rdflib.store.Store import add [as 别名]
    def add(self, triple, context, quoted=False):
        Store.add(self, triple, context, quoted)

        if context is not None:
            self.__all_contexts.add(context)

        enctriple = self.__encodeTriple(triple)
        sid, pid, oid = enctriple

        self.__addTripleContext(enctriple, context, quoted)

        if sid in self.__subjectIndex:
            self.__subjectIndex[sid].add(enctriple)
        else:
            self.__subjectIndex[sid] = set([enctriple])

        if pid in self.__predicateIndex:
            self.__predicateIndex[pid].add(enctriple)
        else:
            self.__predicateIndex[pid] = set([enctriple])

        if oid in self.__objectIndex:
            self.__objectIndex[oid].add(enctriple)
        else:
            self.__objectIndex[oid] = set([enctriple])
开发者ID:RDFLib,项目名称:rdflib,代码行数:27,代码来源:memory.py

示例2: add

# 需要导入模块: from rdflib.store import Store [as 别名]
# 或者: from rdflib.store.Store import add [as 别名]
    def add(self, triple, context, quoted=False):
        # oldlen = len(self)
        Store.add(self, triple, context, quoted)
        context = getattr(context, 'identifier', context)
        if context is None:
            context = DEFAULT
        if context is not DEFAULT and context not in self.__all_contexts:
            self.__all_contexts.add(context)

        enctriple = self.__encodeTriple(triple)
        sid, pid, oid = enctriple

        self.__addTripleContext(enctriple, context, quoted)

        if sid in self.__subjectIndex:
            self.__subjectIndex[sid].add(enctriple)
        else:
            self.__subjectIndex[sid] = self.family.OO.Set((enctriple,))

        if pid in self.__predicateIndex:
            self.__predicateIndex[pid].add(enctriple)
        else:
            self.__predicateIndex[pid] = self.family.OO.Set((enctriple,))

        if oid in self.__objectIndex:
            self.__objectIndex[oid].add(enctriple)
        else:
            self.__objectIndex[oid] = self.family.OO.Set((enctriple,))
开发者ID:RDFLib,项目名称:rdflib-zodb,代码行数:30,代码来源:ZODB.py

示例3: add

# 需要导入模块: from rdflib.store import Store [as 别名]
# 或者: from rdflib.store.Store import add [as 别名]
    def add(self, triple, context=None, quoted=False):
        """ Add a triple to the store.
            Apply the modifications on the cache, trigger an exception if data
            has already been modified on the server.
            
            :param triple: Triple (subject, predicate, object) to add.
            :param context: 
            :param quoted: The quoted argument is interpreted by formula-aware
                stores to indicate this statement is quoted/hypothetical. It
                should be an error to not specify a context and have the
                quoted argument be True. It should also be an error for the
                quoted argument to be True when the store is not
                formula-aware.

            :returns: 
        """

        LOG.debug("-- ProxyStore.add(triple=%s, context=%s, quoted=%s) --", 
                  triple, context, quoted)

        assert self._identifier is not None, "The store must be open."

        # TODO LATER : Wrong, assert is made to test bugs
        assert self._format is not None, "The store must be open."
        assert quoted == False, "The store -proxyStore- is not formula-aware"

        Store.add(self, triple, context, quoted)

        # Instruction suivant extraite du plugin Sleepycat
        # Store.add(self, (subject, predicate, object), context, quoted)
        self._graph.add(triple)
开发者ID:fderbel,项目名称:ktbs,代码行数:33,代码来源:proxystore.py

示例4: add

# 需要导入模块: from rdflib.store import Store [as 别名]
# 或者: from rdflib.store.Store import add [as 别名]
    def add(self, triple, context, quoted=False, txn=None):
        """\
        Add a triple to the store of triples.
        """
        (subject, predicate, object) = triple
        assert self.__open, "The Store must be open."
        assert context != self, "Can not add triple directly to store"
        Store.add(self, (subject, predicate, object), context, quoted)

        _to_string = self._to_string

        s = _to_string(subject, txn=txn)
        p = _to_string(predicate, txn=txn)
        o = _to_string(object, txn=txn)
        c = _to_string(context, txn=txn)

        cspo, cpos, cosp = self.__indicies

        value = cspo.get(bb("%s^%s^%s^%s^" % (c, s, p, o)), txn=txn)
        if value is None:
            self.__contexts.put(bb(c), "", txn=txn)

            contexts_value = cspo.get(
                bb("%s^%s^%s^%s^" % ("", s, p, o)), txn=txn) or b("")
            contexts = set(contexts_value.split(b("^")))
            contexts.add(bb(c))
            contexts_value = b("^").join(contexts)
            assert contexts_value is not None

            cspo.put(bb("%s^%s^%s^%s^" % (c, s, p, o)), "", txn=txn)
            cpos.put(bb("%s^%s^%s^%s^" % (c, p, o, s)), "", txn=txn)
            cosp.put(bb("%s^%s^%s^%s^" % (c, o, s, p)), "", txn=txn)
            if not quoted:
                cspo.put(bb(
                    "%s^%s^%s^%s^" % ("", s, p, o)), contexts_value, txn=txn)
                cpos.put(bb(
                    "%s^%s^%s^%s^" % ("", p, o, s)), contexts_value, txn=txn)
                cosp.put(bb(
                    "%s^%s^%s^%s^" % ("", o, s, p)), contexts_value, txn=txn)

            self.__needs_sync = True
开发者ID:3mcorp,项目名称:schemaorg,代码行数:43,代码来源:sleepycat.py

示例5: add

# 需要导入模块: from rdflib.store import Store [as 别名]
# 或者: from rdflib.store.Store import add [as 别名]
    def add(self, xxx_todo_changeme, context, quoted=False):
        """\
        Add a triple to the store of triples.
        """
        (subject, predicate, object) = xxx_todo_changeme
        assert self.__open, "The Store must be open."
        assert context != self, "Can not add triple directly to store"
        # Add the triple to the Store, triggering TripleAdded events
        Store.add(self, (subject, predicate, object), context, quoted)

        _to_string = self._to_string

        s = _to_string(subject)
        p = _to_string(predicate)
        o = _to_string(object)
        c = _to_string(context)

        cspo, cpos, cosp = self.__indices

        value = cspo.get(bb("%s^%s^%s^%s^" % (c, s, p, o)))
        if value is None:
            self.__contexts.set(bb(c), "")

            contexts_value = cspo.get(bb(
                "%s^%s^%s^%s^" % ("", s, p, o))) or b("")
            contexts = set(contexts_value.split(b("^")))
            contexts.add(bb(c))
            contexts_value = b("^").join(contexts)
            assert contexts_value != None

            cspo.set(bb("%s^%s^%s^%s^" % (c, s, p, o)), "")
            cpos.set(bb("%s^%s^%s^%s^" % (c, p, o, s)), "")
            cosp.set(bb("%s^%s^%s^%s^" % (c, o, s, p)), "")
            if not quoted:
                cspo.set(bb("%s^%s^%s^%s^" % ("", s, p, o)), contexts_value)
                cpos.set(bb("%s^%s^%s^%s^" % ("", p, o, s)), contexts_value)
                cosp.set(bb("%s^%s^%s^%s^" % ("", o, s, p)), contexts_value)
            self.__needs_sync = True
开发者ID:mwatts15,项目名称:rdflib-kyotocabinet,代码行数:40,代码来源:KyotoCabinet.py

示例6: destroy

# 需要导入模块: from rdflib.store import Store [as 别名]
# 或者: from rdflib.store.Store import add [as 别名]
    def destroy(self, configuration=''):
        import os
        path = configuration or self.homeDir
        if os.path.exists(path):
            for f in os.listdir(path): 
                os.unlink(path+'/'+f)
            os.rmdir(path)

    def add(self, (subject, predicate, object), context, quoted=False):
        """\
        Add a triple to the store of triples.
        """
        assert self.__open, "The Store must be open."
        assert context != self, "Can not add triple directly to store"
        # Add the triple to the Store, triggering TripleAdded events
        Store.add(self, (subject, predicate, object), context, quoted)
        
        _to_string = self._to_string
        
        s = _to_string(subject)
        p = _to_string(predicate)
        o = _to_string(object)
        c = _to_string(context)
        
        cspo, cpos, cosp = self.__indices
        
        value = cspo.get(bb("%s^%s^%s^%s^" % (c, s, p, o)))
        if value is None:
            self.__contexts.set(bb(c), "")
            
            contexts_value = cspo.get(bb("%s^%s^%s^%s^" % ("", s, p, o))) or b("")
开发者ID:pebbie,项目名称:rdflib-kyotocabinet,代码行数:33,代码来源:KyotoCabinet.py

示例7: add

# 需要导入模块: from rdflib.store import Store [as 别名]
# 或者: from rdflib.store.Store import add [as 别名]
    def add(self, triple, context, quoted=False):
        """\
        Add a triple to the store.
        """
        Store.add(self, triple, context, quoted)
        for triple, cg in self.triples(triple, context):
            # triple is already in the store.
            return

        subject, predicate, object = triple

        f = self.forward
        r = self.reverse

        # assign keys for new identifiers

        if subject not in r:
            si = randid()
            while si in f:
                si = randid()
            f[si] = subject
            r[subject] = si
        else:
            si = r[subject]

        if predicate not in r:
            pi = randid()
            while pi in f:
                pi = randid()
            f[pi] = predicate
            r[predicate] = pi
        else:
            pi = r[predicate]

        if object not in r:
            oi = randid()
            while oi in f:
                oi = randid()
            f[oi] = object
            r[object] = oi
        else:
            oi = r[object]

        if context not in r:
            ci = randid()
            while ci in f:
                ci = randid()
            f[ci] = context
            r[context] = ci
        else:
            ci = r[context]

        # add dictionary entries for cspo[c][s][p][o] = 1,
        # cpos[c][p][o][s] = 1, and cosp[c][o][s][p] = 1, creating the
        # nested {} where they do not yet exits.
        self._setNestedIndex(self.cspo, ci, si, pi, oi)
        self._setNestedIndex(self.cpos, ci, pi, oi, si)
        self._setNestedIndex(self.cosp, ci, oi, si, pi)

        if not quoted:
            self._setNestedIndex(self.spo, si, pi, oi, ci)
            self._setNestedIndex(self.pos, pi, oi, si, ci)
            self._setNestedIndex(self.osp, oi, si, pi, ci)
开发者ID:fetus94,项目名称:ordigRDFmapper,代码行数:65,代码来源:memory.py


注:本文中的rdflib.store.Store.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。