class_docstr: A Tree represents a hierarchical grouping of leaves and subtrees.
  For example, each constituent in a syntax tree is represented by a single Tree.
  
  A tree's children are encoded as a list of leaves and subtrees,
  where a leaf is a basic (non-tree) value; and a subtree is a
  nested Tree.
  
      >>> from nltk.tree import Tree
      >>> print(Tree(1, [2, Tree(3, [4]), 5]))
      (1 2 (3 4) 5)
      >>> vp = Tree('VP', [Tree('V', ['saw']),
      ...                  Tree('NP', ['him'])])
      >>> s = Tree('S', [Tree('NP', ['I']), vp])
      >>> print(s)
      (S (NP I) (VP (V saw) (NP him)))
      >>> print(s[1])
      (VP (V saw) (NP him))
      >>> print(s[1,1])
      (NP him)
      >>> t = Tree.fromstring("(S (NP I) (VP (V saw) (NP him)))")
      >>> s == t
      True
      >>> t[1][1].set_label('X')
      >>> t[1][1].label()
      'X'
      >>> print(t)
      (S (NP I) (VP (V saw) (X him)))
      >>> t[0], t[1,1] = t[1,1], t[0]
      >>> print(t)
      (S (X him) (VP (V saw) (NP I)))
  
  The length of a tree is the number of children it has.
  
      >>> len(t)
      2
  
  The set_label() and label() methods allow individual constituents
  to be labeled.  For example, syntax trees use this label to specify
  phrase tags, such as "NP" and "VP".
  
  Several Tree methods use "tree positions" to specify
  children or descendants of a tree.  Tree positions are defined as
  follows:
  
    - The tree position *i* specifies a Tree's *i*\ th child.
    - The tree position ``()`` specifies the Tree itself.
    - If *p* is the tree position of descendant *d*, then
      *p+i* specifies the *i*\ th child of *d*.
  
  I.e., every tree position is either a single index *i*,
  specifying ``tree[i]``; or a sequence *i1, i2, ..., iN*,
  specifying ``tree[i1][i2]...[iN]``.
  
  Construct a new tree.  This constructor can be called in one
  of two ways:
  
  - ``Tree(label, children)`` constructs a new tree with the
      specified label and list of children.
  
  - ``Tree.fromstring(s)`` constructs a new tree by parsing the string ``s``.
class_docstr_tok: ["A","Tree","represents","a","hierarchical","grouping","of","leaves","and","subtrees",".","For","example",",","each","constituent","in","a","syntax","tree","is","represented","by","a","single","Tree",".","A","tree","'s","children","are","encoded","as","a","list","of","leaves","and","subtrees",",","where","a","leaf","is","a","basic","(","non-tree",")","value",";","and","a","subtree","is","a","nested","Tree",".",">",">",">","from","nltk.tree","import","Tree",">",">",">","print","(","Tree","(","1",",","[","2",",","Tree","(","3",",","[","4","]",")",",","5","]",")",")","(","1","2","(","3","4",")","5",")",">",">",">","vp","=","Tree","(","'VP","'",",","[","Tree","(","'","V","'",",","[","'saw","'","]",")",",","...","Tree","(","'NP","'",",","[","'him","'","]",")","]",")",">",">",">","s","=","Tree","(","'S","'",",","[","Tree","(","'NP","'",",","[","'","I","'","]",")",",","vp","]",")",">",">",">","print","(","s",")","(","S","(","NP","I",")","(","VP","(","V","saw",")","(","NP","him",")",")",")",">",">",">","print","(","s","[","1","]",")","(","VP","(","V","saw",")","(","NP","him",")",")",">",">",">","print","(","s","[","1,1","]",")","(","NP","him",")",">",">",">","t","=","Tree.fromstring","(","``","(","S","(","NP","I",")","(","VP","(","V","saw",")","(","NP","him",")",")",")","''",")",">",">",">","s","==","t","True",">",">",">","t","[","1","]","[","1","]",".set_label","(","'","X","'",")",">",">",">","t","[","1","]","[","1","]",".label","(",")","'","X'",">",">",">","print","(","t",")","(","S","(","NP","I",")","(","VP","(","V","saw",")","(","X","him",")",")",")",">",">",">","t","[","0","]",",","t","[","1,1","]","=","t","[","1,1","]",",","t","[","0","]",">",">",">","print","(","t",")","(","S","(","X","him",")","(","VP","(","V","saw",")","(","NP","I",")",")",")","The","length","of","a","tree","is","the","number","of","children","it","has",".",">",">",">","len","(","t",")","2","The","set_label","(",")","and","label","(",")","methods","allow","individual","constituents","to","be","labeled",".","For","example",",","syntax","trees","use","this","label","to","specify","phrase","tags",",","such","as","``","NP","''","and","``","VP","''",".","Several","Tree","methods","use","``","tree","positions","''","to","specify","children","or","descendants","of","a","tree",".","Tree","positions","are","defined","as","follows",":","-","The","tree","position","*","i","*","specifies","a","Tree","'s","*","i","*","\\","th","child",".","-","The","tree","position","``","(",")","``","specifies","the","Tree","itself",".","-","If","*","p","*","is","the","tree","position","of","descendant","*","d","*",",","then","*","p+i","*","specifies","the","*","i","*","\\","th","child","of","*","d","*",".","I.e.",",","every","tree","position","is","either","a","single","index","*","i","*",",","specifying","``","tree","[","i","]","``",";","or","a","sequence","*","i1",",","i2",",","...",",","iN","*",",","specifying","``","tree","[","i1","]","[","i2","]","...","[","iN","]","``",".","Construct","a","new","tree",".","This","constructor","can","be","called","in","one","of","two","ways",":","-","``","Tree","(","label",",","children",")","``","constructs","a","new","tree","with","the","specified","label","and","list","of","children",".","-","``","Tree.fromstring","(","s",")","``","constructs","a","new","tree","by","parsing","the","string","``","s","``","."]
docstr: This method can modify a tree in three ways:
  
    1. Convert a tree into its Chomsky Normal Form (CNF)
       equivalent -- Every subtree has either two non-terminals
       or one terminal as its children.  This process requires
       the creation of more"artificial" non-terminal nodes.
    2. Markov (vertical) smoothing of children in new artificial
       nodes
    3. Horizontal (parent) annotation of nodes
  
  :param factor: Right or left factoring method (default = "right")
  :type  factor: str = [left|right]
  :param horzMarkov: Markov order for sibling smoothing in artificial nodes (None (default) = include all siblings)
  :type  horzMarkov: int | None
  :param vertMarkov: Markov order for parent smoothing (0 (default) = no vertical annotation)
  :type  vertMarkov: int | None
  :param childChar: A string used in construction of the artificial nodes, separating the head of the
                    original subtree from the child nodes that have yet to be expanded (default = "|")
  :type  childChar: str
  :param parentChar: A string used to separate the node representation from its vertical annotation
  :type  parentChar: str
