class nltk.ProbabilisticTree(node, children=None, **prob_kwargs)[source]


__init__(node[, children])
append L.append(object) – append object to end
chomsky_normal_form([factor, horzMarkov, ...]) This method can modify a tree in three ways:
collapse_unary([collapsePOS, collapseRoot, ...]) Collapse subtrees with a single child (ie.
draw() Open a new window containing a graphical diagram of this tree.
extend L.extend(iterable) – extend list by appending elements from the iterable
flatten() Return a flat version of the tree, with all non-root non-terminals removed.
fromstring(s[, brackets, read_node, ...]) Read a bracketed tree string and return the resulting tree.
height() Return the height of the tree.
index((value, [start, ...) Raises ValueError if the value is not present.
insert L.insert(index, object) – insert object before index
label() Return the node label of the tree.
return:The tree position of the index-th leaf in this
leaves() Return the leaves of the tree.
logprob() Return log(p), where p is the probability associated with this object.
pformat([margin, indent, nodesep, parens, ...])
return:A pretty-printed string representation of this tree.
pformat_latex_qtree() Returns a representation of the tree compatible with the LaTeX qtree package.
pop(...) Raises IndexError if list is empty or index is out of range.
pos() Return a sequence of pos-tagged words extracted from the tree.
pprint(**kwargs) Print a string representation of this Tree to ‘stream’
pretty_print([sentence, highlight, stream]) Pretty-print this tree as ASCII or Unicode art.
prob() Return the probability associated with this object.
productions() Generate the productions that correspond to the non-terminal nodes of the tree.
remove L.remove(value) – remove first occurrence of value.
reverse L.reverse() – reverse IN PLACE
set_label(label) Set the node label of the tree.
set_logprob(logprob) Set the log probability associated with this object to logprob.
set_prob(prob) Set the probability associated with this object to prob.
sort L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE;
subtrees([filter]) Generate all the subtrees of this tree, optionally restricted to trees matching the filter function.
treeposition_spanning_leaves(start, end)
return:The tree position of the lowest descendant of this
>>> t = Tree.fromstring("(S (NP (D the) (N dog)) (VP (V chased) (NP (D the) (N cat))))")
un_chomsky_normal_form([expandUnary, ...]) This method modifies the tree in three ways:


node Outdated method to access the node value; use the label() method instead.