code: def end_of_chunk(prev_tag, tag, prev_type, type_):
      
      chunk_end = False
  
      if prev_tag == 'E': chunk_end = True
      if prev_tag == 'S': chunk_end = True
  
      if prev_tag == 'B' and tag == 'B': chunk_end = True
      if prev_tag == 'B' and tag == 'S': chunk_end = True
      if prev_tag == 'B' and tag == 'O': chunk_end = True
      if prev_tag == 'I' and tag == 'B': chunk_end = True
      if prev_tag == 'I' and tag == 'S': chunk_end = True
      if prev_tag == 'I' and tag == 'O': chunk_end = True
  
      if prev_tag != 'O' and prev_tag != '.' and prev_type != type_:
          chunk_end = True
  
      return chunk_end
docs: Checks if a chunk ended between the previous and current word.
  
      Args:
          prev_tag: previous chunk tag.
          tag: current chunk tag.
          prev_type: previous type.
          type_: current type.
  
      Returns:
          chunk_end: boolean.