docstr_tok: ["This","method","can","modify","a","tree","in","three","ways",":","1",".","Convert","a","tree","into","its","Chomsky","Normal","Form","(","CNF",")","equivalent","--","Every","subtree","has","either","two","non-terminals","or","one","terminal","as","its","children",".","This","process","requires","the","creation","of","more","''","artificial","''","non-terminal","nodes",".","2",".","Markov","(","vertical",")","smoothing","of","children","in","new","artificial","nodes","3",".","Horizontal","(","parent",")","annotation","of","nodes",":","param","factor",":","Right","or","left","factoring","method","(","default","=","``","right","''",")",":","type","factor",":","str","=","[","left|right","]",":","param","horzMarkov",":","Markov","order","for","sibling","smoothing","in","artificial","nodes","(","None","(","default",")","=","include","all","siblings",")",":","type","horzMarkov",":","int","|","None",":","param","vertMarkov",":","Markov","order","for","parent","smoothing","(","0","(","default",")","=","no","vertical","annotation",")",":","type","vertMarkov",":","int","|","None",":","param","childChar",":","A","string","used","in","construction","of","the","artificial","nodes",",","separating","the","head","of","the","original","subtree","from","the","child","nodes","that","have","yet","to","be","expanded","(","default","=","``","|","''",")",":","type","childChar",":","str",":","param","parentChar",":","A","string","used","to","separate","the","node","representation","from","its","vertical","annotation",":","type","parentChar",":","str"]
code: def chomsky_normal_form(
      self,
      factor="right",
      horzMarkov=None,
      vertMarkov=0,
      childChar="|",
      parentChar="^",
  ):
      """
      This method can modify a tree in three ways:
  
        1. Convert a tree into its Chomsky Normal Form (CNF)
           equivalent -- Every subtree has either two non-terminals
           or one terminal as its children.  This process requires
           the creation of more"artificial" non-terminal nodes.
        2. Markov (vertical) smoothing of children in new artificial
           nodes
        3. Horizontal (parent) annotation of nodes
  
      :param factor: Right or left factoring method (default = "right")
      :type  factor: str = [left|right]
      :param horzMarkov: Markov order for sibling smoothing in artificial nodes (None (default) = include all siblings)
      :type  horzMarkov: int | None
      :param vertMarkov: Markov order for parent smoothing (0 (default) = no vertical annotation)
      :type  vertMarkov: int | None
      :param childChar: A string used in construction of the artificial nodes, separating the head of the
                        original subtree from the child nodes that have yet to be expanded (default = "|")
      :type  childChar: str
      :param parentChar: A string used to separate the node representation from its vertical annotation
      :type  parentChar: str
      """
      from nltk.tree.transforms import chomsky_normal_form
  
      chomsky_normal_form(
          self, factor, horzMarkov, vertMarkov, childChar, parentChar
      )
  
imports: import re
  from nltk.grammar import Nonterminal, Production
  from nltk.internals import deprecated
label_desc: Use image node_id 24 for calling the Tree obj's underlying member method code with example usage: obj.chomsky_normal_form(factor, horzMarkov, vertMarkov, childChar, parentChar) without return types