nschneid/amr-hackathon

__str__ issue

Closed this issue · 3 comments

Given the sentence

(l / look-01
      :ARG0 (h / he)
      :ARG1 (i / i
            :ARG0-of (b2 / bend-01
                  :destination (d / down)
                  :location (o / object
                        :mod (u / ugly
                              :mod (s / seem-01
                                    :ARG2 h)
                              :degree (e2 / extreme))))
            :ARG0-of (h4 / have-03
                  :ARG1 (h2 / hammer
                        :poss i)
                  :location (h3 / hand
                        :part-of i))
            :ARG0-of (h5 / have-03
                  :ARG1 (f / finger
                        :part-of i
                        :ARG1-of (b / black-04
                              :ARG0 (g / grease
                                    :mod (e / engine))))))
      :location (t / there))

If I construct an AMR instance by passing the string above and then call the __str__ method, I get something different:

(l / look-01
    :ARG0 (h / he)
    :ARG1 (i / i
        :ARG0-of (b2 / bend-01
            :destination (d / down)
            :location (o / object
                :mod (u / ugly
                    :mod (s / seem-01
                        :ARG2 h)
                    :degree (e2 / extreme))))
        :ARG0-of (h4 / have-03
            :ARG1 (h2 / hammer
                :poss i)
            :location (h3 / hand
                :part-of (i
                    :ARG0-of (h5 / have-03
                        :ARG1 (f / finger
                            :part-of i
                            :ARG1-of (b / black-04
                                :ARG0 (g / grease
                                    :mod (e / engine)))))))))
    :location (t / there))

It looks like the difference is that ":ARG0-of (h5 / have-03..." is attached to the wrong occurrence of "i".

Marco

This is an interesting edge case where, when the triple (i, :ARG0-of, h5) is reached, there are two copies of i on the stack and the one nearer the top of the stack is deeper (in the AMR) than the one it was under in the original annotation.

The only legal place to attach it is under the one which has the concept. The fragment

                :part-of (i
                    :ARG0-of (h5 / have-03

is illegal because an open parenthesis and variable must always be followed by a slash and the concept.

So, when we reach the triple (i, :ARG-of, h5), we want to pop the AMR-string-generating stack until the occurrence of i with the concept attached is reached. I think this involves adding an additional test to

while stack and h!=stack[-1]:
.

@mdtux89, is it fixed now?

Yes, fixed. Thanks!