From e3cd9f3abcfa8d5a2da60290def964e549d68ed4 Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Fri, 15 Feb 2019 22:14:18 +0530 Subject: [PATCH] Fixing 'incorporate 50billion rmt#' error --- parse_flodata.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/parse_flodata.py b/parse_flodata.py index 5d9b1dc..10f83cd 100644 --- a/parse_flodata.py +++ b/parse_flodata.py @@ -66,11 +66,15 @@ def extractInitTokens(text): base_units = {'thousand':10**3 , 'million':10**6 ,'billion':10**9, 'trillion':10**12} textList = text.split(' ') for idx,word in enumerate(textList): + for unit in base_units: + temp = word.split(unit) + if len(temp)==2 and temp[1]=='': + return float(temp[0])*base_units[unit] try: result = float(word) if textList[idx+1] in base_units: return result*base_units[textList[idx+1]] - return res + return result except: continue