def addN(self, quads):
        for s, p, o, c in quads:
            assert c is not None, \
                "Context associated with %s %s %s is None!" % (s, p, o)
            qSlots = genQuadSlots([s, p, o, c.identifier], self.useSignedInts)

            # print 'Writing data...', qSlots
            # Add to the denormalized delimited file:
            beginning = True
            for item in qSlots:
                parts = [item.md5Int, item.termType]
                if not self.recent.check((item.termType, item.term)):
                    self.lexicalFile.write(
                        make_delimited(parts + [item.normalizeTerm()]) +
                        ROW_DELIMITER)
                    self.recent_misses += 1
                else:
                    self.recent_hits += 1

                if item.position == OBJECT:
                    dqs = item.getDatatypeQuadSlot()
                    if dqs is not None:
                        parts.append(dqs.md5Int)
                        if not self.recent.check((dqs.termType, dqs.term)):
                            self.lexicalFile.write(
                                make_delimited(
                                    [dqs.md5Int, 'U',
                                     dqs.normalizeTerm()]) + ROW_DELIMITER)
                            self.recent_misses += 1
                        else:
                            self.recent_hits += 1
                    else:
                        parts.append(None)

                    if item.termType == 'L':
                        parts.append(item.term.language)
                    else:
                        parts.append(None)
                if not beginning:
                    self.triplesFile.write(COL_DELIMITER)
                beginning = False
                self.triplesFile.write(make_delimited(parts))
            self.triplesFile.write(ROW_DELIMITER)
Esempio n. 2
0
 def addN(self, quads):
     for s,p,o,c in quads:
         assert c is not None, \
             "Context associated with %s %s %s is None!" % (s, p, o)
         qSlots = genQuadSlots([s, p, o, c.identifier],
                                  self.useSignedInts)
         
         # print 'Writing data...', qSlots
         # Add to the denormalized delimited file:
         beginning = True
         for item in qSlots:
             parts = [item.md5Int, item.termType]
             if not self.recent.check((item.termType, item.term)):
                 self.lexicalFile.write(make_delimited(
                     parts + [item.normalizeTerm()]) + ROW_DELIMITER)
                 self.recent_misses += 1
             else:
                 self.recent_hits += 1
                 
             if item.position == OBJECT:
                 dqs = item.getDatatypeQuadSlot()
                 if dqs is not None:
                     parts.append(dqs.md5Int)
                     if not self.recent.check((dqs.termType, dqs.term)):
                         self.lexicalFile.write(make_delimited(
                             [dqs.md5Int, 'U', dqs.normalizeTerm()]) +
                             ROW_DELIMITER)
                         self.recent_misses += 1
                     else:
                         self.recent_hits += 1
                 else:
                     parts.append(None)
                     
                 if item.termType == 'L':
                     parts.append(item.term.language)
                 else:
                     parts.append(None)
             if not beginning:
                     self.triplesFile.write(COL_DELIMITER)
             beginning = False
             self.triplesFile.write(make_delimited(parts))
         self.triplesFile.write(ROW_DELIMITER)
    def addN(self, quads):
        for s, p, o, c in quads:
            assert c is not None, \
                "Context associated with %s %s %s is None!" % (s, p, o)
            qSlots = genQuadSlots([s, p, o, c.identifier], self.useSignedInts)

            table = self.get_table((s, p, o))
            table.delimited_file.write(
                make_delimited(table.makeRowComponents(qSlots)) +
                ROW_DELIMITER)

            for row in table.listIdentifiers(qSlots):
                if not self.recent.check((row[2], row[1])):
                    self.idHash.delimited_file.write(
                        make_delimited(row) + ROW_DELIMITER)
                    self.recent_misses += 1
                else:
                    self.recent_hits += 1

            for row in table.listLiterals(qSlots):
                self.valueHash.delimited_file.write(
                    make_delimited(row) + ROW_DELIMITER)
Esempio n. 4
0
 def addN(self, quads):
     for s,p,o,c in quads:
         assert c is not None, \
             "Context associated with %s %s %s is None!" % (s, p, o)
         qSlots = genQuadSlots([s, p, o, c.identifier],
                                         self.useSignedInts)
         
         table = self.get_table((s, p, o))
         table.delimited_file.write(make_delimited(
             table.makeRowComponents(qSlots)) + ROW_DELIMITER)
         
         for row in table.listIdentifiers(qSlots):
             if not self.recent.check((row[2], row[1])):
                 self.idHash.delimited_file.write(make_delimited(
                     row) + ROW_DELIMITER)
                 self.recent_misses += 1
             else:
                 self.recent_hits += 1
         
         for row in table.listLiterals(qSlots):
             self.valueHash.delimited_file.write(
                 make_delimited(row) + ROW_DELIMITER)