Explorar o código

费率错误修复

znj %!s(int64=2) %!d(string=hai) anos
pai
achega
1ed4d65a86
Modificáronse 1 ficheiros con 13 adicións e 3 borrados
  1. 13 3
      BiddingKG/dl/ratio/re_ratio.py

+ 13 - 3
BiddingKG/dl/ratio/re_ratio.py

@@ -30,8 +30,8 @@ def re_standard_ratio(_str):
             left = _str[max(0,m_span[0]-15):m_span[0]]
             right = _str[m_span[1]:m_span[1]+10]
             context = left + keyword + right
-            print(1,keyword)
-            if not re.search("利率",context) and not re.search("^[万元]",right):
+            # print(1,keyword)
+            if not re.search("利率|保险",context) and not re.search("^[万元]",right):
                 ratio_list.append([keyword, keyword_index])
 
     return ratio_list
@@ -74,8 +74,18 @@ def extract_ratio(text):
                 # if not re.search("[%‰]",word):
                 #     continue
                 match_text = num_value
-                num_value = float(re.sub('[((]|[%‰]','',num_value))
+                num_value = round(Decimal(re.sub('[((]|[%‰]','',num_value)),10)
+                # print(num_value)
+                # _num = str(num_value).split('.')[0]
+                if len(str(num_value).split('.'))<2:
+                    continue
                 _decimal = str(num_value).split('.')[1]
+                _decimal = re.sub("0+$","",_decimal)
+                # print(_decimal)
+                if _decimal=="":
+                    _decimal = "0"
+                # num_value = float(_num+"."+_decimal)
+                # print(num_value)
                 if _decimal == '0':
                     round_len = 0
                 else: