class_docstr: CNNER Sample class to hold the necessary info and provide atomic operations.
  the input x can be a sentence or a list of single words,
  while y being a list of tags aligned to each word in x.
  
  Example::
      1. {'x':'上海浦东开发与法制建设同步', 'y':'['B-GPE','E-GPE','B-GPE','E-GPE','O','O','O','O','O','O','O','O','O']'}
  
      2. {
          'x':['上','海','浦','东','开','发','与','法','制','建','设','同','步'],
          'y':['B-GPE','E-GPE','B-GPE',E'-GPE','O','O','O','O','O','O','O','O','O']
         }
class_docstr_tok: ["CNNER","Sample","class","to","hold","the","necessary","info","and","provide","atomic","operations",".","the","input","x","can","be","a","sentence","or","a","list","of","single","words",",","while","y","being","a","list","of","tags","aligned","to","each","word","in","x",".","Example",":",":","1",".","{","'","x","'",":","'\u4e0a\u6d77\u6d66\u4e1c\u5f00\u53d1\u4e0e\u6cd5\u5236\u5efa\u8bbe\u540c\u6b65","'",",","'","y","'",":","'","[","'","B-GPE","'",",","'","E-GPE","'",",","'","B-GPE","'",",","'","E-GPE","'",",","'","O","'",",","'","O","'",",","'","O","'",",","'","O","'",",","'","O","'",",","'","O","'",",","'","O","'",",","'","O","'",",","'","O","'","]","'","}","2",".","{","'","x","'",":","[","'","\u4e0a","'",",","'","\u6d77","'",",","'","\u6d66","'",",","'","\u4e1c","'",",","'","\u5f00","'",",","'","\u53d1","'",",","'","\u4e0e","'",",","'","\u6cd5","'",",","'","\u5236","'",",","'","\u5efa","'",",","'","\u8bbe","'",",","'","\u540c","'",",","'","\u6b65","'","]",",","'","y","'",":","[","'","B-GPE","'",",","'","E-GPE","'",",","'","B-GPE","'",",","E'-GPE","'",",","'","O","'",",","'","O","'",",","'","O","'",",","'","O","'",",","'","O","'",",","'","O","'",",","'","O","'",",","'","O","'",",","'","O","'","]","}"]
docstr: Replace multi entity in once time.Assume input entities
  with reversed sequential.
  
  :param list entities_info: list of entity_info
  :param list candidates: candidate entities
  :return: Modified NERSample
docstr_tok: ["Replace","multi","entity","in","once","time.Assume","input","entities","with","reversed","sequential",".",":","param","list","entities_info",":","list","of","entity_info",":","param","list","candidates",":","candidate","entities",":","return",":","Modified","NERSample"]
code: def entities_replace(self, entities_info, candidates):
      r"""
      Replace multi entity in once time.Assume input entities
      with reversed sequential.
  
      :param list entities_info: list of entity_info
      :param list candidates: candidate entities
      :return: Modified NERSample
  
      """
      assert len(entities_info) and len(entities_info) == len(
          candidates
      )
      assert isinstance(entities_info, list)
      assert isinstance(candidates, list)
      sample = self.clone(self)
  
      offset = 0
      entities_info = sorted(entities_info, key=lambda x: x["start"])
      for entity, candidate in zip(entities_info, candidates):
          rep_range = (
              entity["start"] + offset,
              entity["end"] + offset + 1,
          )
          candidate = list(candidate)
  
          len_candidate = len(candidate)
          offset += len_candidate - len(entity["entity"])
          ent_label = entity["tag"]
  
          if len_candidate == 1:
              tags = ["S-" + ent_label]
          elif len_candidate == 2:
              tags = ["B-" + ent_label, "E-" + ent_label]
          else:
              tags = (
                  ["B-" + ent_label]
                  + ["M-" + ent_label] * (len_candidate - 2)
                  + ["E-" + ent_label]
              )
          sample = sample.unequal_replace_field_at_indices(
              "text", [rep_range], [candidate]
          )
          sample = sample.unequal_replace_field_at_indices(
              "tags", [rep_range], [tags]
          )
  
      sample.entities = sample.find_entities_BMOES(
          sample.text.tokens, sample.tags
      )
      return sample
  
file_path: textflint/textflint/input/component/sample/nercn_sample.py
imports: from .cnsample import CnSample
  from ..field import ListField, CnTextField
  from ....common.utils.list_op import get_align_seq
label_desc: Use image node_id 8 for calling the NERCnSample obj's underlying member method code with example usage: obj.entities_replace(entities_info, candidates) and returns: sample