Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-referenced Node Formatting #119

Open
Zoher15 opened this issue Sep 6, 2023 · 5 comments
Open

Re-referenced Node Formatting #119

Zoher15 opened this issue Sep 6, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@Zoher15
Copy link

Zoher15 commented Sep 6, 2023

Hi @goodmami ,

I see this weird formatting quirk where a re-referenced node is written to file within parantheses sometimes:
image

This is creating issues with tools that use their own parsers like smatch and sembleu. Is there a way to avoid this?

Best,
Zoher

@Zoher15
Copy link
Author

Zoher15 commented Sep 8, 2023

This happens when 'graph.triples' are shuffled in place.....

@goodmami goodmami added the bug Something isn't working label Sep 8, 2023
@goodmami
Copy link
Owner

goodmami commented Sep 8, 2023

@Zoher15 thanks for the report. This is clearly a bug.

I think this is because the epigraphical data from the original graph doesn't match the shuffled triples, and a Push marker is trying to create a new node context on the re-entrant variable (if you're not familiar with how Penman uses an epigraph to encode the serialized layout of a graph, the penman.layout module documentation gives a summary at the top).

We can create a MWE like this:

>>> import penman
>>> from penman.layout import Push
>>> g = penman.Graph(
...     [("a", ":instance", "A"), ("a", ":ARG0", "b")],
...     epidata={("a", ":ARG0", "b"): [Push("b")]}
... )
>>> print(penman.encode(g))
(a / A
   :ARG0 (b))

Penman is supposed to respect the epigraph data when they match the triples in the graph and to ignore them otherwise. In this case we should check in penman.layout.configure() that upon encountering a triple with the epigraphical marker Push(x), the next triple should be (x, ":instance", ...), and if not to ignore the Push.

@Zoher15
Copy link
Author

Zoher15 commented Sep 8, 2023

Thanks @goodmami! I obviously got around it by shuffling a copy of the triples instead.

PS: This is an amazing package! Thanks for your work!

@goodmami
Copy link
Owner

goodmami commented Sep 9, 2023

@Zoher15 I don't know how robust a solution shuffling a copy of the triples is. It might just be that a different shuffling didn't cause the issue to surface.

This is clearly a bug.

I spoke too soon. This is in fact a supported graph type in Penman. However I agree that it is generally unacceptable for AMR. So rather than changing the layout code, we might need something specific for the AMR model.

@flipz357
Copy link

@Zoher15 What you posted is not a bug in penman and I also see no reason why it shouldn't be a valid AMR (it's just redundancy). So this is an issue that you better submit to the smatch/sembleu repos. Note that the smatch/sembleu AMR reading can also be buggy in other ways, so what you should actually do is use an improved amr/graph reader like penman, or use smatch++ which also fixes some other issues in smatch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants