How to use the asrtoolkit.alignment.align_utils.is_sorted function in asrtoolkit

To help you get started, we’ve selected a few asrtoolkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github finos / greenkey-asrtoolkit / asrtoolkit / alignment / aligned_doc.py View on Github external
"""

        x = list(merge_sorted(self.matched_dict[0], self.matched_dict[1]))
        y = list(merge_sorted(x, self.matched_dict[2]))
        z = list(merge_sorted(y, self.matched_dict[3]))

        matched_spans = z

        token_matches = []
        for hyp_match, ref_match in matched_spans:
            assert hyp_match.text == ref_match.text
            m1_tokens = self.get_token_idxs(hyp_match)
            m2_tokens = self.get_token_idxs(ref_match)
            for hyp_tok, ref_tok in zip(m1_tokens, m2_tokens):
                matched = (hyp_tok, ref_tok)
                if matched not in token_matches and is_sorted(token_matches +
                                                              [matched]):
                    token_matches.append(matched)
        return token_matches