1 / 18

How to perform tree surgery

How to perform tree surgery. Anna Rafferty Marie-Catherine de Marneffe. Tsurgeon by Roger Levy. What? makes operations on a grammatical tree How? based on Tregex syntax Where? Javanlp: trees.tregex.tsurgeon. S. VP. DT. VBD. VP. NP. NP. VBG. PP. NP. NN. NN. IN. NN. NNS.

booth
Download Presentation

How to perform tree surgery

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. How to perform tree surgery Anna Rafferty Marie-Catherine de Marneffe

  2. Tsurgeon by Roger Levy • What? makes operations on a grammatical tree • How? based on Tregex syntax • Where? Javanlp: trees.tregex.tsurgeon

  3. S VP DT VBD VP NP NP VBG PP NP NN NN IN NN NNS PRP The firm stopped using croco-dilite in its cigarette filters How? Tregex • utility for identifying patterns in trees (like regular expressions for strings) • node descriptions and relationships between nodes NP < /^NN/

  4. Tsurgeon syntax • Define a pattern to be matched on the trees VBZ=vbz $ NP • Define one or several operation(s) relabel vbz VBZ_TRANSITIVE

  5. Delete (ROOT (SBARQ (SQ (NP (NNS Cats)) (VP (VBP do) (VP (WHNP what) (VB eat))) (PUNCT ?))) PUNCT=punct > SBARQ delete punct

  6. Delete (ROOT (SBARQ (SQ (NP (NNS Cats)) (VP (VBP do) (VP (WHNP what) (VB eat))) (PUNCT ?))) PUNCT=punct > SBARQ delete punct delete <name1>…<nameN> Delete the node and everything below it

  7. Excise (ROOT (SBARQ (SQ (NP (NNS Cats)) (VP (VBP do) (VP (WHNP what) (VB eat)))))) SBARQ=sbarq > ROOT excise sbarq sbarq (ROOT (SQ (NP (NNS Cats)) (VP (VBP do) (VP (WHNP what) (VB eat)))))

  8. Excise (ROOT (SBARQ (SQ (NP (NNS Cats)) (VP (VBP do) (VP (WHNP what) (VB eat)))))) SBARQ=sbarq > ROOT excise sbarq sbarq excise <name1> <name2> name1 is name2 or dominates name2. All children of name2 go into the parent of name1, where name1 was.

  9. Prune prune <name1>…<nameN> Different from delete: If after the pruning the parent has no children anymore, the parent is pruned too.

  10. Insert (ROOT (SQ (NP (NNS Cats)) (VP (VBP do) (VP (WHNP what) (VB eat))))) SQ=sq > ROOT !<- /PUNCT/ insert (PUNCT .) >-1 sq <tree> <position> (ROOT (SQ (NP (NNS Cats)) (VP (VBP do) (VP (WHNP what) (VB eat))) (PUNCT .))) Caveat: cyclic application of rules

  11. Position for ‘insert’ and ‘move’ insert <name> <position> insert <tree> <position> <position> := <relation> <name> <relation> $+ the left sister of the named node $- the right sister of the named node >i the i_th daughter of the named node >-i the i_th daughter, counting from the right, of the named node.

  12. Move (ROOT (SQ (NP (NNS Cats)) (VP (VBP do) (VP (WHNPwhat) (VBeat))) (PUNCT .))) VP < (/^WH/=wh $++ /^VB/=vb) move vb $+ wh <position> move <name> <position> moves the named node into the specifiedposition

  13. Move (ROOT (SQ (NP (NNS Cats)) (VP (VBP do) (VP (WHNPwhat) (VBeat))) (PUNCT .))) VP < (/^WH/=wh $++ /^VB/=vb) move vb $+ wh <position> (ROOT (SQ (NP (NNS Cats)) (VP (VBP do) (VP (VBeat) (WHNPwhat))) (PUNCT .)))

  14. Adjoin (ROOT (SQ (NP (NNS Cats)) (VP (ADVP (RB usually)) (VP (VBP do) (VP (VB eat) (WHNP what))) (PUNCT .))) (ROOT (SQ (NP (NNS Cats)) (VP (VBP do) (VP (VB eat) (WHNP what))) (PUNCT .))) VP=vp > SQ !> (__ << usually) adjoin (VP (ADVP (ADV usually)) VP@)vp

  15. Adjoin syntax adjoin <auxiliary_tree> <name> Adjoins the specified auxiliary tree into the named node. The daughters of the target node will become the daughters of the foot of the auxiliary tree. adjoin (VP (ADVP (ADV usually)) VP@) vp foot

  16. On the command line java Tsurgeon -treeFile <aFile> [<operationFile>]* aFile -> a file containing the trees to be transformed operationFile -> pattern (Tregex expression) an empty line operation(s) (one by line)

  17. How to use the Tsurgeon class TregexPattern matchPattern = TregexPattern.compile("SQ=sq < (/^WH/ $++ VP)"); List<TsurgeonPattern> ps = new ArrayList<TsurgeonPattern>(); TsurgeonPattern p = Tsurgeon.parseOperation("relabel sq S"); ps.add(p); Collection<Tree> result = Tsurgeon.processPatternOnTrees(matchPattern,Tsurgeon.collectOperations(ps),lTrees);

  18. To become a specialist • See Roger’s README! • Practice tree surgery!

More Related