def _concatenate_inner(self, direction):
tmp_bucket = []<EOL>source_chunks = self if direction else self[::-<NUM_LIT:1>]<EOL>target_chunks = ChunkList()<EOL>for chunk in source_chunks:<EOL><INDENT>if (<EOL>chunk.dependency == direction or<EOL>(direction is False and chunk.is_space())<EOL>):<EOL><INDENT>tmp_bucket.append(chunk)<EOL>continue<EOL><DEDENT>tmp_bucket.append(chunk)<EOL>if not direction:<EOL><INDENT>tmp_bucket = tmp_bucket[::-<NUM_LIT:1>]<EOL><DEDENT>new_word = '<STR_LIT>'.join([tmp_chunk.word for tmp_chunk in tmp_bucket])<EOL>new_chunk = Chunk(new_word, pos=chunk.pos, label=chunk.label,<EOL>dependency=chunk.dependency)<EOL>target_chunks.append(new_chunk)<EOL>tmp_bucket = ChunkList()<EOL><DEDENT>if tmp_bucket:<EOL><INDENT>target_chunks += tmp_bucket<EOL><DEDENT>if not direction:<EOL><INDENT>target_chunks = target_chunks[::-<NUM_LIT:1>]<EOL><DEDENT>self.list = target_chunks<EOL>
Concatenates chunks based on each chunk's dependency.

        Args:
          direction (bool): Direction of concatenation process. True for forward.