zeke-chin пре 2 година
родитељ
комит
9bfea7f25f
1 измењених фајлова са 23 додато и 9 уклоњено
  1. 23 9
      core/parser.py

+ 23 - 9
core/parser.py

@@ -111,15 +111,29 @@ class FrontParser(Parser):
         raise Exception('无法识别')
 
     def national(self):
-        # 性别女民族汉
-        if len(self.result[1]) == 1:
-            txt = self.result[1][0].txt
-            conf = self.result[1][0].conf
-            res = re.findall(".*民族[\u4e00-\u9fa5]+", txt)
-
-            if len(res) > 0:
-                self.res["ethnicity"] = RecItem(res[0].split("族")[-1], conf)
-                return
+        """
+        性别 <-- id
+        民族汉
+        """
+
+        for nation in self.result[1]:
+            if nation is not None:
+                txt = nation.txt
+                conf = nation.conf
+                res = re.findall(".*民族[\u4e00-\u9fa5]+", txt)
+
+                if len(res) > 0:
+                    self.res["ethnicity"] = RecItem(res[0].split("族")[-1], conf)
+                    return
+
+        # if len(self.result[1]) == 1:
+        #     txt = self.result[1][0].txt
+        #     conf = self.result[1][0].conf
+        #     res = re.findall(".*民族[\u4e00-\u9fa5]+", txt)
+        #
+        #     if len(res) > 0:
+        #         self.res["ethnicity"] = RecItem(res[0].split("族")[-1], conf)
+        #         return
 
     def address(self):
         """