How to iterate through all nodes of a tree?
问题 I want to simplify my parse trees' nodes, i.e. given a node I get rid of the first hyphen and whatever that comes after that hyphen. For example if a node is NP-TMP-FG, I want to make it NP and if it is SBAR-SBJ, I want to make it SBAR and so on. This is an example of one parse tree that I have ( (S (S-TPC-2 (NP-SBJ (NP (DT The) (NN asbestos) (NN fiber) ) (, ,) (NP (NN crocidolite) ) (, ,) ) (VP (VBZ is) (ADJP-PRD (RB unusually) (JJ resilient) ) (SBAR-TMP (IN once) (S (NP-SBJ (PRP it) ) (VP