From 10806f2ba55e132d9049c8082578675b215c8dc5 Mon Sep 17 00:00:00 2001 From: Marcel Bollmann Date: Sun, 25 Sep 2022 12:56:10 +0200 Subject: [PATCH] Handle weird error --- sonnet_finder.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sonnet_finder.py b/sonnet_finder.py index 4a0145f..0e32cd4 100644 --- a/sonnet_finder.py +++ b/sonnet_finder.py @@ -483,7 +483,14 @@ def main(args): # pronunciation prediction on these words sentence = sentence.replace("-", " - ") - pron = g2p(sentence) + try: + pron = g2p(sentence) + except Exception: + # Something weird is going on here, e.g. + # inflect.NumOutOfRangeError when input contains a long string + # of digits + continue + candidates.extend(phrase for phrase in extract_phrases(sentence, pron)) log.info(f"Extracted {len(candidates)} candidate phrases.")