Skip to content

Commit

Permalink
refactor: refactor prettyprinter to be more readable (#2893)
Browse files Browse the repository at this point in the history
* refactor: refactor prettyprinter to be more readable

* fix tests

* fix tests

* refactor to old if condition

* replace all with any
  • Loading branch information
12mohaned committed Nov 28, 2021
1 parent ca7950c commit de27a05
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nltk/tree/prettyprinter.py
Expand Up @@ -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]
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit de27a05

Please sign in to comment.