snowblink14 / smatch

Smatch tool: evaluation of AMR semantic structures
MIT License
63 stars 27 forks source link

do not compute swap gain if both new mappings are not in candidates (… #40

Closed tahira closed 2 years ago

tahira commented 2 years ago

I only added two lines (539 and 540) that give 3x speed gain.

When looking for a swap during hill climbing. We can avoid computing the swap gain if none of the swapped mappings is in the candidate mappings. This will not hurt the search since such a mapping can never contribute to a gain in the score. Also, all optimal mapping will still be reachable even if this swap's gain is not computed/considered.

Doing this change makes the algorithm up to 3x faster for me on AMR2.0 dev.

This change has never affected the smatch score in my test runs. Also, I can not see a way how it can possibly affect the smatch one way or the other.

snowblink14 commented 2 years ago

Thanks! Looks good, but do you mind adding the comments above your code, so people reading the code can find the rationale easier?

tahira commented 2 years ago

Thanks for the review, I added the comment.