class_docstr: Coref Part Sample: corresponed to a part of a Coref Sample
class_docstr_tok: ["Coref","Part","Sample",":","corresponed","to","a","part","of","a","Coref","Sample"]
docstr: concat conll parts
  
  :param: many CorefPartSamples
      elements in which are assumed to be parts from the same conll,
      generated by part_conll.
      Merge result is still treated as a conll part, which should be
      postprocessed by `remove_invalid_corefs_from_part` to form a
      valid CorefSample.
  :return ~textflint.input.component.sample.CorefPartSample:
      a CorefPartSample of a conll-part
docstr_tok: ["concat","conll","parts",":","param",":","many","CorefPartSamples","elements","in","which","are","assumed","to","be","parts","from","the","same","conll",",","generated","by","part_conll",".","Merge","result","is","still","treated","as","a","conll","part",",","which","should","be","postprocessed","by","`","remove_invalid_corefs_from_part","`","to","form","a","valid","CorefSample",".",":","return","~textflint.input.component.sample.CorefPartSample",":","a","CorefPartSample","of","a","conll-part"]
code: def concat_conll_parts(*args):
      r"""
      concat conll parts
  
      :param: many CorefPartSamples
          elements in which are assumed to be parts from the same conll,
          generated by part_conll.
          Merge result is still treated as a conll part, which should be
          postprocessed by `remove_invalid_corefs_from_part` to form a
          valid CorefSample.
      :return ~textflint.input.component.sample.CorefPartSample:
          a CorefPartSample of a conll-part
  
      """
      if len(args) == 0:
          return CorefPartSample(data=None, origin=None)
      ret_coref_sample = CorefPartSample(None, origin=args[0])
      shift = 0
      for corefsam in args:
          if corefsam.doc_key != None:
              ret_coref_sample.doc_key = corefsam.doc_key
              break
      mask, x, sen_map, doc_sp = [], [], [], []
      clusters = [[] for cluster in args[0].clusters.field_value]
      constituents, ner = [], []
      for corefsam in args:
  
          @shift_decor
          def index_shift(word_idx):
              return word_idx + shift
  
          mask.extend(corefsam.x.mask)
          x.extend(corefsam.x.words)
          sen_map.extend(corefsam.sen_map)
          doc_sp.extend(corefsam.doc_sp.words)
          samp_clusters = recur_ap(
              index_shift, corefsam.clusters.field_value
          )
          for i in range(len(clusters)):
              clusters[i].extend(samp_clusters[i])
          constituents.extend(
              recur_ap(index_shift, corefsam.constituents.field_value)
          )
          ner.extend(recur_ap(index_shift, corefsam.ner.field_value))
          shift += len(corefsam.x.words)
      ret_coref_sample.x = TextField(x, mask=mask)
      ret_coref_sample.sen_map = sen_map
      ret_coref_sample.doc_sp = TextField(doc_sp, mask=mask)
      ret_coref_sample.clusters = ListField(clusters)
      ret_coref_sample.constituents = ListField(constituents)
      ret_coref_sample.ner = ListField(ner)
      return ret_coref_sample
  
imports: from ....common.settings import ORIGIN, TASK_MASK
  from ....common.utils.fp_utils import *
  from ....common.utils.shift_utils import *
  from .sample import Sample
  from ..field import ListField, TextField
label_desc: Use image node_id 5 for calling the CorefPartSample obj's underlying member method code with example usage: obj.concat_conll_parts() and returns: ret_coref_sample, CorefPartSample, unknown