Advertisement
Guest User

Untitled

a guest
Nov 20th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. ( (S (S-TPC-2 (NP-SBJ (NP (DT The) (NN asbestos) (NN fiber) ) (, ,)
  2. (NP (NN crocidolite) ) (, ,) ) (VP (VBZ is) (ADJP-PRD (RB unusually) (JJ resilient) )
  3. (SBAR-TMP (IN once) (S (NP-SBJ (PRP it) ) (VP (VBZ enters) (NP (DT the) (NNS lungs) ))))
  4. (, ,) (PP (IN with)(S-NOM (NP-SBJ (NP (RB even) (JJ brief) (NNS exposures) ) (PP (TO to)
  5. (NP (PRP it) ))) (VP (VBG causing) (NP (NP (NNS symptoms) ) (SBAR (WHNP-1 (WDT that) )
  6. (S (NP-SBJ (-NONE- *T*-1) ) (VP (VBP show) (PRT (RP up) ) (ADVP-TMP (NP (NNS decades) )
  7. (JJ later) )))))))))) (, ,) (NP-SBJ (NNS researchers) ) (VP (VBD said)(SBAR (-NONE- 0)
  8. (S (-NONE- *T*-2) ))) (. .) ))
  9.  
  10. import re
  11. import nltk
  12. from nltk.tree import *
  13. tree = Tree.fromstring(line) // Each parse tree is stored in one single line
  14. for subtree in tree.subtrees():
  15. re.sub('-.*', '', subtree.label())
  16. print tree
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement