(self, chunks, relations)
return new_chunks, new_rels
Remove null chunks
Remove null chunks
Remove null chunks
def clean_chunk_rel(self, chunks, relations):
        """Remove null chunks"""
        new_chunks = []
        oldid2newid = [-1 for i in range(len(chunks))]
        for i, c in enumerate(chunks):
            if c.x2 == c.x1 or c.y2 == c.y1 or c.text == "":
                continue
            oldid2newid[i] = len(new_chunks)
            new_chunks.append(c)
        new_rels = []
        for i, j, t in relations:
            ni = oldid2newid[i]
            nj = oldid2newid[j]
            if ni != -1 and nj != -1: new_rels.append((ni, nj, t))
        return new_chunks, new_rels
def clean_chunk_rel ( self , chunks , relations ) : new_chunks = [ ] oldid2newid = [ - 1 for i in range ( len ( chunks ) ) ] for i , c in enumerate ( chunks ) : if c . x2 == c . x1 or c . y2 == c . y1 or c . text == "" : continue oldid2newid [ i ] = len ( new_chunks ) new_chunks . append ( c ) new_rels = [ ] for i , j , t in relations : ni = oldid2newid [ i ] nj = oldid2newid [ j ] if ni != - 1 and nj != - 1 : new_rels . append ( ( ni , nj , t ) ) return new_chunks , new_rels