From 83c5b717feb438842d5784ef64e996c0c8cce861 Mon Sep 17 00:00:00 2001 From: "David R. Mortensen" Date: Thu, 7 Jul 2022 16:59:53 +0200 Subject: [PATCH] Fixed off-by-one error regarding non-determinism --- epitran/simple.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/epitran/simple.py b/epitran/simple.py index 170ebf84..e123d615 100644 --- a/epitran/simple.py +++ b/epitran/simple.py @@ -79,7 +79,7 @@ def __exit__(self, _type_, _val, _trace_back): # return ("", []) def _non_deterministic_mappings(self, gr_by_line: "dict[str, list[int]]") -> "list[tuple[str, list[int]]]": - return [(g, ls) for (g, ls) in gr_by_line.items() if len(ls) > 0] + return [(g, ls) for (g, ls) in gr_by_line.items() if len(ls) > 1] def _load_g2p_map(self, code: str, rev: bool) -> "DefaultDict[str, list[str]]": """Load the code table for the specified language. @@ -119,7 +119,7 @@ def _load_g2p_map(self, code: str, rev: bool) -> "DefaultDict[str, list[str]]": lines = [l + 2 for l in lines] delim = ', ' message += '\n' + f'One-to-many G2P mapping for "{graph}" on lines {delim.join(map(str, lines))}' - raise MappingError(message) + raise MappingError(f'Invalid mapping for {code}:\n{message}') return g2p def _load_punc_norm_map(self):