Beispiel #1
0
def transform(t):
    ptb.remove_empty_elements(t)
    ptb.simplify_labels(t)
    return ptb.add_root(t, 'ROOT')
Beispiel #2
0
        ('PRP', 0, 1),
        ('ADVP', 1, 2),
        ('RB', 1, 2),
        ('VP', 2, 6),
        ('VBZ', 2, 3),
        ('NP-PRD', 3, 6),
        ('DT', 3, 4),
        ('NN', 4, 5),
        ('NN', 5, 6),
        (',', 6, 7),
        ('NP-SBJ', 7, 8),
        ('NNS', 7, 8),
        ('VP', 8, 9),
        ('VBP', 8, 9),
        ('SBAR', 9, 9),
        ('S', 9, 9),
        ('-NONE-', 9, 9),
        ('-NONE-', 9, 9),
        ('.', 9, 10)
    ]

    t = next(ptb.parse(tree))
    u = next(ptb.parse(transformed_tree))

    expectequal( set(spans) , set(ptb.all_spans(t)) )

    ptb.remove_empty_elements(t)
    ptb.simplify_labels(t)
    t = ptb.add_root(t)
    expectequal( set(ptb.all_spans(t)) , set(ptb.all_spans(u)) )