ImmutableProbabilisticTree.un_chomsky_normal_form(expandUnary=True, childChar=u'|', parentChar=u'^', unaryChar=u'+')

This method modifies the tree in three ways:

  1. Transforms a tree in Chomsky Normal Form back to its original structure (branching greater than two)
  2. Removes any parent annotation (if it exists)
  3. (optional) expands unary subtrees (if previously collapsed with collapseUnary(...) )
  • expandUnary (bool) – Flag to expand unary or not (default = True)
  • childChar (str) – A string separating the head node from its children in an artificial node (default = “|”)
  • parentChar (str) – A sting separating the node label from its parent annotation (default = “^”)
  • unaryChar (str) – A string joining two non-terminals in a unary production (default = “+”)