class_docstr: WSDSample Class
class_docstr_tok: ["WSDSample","Class"]
docstr: Replace scope items of field value with items of different length.
  :param str field: transformed field
  :param list indices: indices of delete positions
  :param list items: insert items
  :return WSDSample: a modified sample
   
docstr_tok: ["Replace","scope","items","of","field","value","with","items","of","different","length",".",":","param","str","field",":","transformed","field",":","param","list","indices",":","indices","of","delete","positions",":","param","list","items",":","insert","items",":","return","WSDSample",":","a","modified","sample"]
code: def unequal_replace_field_at_indices(self, field, indices, items):
      r"""
      Replace scope items of field value with items of different length.
      :param str field: transformed field
      :param list indices: indices of delete positions
      :param list items: insert items
      :return WSDSample: a modified sample
      """
      self.check_indices_and_items(indices, items)
      sample = self.clone(self)
      ori_instance = sample.instance.field_value
      targets = list()
      offset = 0
      for key, start, end, word, sense in ori_instance:
          # target word unchanged
          if [start, end] not in indices:
              targets.append(
                  [key, start + offset, end + offset, word, sense]
              )
          else:
              # target word changed
              idx = indices.index([start, end])
              new_item = items[idx]  # sense key
              new_start = start + offset
              new_word = " ".join([t.split("%")[0] for t in new_item])
              new_word = " ".join(new_word.split("_"))
              offset += len(new_word.split(" ")) - (end - start)
              new_end = end + offset
              targets.append(
                  [key, new_start, new_end, new_word, new_item[0]]
              )
      sorted_items, sorted_indices = zip(
          *sorted(zip(items, indices), key=lambda x: x[1], reverse=True)
      )
      # record pos_list
      ori_pos = sample.pos.field_value
      pos_list = list()
      lemma_list = list()
      for index, item in zip(sorted_indices, sorted_items):
          start, end = index
          tag = ori_pos[start:end][0]
          ins_word = item[0].split("%")[0].split("_")
          pos_list.append([tag] * len(ins_word))
          lemma_list.append([item[0].split("%")[0]] * len(ins_word))
      for idx, item in enumerate(
          zip(sorted_items, pos_list, lemma_list)
      ):
          sorted_token, sorted_pos, sorted_lemma = item
          ins_word = sorted_token[0].split("%")[0].split("_")
          sample = sample.delete_field_at_index(
              field, sorted_indices[idx]
          )
          insert_index = (
              sorted_indices[idx]
              if isinstance(sorted_indices[idx], int)
              else sorted_indices[idx][0]
          )
          field_obj = getattr(sample, field)
          if insert_index > len(field_obj):
              raise ValueError(
                  "Cant replace items at range {0}".format(
                      sorted_indices[idx]
                  )
              )
          elif insert_index == len(field_obj):
              sample = sample.insert_field_after_index(
                  field,
                  insert_index - 1,
                  ins_word,
                  sorted_pos,
                  sorted_lemma,
              )
          else:
              sample = sample.insert_field_before_index(
                  field,
                  insert_index,
                  ins_word,
                  sorted_pos,
                  sorted_lemma,
              )
  
      setattr(sample, "instance", ListField(targets))
      return sample
  
imports: from .sample import Sample
  from ..field import TextField, ListField
  import json
  from ....common.settings import TASK_MASK, PUNC
  import nltk
label_desc: Use image node_id 20 for calling the WSDSample obj's underlying member method code with example usage: obj.unequal_replace_field_at_indices(field, indices, items) and returns: sample