goodmami / penman

PENMAN notation (e.g. AMR) in Python
https://penman.readthedocs.io/
MIT License
135 stars 26 forks source link

rearrange bug #101

Closed Wangpeiyi9979 closed 3 years ago

Wangpeiyi9979 commented 3 years ago

Hi, thanks for your nice work. When I rearrange the amr as follow: image I find the referenced variable p appears before (p / person :mod (e2 / each)). Would you help me solve this problem. Thanks!

goodmami commented 3 years ago

The --rearrange option is a tree operation and it only swaps branch positions. If you want to reattach branches at different locations, try --reconfigure:

~/git/penman$ original='(b / believe-01
>   :ARG1 (c8 / capable-01
>     :ARG2 (i / innovate-01
>       :ARG0 (p / person
>         :mod (e2 / each)))
>     :ARG1 p)
>   :ARG0 (p2 / person))'
~/git/penman$ echo "$original" | penman --reconfigure=canonical
(b / believe-01
   :ARG0 (p2 / person)
   :ARG1 (c8 / capable-01
             :ARG1 (p / person
                      :mod (e2 / each)
                      :ARG0-of i)
             :ARG2 (i / innovate-01)))

Sometimes you can get different results if you chain both operations:

~/git/penman$ echo "$original" | penman --rearrange=attributes-first,alphanumeric | penman --reconfigure=original
(b / believe-01
   :ARG0 (p2 / person)
   :ARG1 (c8 / capable-01
             :ARG1 (p / person
                      :mod (e2 / each))
             :ARG2 (i / innovate-01
                      :ARG0 p)))
Wangpeiyi9979 commented 3 years ago

Thanks!!