class_docstr: NER Sample class to hold the necessary info and provide atomic operations.
class_docstr_tok: ["NER","Sample","class","to","hold","the","necessary","info","and","provide","atomic","operations","."]
docstr: Replace one entity and update entities info.
  
  :param int start: the start position of the entity to be replaced
  :param int end: the end position of the entity to be replaced
  :param str entity: the entity to be replaced with
  :param str label: the category of the entity
  :return: Modified NERSample
docstr_tok: ["Replace","one","entity","and","update","entities","info",".",":","param","int","start",":","the","start","position","of","the","entity","to","be","replaced",":","param","int","end",":","the","end","position","of","the","entity","to","be","replaced",":","param","str","entity",":","the","entity","to","be","replaced","with",":","param","str","label",":","the","category","of","the","entity",":","return",":","Modified","NERSample"]
code: def entity_replace(self, start, end, entity, label):
      r"""
      Replace one entity and update entities info.
  
      :param int start: the start position of the entity to be replaced
      :param int end: the end position of the entity to be replaced
      :param str entity: the entity to be replaced with
      :param str label: the category of the entity
      :return: Modified NERSample
  
      """
      assert start <= end, "start is before end!"
      sample = self.clone(self)
      entity = entity.split(" ")
      word_prefix = sample.text.words[:start]
      word_suffix = (
          []
          if end == len(sample.text.words) - 1
          else sample.text.words[end + 1 :]
      )
      sample.text = TextField(word_prefix + entity + word_suffix)
      tag_prefix = sample.tags[:start]
      tag_suffix = (
          [] if end == len(sample.tags) - 1 else sample.tags[end + 1 :]
      )
  
      if self.mode == "BIO":
          sample.tags = ListField(
              tag_prefix
              + ["B-" + label]
              + ["I-" + label] * (len(entity) - 1)
              + tag_suffix
          )
      else:
          len_entity = len(entity)
          if len_entity == 1:
              substitude = ["S-" + label]
          elif len_entity == 2:
              substitude = ["B-" + label] + ["E-" + label]
          else:
              substitude = (
                  ["B-" + label]
                  + ["I-" + label] * (len_entity - 2)
                  + ["E-" + label]
              )
          sample.tags = ListField(tag_prefix + substitude + tag_suffix)
          # set mask for changed entities
  
      # for i in range(start, end+1):
      #     sample.text.set_mask(i, MODIFIED_MASK)
      sample.entities = ListField(
          sample.find_entities_BIO(sample.text.words, sample.tags)
      )
  
      return sample
  
imports: from .sample import Sample
  from ..field import ListField, TextField
  from ....common.utils.list_op import get_align_seq
label_desc: Use image node_id 16 for calling the NERSample obj's underlying member method code with example usage: obj.entity_replace(start, end, entity, label) and returns: sample