Prechádzať zdrojové kódy

fix name and address

zeke-chin 2 rokov pred
rodič
commit
8c32daeee7
1 zmenil súbory, kde vykonal 13 pridanie a 6 odobranie
  1. 13 6
      core/parser.py

+ 13 - 6
core/parser.py

@@ -61,7 +61,6 @@ class FrontParser(Parser):
                 del date[date.index("日") - 2]
             self.res["Birth"].text = "".join(date)
 
-
     def card_no(self):
         """
         身份证号码
@@ -92,7 +91,7 @@ class FrontParser(Parser):
             length = len(txt)
             print(length)
             if "姓名" in txt:
-                if len(txt) < 6:
+                if len(txt) < 7:
                     res = re.findall("姓名[\u4e00-\u9fa5]{1,4}", txt)
                     # 三个字名字
                     if len(res) > 0:
@@ -169,10 +168,12 @@ class FrontParser(Parser):
                     or "区" in txt
                     or "城" in txt
                     or "组" in txt
+                    or "旗" in txt
                     or "号" in txt
             ):
-
-                if "住址" in txt or "省" in txt or "址" in txt:
+                # if "住址" in txt or "省" in txt or "址" in txt:
+                if "住址" in txt or "省" in txt or "址" in txt or \
+                        ('市' in txt and len(addString) > 0 and '市' not in addString[0]):
                     addString.insert(0, txt.split("址")[-1])
                 else:
                     addString.append(txt)
@@ -196,8 +197,14 @@ class FrontParser(Parser):
             # print(f'pronvince: {province}, city: {city}, region: {region}, detail: {detail}')
             self.res["address_province"] = RecItem(province, conf)
             self.res["address_city"] = RecItem(city, conf)
-            self.res["address_region"] = RecItem(region, conf)
-            self.res["address_detail"] = RecItem(detail, conf)
+            if "旗" in detail:
+                temp_region = []
+                temp_region.insert(0, detail.split("旗")[0] + "旗")
+                self.res["address_region"] = RecItem(temp_region[0], conf)
+                self.res["address_detail"] = RecItem(detail.split("旗")[-1], conf)
+            else:
+                self.res["address_region"] = RecItem(region, conf)
+                self.res["address_detail"] = RecItem(detail, conf)
 
     def expire_date(self):
         for txt, conf in zip(self.result, self.confs):