Code Monkey home page Code Monkey logo

id-validator.py's Issues

出现bug

出生年份有字母、15-17位有字母时报错

获取地理位置没有判断有效结束时间

def get_address(address_code, birthday_code):
"""
通过地址码与出生日期码获取地址信息
:param address_code:
:param birthday_code:
:return:
"""
address = ''
address_code_timeline = data.get_address_code_timeline()
timeline = address_code_timeline.get(address_code, '')
if timeline != '':
year = int(birthday_code[0:4])
for key, val in enumerate(timeline):
start_year = 0 if val['start_year'] == '' else int(val['start_year'])
if (key == 0 and year < start_year) or year >= start_year:
address = val['address']

return address

只判断了start_year是否有效,没有判断end_year,导致有的地理位置错误

校验错误python版本

当我使用这个库当做我的身份证号码校验的方法,客户使用反馈使用本人真实的身份证号码,返回结果却是不合法,我使用一些在线校验的工具得到的答案都是合法的身份证号码,使用validator模块的is_valid()方法返回值却是False,另外,我使用的是严格模式,图片的身份证号码确定一致
Snipaste_2024-03-29_18-02-32
Snipaste_2024-03-29_18-03-59

提取信息速度有点慢,建议优化一下

在我机器上单次get_info需要10ms,处理大批量数据时有点影响速度,建议优化一下,主要是每次加载data.py耗时很长,把那几个dict复用一下速度就会快很多

正则表达式问题

pattern = r'^\d{4}[^0]{2}$'

按我想的是,只需排除末尾是00的地址码即可,但这个正则筛选出来的其实是末尾两位数字中不存在0的情况,下面是示例:

>>> reg = r'^\d{4}[^0]{2}$'
>>> pattern = re.compile(reg)
>>> print(re.match(pattern, '610112'))
<re.Match object; span=(0, 6), match='610112'>
>>> print(re.match(pattern, '610102'))
None
>>> print(re.match(pattern, '610120'))
None

因为对这个地址码的规则不太了解,不知道是规则如此还是代码考虑不全的问题?

關於區劃代碼的問題

實際使用過程中發現部分區劃代碼為 xxxx01 的身份證號被判定為無效號碼,查詢民政部的數據後發現廣東省代碼中均無 xxxx01(圖1),但對比查詢其他政府網站數據(註1-2)(圖2)後發現 xxxx01 應為市轄區的代碼,所以 id-validator 中引用的數據會導致將有效證件號誤判為無效的情況。

註1: http://www.gov.cn/test/2009-03/30/content_1272354.htm
註2: http://gdii.gd.gov.cn/ywfl/jsgz/content/post_939420.html

image
image

建立增加省份信息

因为地址码里已经有省份信息了,建议增加省份字段,不然从address里面提取省份也不方便

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.