From 153ca5a13c6cf5ef4421dd9b454d1f1205c10510 Mon Sep 17 00:00:00 2001 From: Erdi Tac Date: Thu, 21 Apr 2022 09:50:44 +0800 Subject: [PATCH] Update expand.py Error when text has values like "$12,000". Fix by removing the comma --- g2p_en/expand.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/g2p_en/expand.py b/g2p_en/expand.py index d6a9592..89c4bec 100644 --- a/g2p_en/expand.py +++ b/g2p_en/expand.py @@ -34,7 +34,7 @@ def _expand_dollars(m): parts = match.split('.') if len(parts) > 2: return match + ' dollars' # Unexpected format - dollars = int(parts[0]) if parts[0] else 0 + dollars = int(re.sub(',', '', parts[0])) if parts[0] else 0 cents = int(parts[1]) if len(parts) > 1 and parts[1] else 0 if dollars and cents: dollar_unit = 'dollar' if dollars == 1 else 'dollars'