From cfac78a268f19c75bbe87023f79ac5fbbdcf64fe Mon Sep 17 00:00:00 2001 From: liuyebo <1515783401@qq.com> Date: Thu, 25 Jul 2024 13:26:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=A7=93=E5=90=8D=E6=AD=A3?= =?UTF-8?q?=E5=88=99=E5=8C=B9=E9=85=8D=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- photo_mask/__init__.py | 7 +++++-- photo_mask/photo_mask.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/photo_mask/__init__.py b/photo_mask/__init__.py index 8dbaf53..bbd123c 100644 --- a/photo_mask/__init__.py +++ b/photo_mask/__init__.py @@ -18,10 +18,13 @@ NAME_KEYS = [ {"key": "^名[:|:]$", "length": 3}, # 可能误涂 {"key": "[姓|娃]名", "length": 4}, {"key": "款人", "length": 4}, - {"key": "交.人", "length": 4}, + {"key": "交[^病]人", "length": 4}, {"key": "购买方名称", "length": 4}, ] -ID_CARD_NUM_KEYS = [{"key": "身份证号", "length": 19}, ] +ID_CARD_NUM_KEYS = [ + {"key": "身份证", "length": 20}, + {"key": "份证号", "length": 19}, +] # 形近字,只对姓名涂抹生效 SIMILAR_CHAR = { diff --git a/photo_mask/photo_mask.py b/photo_mask/photo_mask.py index 8a43e6c..40e456f 100644 --- a/photo_mask/photo_mask.py +++ b/photo_mask/photo_mask.py @@ -124,7 +124,7 @@ def get_mask_layout(image, name, id_card_num): if find_name_by_key and len(name) > 2: name_len = len(name) name_offset = int(name_len / 2) - r = f"{name[:-1]}.|.{name[1:]}" + ( + r = f"{name[:-1]}.?|.?{name[1:]}" + ( f"|{name[:name_offset]}.{name[-name_offset:]}" if (name_len & 1) == 1 else "") matches = re.findall(r, layout[1]) for match in matches: