diff --git a/nltk/tree/prettyprinter.py b/nltk/tree/prettyprinter.py index 2ce106e055..24337ae329 100644 --- a/nltk/tree/prettyprinter.py +++ b/nltk/tree/prettyprinter.py @@ -75,7 +75,7 @@ def __init__(self, tree, sentence=None, highlight=()): leaves = tree.leaves() if ( leaves - and not any(len(a) == 0 for a in tree.subtrees()) + and all(len(a) > 0 for a in tree.subtrees()) and all(isinstance(a, int) for a in leaves) ): sentence = [str(a) for a in leaves] @@ -291,7 +291,7 @@ def dumpmatrix(): matrix[rowidx][i] = ids[m] nodes[ids[m]] = tree[m] # add column to the set of children for its parent - if m != (): + if len(m) > 0: childcols[m[:-1]].add((rowidx, i)) assert len(positions) == 0