From c38aab2f5f1ad1c5c8b174c0d528da4b73f39b84 Mon Sep 17 00:00:00 2001 From: bjascob Date: Mon, 4 Jan 2021 07:29:40 -0700 Subject: [PATCH] Add remove surface alignments to rbw aligner --- amrlib/alignments/rbw_aligner/rbw_aligner.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/amrlib/alignments/rbw_aligner/rbw_aligner.py b/amrlib/alignments/rbw_aligner/rbw_aligner.py index c27ee4a..ab5f653 100644 --- a/amrlib/alignments/rbw_aligner/rbw_aligner.py +++ b/amrlib/alignments/rbw_aligner/rbw_aligner.py @@ -4,6 +4,7 @@ from types import SimpleNamespace import penman from penman.models.noop import NoOpModel +from penman.surface import AlignmentMarker from .match_candidates import get_match_candidates @@ -54,6 +55,12 @@ def get_penman_graph(self): def get_graph_string(self): return penman.encode(self.graph, model=NoOpModel(), indent=6) + # Remove the surface alignments from the penman graph + def remove_surface_alignments(self): + for key, values in self.graph.epidata.items(): + self.graph.epidata[key] = [x for x in values if not isinstance(x, AlignmentMarker)] + + ########################################################################### #### Rule Base Word Alignments added to Graph as Surface Aligments ###########################################################################