Use the Tree.fromstring()
method:
>>> from nltk import Tree
>>> parse = Tree.fromstring('(ROOT (S (NP (PRP You)) (VP (MD could) (VP (VB say) (SBAR (IN that) (S (NP (PRP they)) (ADVP (RB regularly)) (VP (VB catch) (NP (NP (DT a) (NN shower)) (, ,) (SBAR (WHNP (WDT which)) (S (VP (VBZ adds) (PP (TO to) (NP (NP (PRP$ their) (NN exhilaration)) (CC and) (NP (FW joie) (FW de) (FW vivre))))))))))))) (. .)))')
>>> parse
Tree('ROOT', [Tree('S', [Tree('NP', [Tree('PRP', ['You'])]), Tree('VP', [Tree('MD', ['could']), Tree('VP', [Tree('VB', ['say']), Tree('SBAR', [Tree('IN', ['that']), Tree('S', [Tree('NP', [Tree('PRP', ['they'])]), Tree('ADVP', [Tree('RB', ['regularly'])]), Tree('VP', [Tree('VB', ['catch']), Tree('NP', [Tree('NP', [Tree('DT', ['a']), Tree('NN', ['shower'])]), Tree(',', [',']), Tree('SBAR', [Tree('WHNP', [Tree('WDT', ['which'])]), Tree('S', [Tree('VP', [Tree('VBZ', ['adds']), Tree('PP', [Tree('TO', ['to']), Tree('NP', [Tree('NP', [Tree('PRP$', ['their']), Tree('NN', ['exhilaration'])]), Tree('CC', ['and']), Tree('NP', [Tree('FW', ['joie']), Tree('FW', ['de']), Tree('FW', ['vivre'])])])])])])])])])])])])]), Tree('.', ['.'])])])
>>> parse.pretty_print()
ROOT
|
S
______________________________________________________|_____________________________________________________________
| VP |
| ____|___ |
| | VP |
| | ___|____ |
| | | SBAR |
| | | ____|_______ |
| | | | S |
| | | | _______|____________ |
| | | | | | VP |
| | | | | | ____|______________ |
| | | | | | | NP |
| | | | | | | __________|__________ |
| | | | | | | | | SBAR |
| | | | | | | | | ____|____ |
| | | | | | | | | | S |
| | | | | | | | | | | |
| | | | | | | | | | VP |
| | | | | | | | | | ____|____ |
| | | | | | | | | | | PP |
| | | | | | | | | | | ____|_____________________ |
| | | | | | | | | | | | NP |
| | | | | | | | | | | | ________________|________ |
NP | | | NP ADVP | NP | WHNP | | NP | NP |
| | | | | | | ___|____ | | | | ____|_______ | ____|____ |
PRP MD VB IN PRP RB VB DT NN , WDT VBZ TO PRP$ NN CC FW FW FW .
| | | | | | | | | | | | | | | | | | | |
You could say that they regularly catch a shower , which adds to their exhilaration and joie de vivre .