class_docstr: A string-based encoding of a particular chunking of a text.
  Internally, the ``ChunkString`` class uses a single string to
  encode the chunking of the input text.  This string contains a
  sequence of angle-bracket delimited tags, with chunking indicated
  by braces.  An example of this encoding is::
  
      {<DT><JJ><NN>}<VBN><IN>{<DT><NN>}<.>{<DT><NN>}<VBD><.>
  
  ``ChunkString`` are created from tagged texts (i.e., lists of
  ``tokens`` whose type is ``TaggedType``).  Initially, nothing is
  chunked.
  
  The chunking of a ``ChunkString`` can be modified with the ``xform()``
  method, which uses a regular expression to transform the string
  representation.  These transformations should only add and remove
  braces; they should *not* modify the sequence of angle-bracket
  delimited tags.
  
  :type _str: str
  :ivar _str: The internal string representation of the text's
      encoding.  This string representation contains a sequence of
      angle-bracket delimited tags, with chunking indicated by
      braces.  An example of this encoding is::
  
          {<DT><JJ><NN>}<VBN><IN>{<DT><NN>}<.>{<DT><NN>}<VBD><.>
  
  :type _pieces: list(tagged tokens and chunks)
  :ivar _pieces: The tagged tokens and chunks encoded by this ``ChunkString``.
  :ivar _debug: The debug level.  See the constructor docs.
  
  :cvar IN_CHUNK_PATTERN: A zero-width regexp pattern string that
      will only match positions that are in chunks.
  :cvar IN_STRIP_PATTERN: A zero-width regexp pattern string that
      will only match positions that are in strips.
class_docstr_tok: ["A","string-based","encoding","of","a","particular","chunking","of","a","text",".","Internally",",","the","``","ChunkString","``","class","uses","a","single","string","to","encode","the","chunking","of","the","input","text",".","This","string","contains","a","sequence","of","angle-bracket","delimited","tags",",","with","chunking","indicated","by","braces",".","An","example","of","this","encoding","is",":",":","{","<","DT",">","<","JJ",">","<","NN",">","}","<","VBN",">","<","IN",">","{","<","DT",">","<","NN",">","}","<",".",">","{","<","DT",">","<","NN",">","}","<","VBD",">","<",".",">","``","ChunkString","``","are","created","from","tagged","texts","(","i.e.",",","lists","of","``","tokens","``","whose","type","is","``","TaggedType","``",")",".","Initially",",","nothing","is","chunked",".","The","chunking","of","a","``","ChunkString","``","can","be","modified","with","the","``","xform","(",")","``","method",",","which","uses","a","regular","expression","to","transform","the","string","representation",".","These","transformations","should","only","add","and","remove","braces",";","they","should","*","not","*","modify","the","sequence","of","angle-bracket","delimited","tags",".",":","type","_str",":","str",":","ivar","_str",":","The","internal","string","representation","of","the","text's","encoding",".","This","string","representation","contains","a","sequence","of","angle-bracket","delimited","tags",",","with","chunking","indicated","by","braces",".","An","example","of","this","encoding","is",":",":","{","<","DT",">","<","JJ",">","<","NN",">","}","<","VBN",">","<","IN",">","{","<","DT",">","<","NN",">","}","<",".",">","{","<","DT",">","<","NN",">","}","<","VBD",">","<",".",">",":","type","_pieces",":","list","(","tagged","tokens","and","chunks",")",":","ivar","_pieces",":","The","tagged","tokens","and","chunks","encoded","by","this","``","ChunkString","``",".",":","ivar","_debug",":","The","debug","level",".","See","the","constructor","docs",".",":","cvar","IN_CHUNK_PATTERN",":","A","zero-width","regexp","pattern","string","that","will","only","match","positions","that","are","in","chunks",".",":","cvar","IN_STRIP_PATTERN",":","A","zero-width","regexp","pattern","string","that","will","only","match","positions","that","are","in","strips","."]
docstr: Apply the given transformation to the string encoding of this
  ``ChunkString``.  In particular, find all occurrences that match
  ``regexp``, and replace them using ``repl`` (as done by
  ``re.sub``).
  
  This transformation should only add and remove braces; it
  should *not* modify the sequence of angle-bracket delimited
  tags.  Furthermore, this transformation may not result in
  improper bracketing.  Note, in particular, that bracketing may
  not be nested.
  
  :type regexp: str or regexp
  :param regexp: A regular expression matching the substring
      that should be replaced.  This will typically include a
      named group, which can be used by ``repl``.
  :type repl: str
  :param repl: An expression specifying what should replace the
      matched substring.  Typically, this will include a named
      replacement group, specified by ``regexp``.
  :rtype: None
  :raise ValueError: If this transformation generated an
      invalid chunkstring.
docstr_tok: ["Apply","the","given","transformation","to","the","string","encoding","of","this","``","ChunkString","``",".","In","particular",",","find","all","occurrences","that","match","``","regexp","``",",","and","replace","them","using","``","repl","``","(","as","done","by","``","re.sub","``",")",".","This","transformation","should","only","add","and","remove","braces",";","it","should","*","not","*","modify","the","sequence","of","angle-bracket","delimited","tags",".","Furthermore",",","this","transformation","may","not","result","in","improper","bracketing",".","Note",",","in","particular",",","that","bracketing","may","not","be","nested",".",":","type","regexp",":","str","or","regexp",":","param","regexp",":","A","regular","expression","matching","the","substring","that","should","be","replaced",".","This","will","typically","include","a","named","group",",","which","can","be","used","by","``","repl","``",".",":","type","repl",":","str",":","param","repl",":","An","expression","specifying","what","should","replace","the","matched","substring",".","Typically",",","this","will","include","a","named","replacement","group",",","specified","by","``","regexp","``",".",":","rtype",":","None",":","raise","ValueError",":","If","this","transformation","generated","an","invalid","chunkstring","."]
code: def xform(self, regexp, repl):
      """
      Apply the given transformation to the string encoding of this
      ``ChunkString``.  In particular, find all occurrences that match
      ``regexp``, and replace them using ``repl`` (as done by
      ``re.sub``).
  
      This transformation should only add and remove braces; it
      should *not* modify the sequence of angle-bracket delimited
      tags.  Furthermore, this transformation may not result in
      improper bracketing.  Note, in particular, that bracketing may
      not be nested.
  
      :type regexp: str or regexp
      :param regexp: A regular expression matching the substring
          that should be replaced.  This will typically include a
          named group, which can be used by ``repl``.
      :type repl: str
      :param repl: An expression specifying what should replace the
          matched substring.  Typically, this will include a named
          replacement group, specified by ``regexp``.
      :rtype: None
      :raise ValueError: If this transformation generated an
          invalid chunkstring.
      """
      # Do the actual substitution
      s = re.sub(regexp, repl, self._str)
  
      # The substitution might have generated "empty chunks"
      # (substrings of the form "{}").  Remove them, so they don't
      # interfere with other transformations.
      s = re.sub(r"\{\}", "", s)
  
      # Make sure that the transformation was legal.
      if self._debug > 1:
          self._verify(s, self._debug - 2)
  
      # Commit the transformation.
      self._str = s
  
imports: import re
  import regex
  from nltk.chunk.api import ChunkParserI
  from nltk.tree import Tree
label_desc: Use image node_id 5 for calling the ChunkString obj's underlying member method code with example usage: obj.xform(regexp, repl) without return types