Skip to content

Commit

Permalink
Fixed off-by-one error regarding non-determinism
Browse files Browse the repository at this point in the history
  • Loading branch information
dmort27 committed Jul 7, 2022
1 parent 7e42044 commit 83c5b71
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions epitran/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 83c5b71

Please sign in to comment.