地址解析识别python版本
项目基于JioNLP 地址解析来进行地址识别
地址库:2020年国家统计局行政区划
基于结巴分词 提供的分词以及语义化分析进行姓名识别
基于Levenshtein 字符串相似度算法来进行详细地址过滤
依赖下载
python支持版本:>=3.8
pip3 install addressrec
使用
直接运行
import addressrec
print(addressrec.run('王志超029-68216000新疆维吾尔自治区乌鲁木齐市沙依巴克区西虹东路463号', True, False))
# addressrec(text, town_village, town_village)
# "text":"王志超029-68216000新疆维吾尔自治区乌鲁木齐市沙依巴克区西虹东路463号",
# "town_village": True, //可不传默认True 指定参数town_village(bool),可获取乡镇、村、社区两级详细地名
# "change2new": False //可不传默认True 指定参数change2new(bool)可自动将旧地址转换为新地址
返回结果:
{
"city": "乌鲁木齐市",
"county": "沙依巴克区",
"detail": "西虹东路463号",
"name": "王志超",
"phone": "029-68216000",
"province": "新疆维吾尔自治区",
"town": "",
"village": ""
}
封装为接口调用:
# pip3 install flask
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/smart_address', methods=['POST'])
def handle_smart_address():
data = request.get_json()
text = data.get('text', '')
town_village = data.get('town_village', True)
change2new = data.get('change2new', False)
result = smart_address(text, town_village, change2new)
if result:
return jsonify(result)
else:
return jsonify({"error": "Failed to process the request"}), 500
if __name__ == '__main__':
app.run(host='0.0.0.0', port=3000)
#URL: `http://127.0.0.1:3000/smart_address`
#METHOD: 'POST'
#BODY:
#{
# "text":"王志超029-68216000新疆维吾尔自治区乌鲁木齐市沙依巴克区西虹东路463号",
# "town_village": true, //可不传默认true 指定参数town_village(bool),可获取乡镇、村、社区两级详细地名
# "change2new": false //可不传默认false 指定参数change2new(bool)可自动将旧地址转换为新地址
#}
识别结果测试
广东省珠海市香洲区盘山路28号幸福茶庄,陈景勇,13593464918 识别结果:
{'city': '珠海市',
'county': '香洲区',
'detail': '盘山路28号幸福茶庄,,',
'name': '陈景勇',
'phone': '13593464918',
'province': '广东省',
'town': '',
'village': ''}
-----------------
马云,陕西省西安市雁塔区丈八沟街道高新四路高新大都荟 13593464918 识别结果:
{'city': '西安市',
'county': '雁塔区',
'detail': '高新四路高新大都荟',
'name': '马云',
'phone': ' 13593464918',
'province': '陕西省',
'town': '丈八沟街道',
'village': ''}
-----------------
陕西省西安市雁塔区丈八沟街道高新四路高新大都荟710061 刘国良 13593464918 识别结果:
{'city': '西安市',
'county': '雁塔区',
'detail': '高新四路高新大都荟710061',
'name': '刘国良',
'phone': ' 13593464918',
'province': '陕西省',
'town': '丈八沟街道',
'village': ''}
-----------------
西安市雁塔区丈八沟街道高新四路高新大都荟710061 刘国良 13593464918 识别结果:
{'city': '西安市',
'county': '雁塔区',
'detail': '高新四路高新大都荟710061',
'name': '刘国良',
'phone': ' 13593464918',
'province': '陕西省',
'town': '丈八沟街道',
'village': ''}
-----------------
雁塔区丈八沟街道高新四路高新大都荟710061 刘国良 13593464918 识别结果:
{'city': '西安市',
'county': '雁塔区',
'detail': '高新四路高新大都荟710061',
'name': '刘国良',
'phone': ' 13593464918',
'province': '陕西省',
'town': '丈八沟街道',
'village': ''}
-----------------
收货人: 李节霁手机号码: 15180231234所在地区: 浙江省金华市婺城区西关街道详细地址: 金磐路上坞街 识别结果:
{'city': '金华市',
'county': '婺城区',
'detail': '详细地址: 金磐路上坞街',
'name': '李节',
'phone': ' 15180231234',
'province': '浙江省',
'town': '西关街道',
'village': ''}
-----------------
收货人: 马云手机号码: 150-3569-6956详细地址: 河北省石家庄市新华区中华北大街68号鹿城商务中心6号楼1413室 识别结果:
{'city': '石家庄市',
'county': '新华区',
'detail': '中华北大街68号鹿城商务中心6号楼1413室',
'name': '马云',
'phone': ' 150-3569-6956',
'phone1': '150-3569-6956',
'province': '河北省',
'town': '',
'village': ''}
-----------------
LICENSE:Apache License
IDE:致谢JetBrains为本项目提供免费license支持
联系我,欢迎交流
qq交流群
Metadata
Release files for addressrec 0.0.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| addressrec-0.0.14.tar.gz | 8.8 kB | Without provenance | Details for addressrec-0.0.14.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| addressrec-0.0.14-py3-none-any.whl | Python 3 | none | any | Details for addressrec-0.0.14-py3-none-any.whl |
Total release size: 18.0 kB
Release files / addressrec-0.0.14.tar.gz
| Download URL | addressrec-0.0.14.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
51f44b6c72884f29ef50e002fe82187c5b2d89e37295f463603316c3a94140d8
|
|
BLAKE2b-256 checksum How to use checksums |
20ed494c654e8e6b0d8a8618402cff1fdd80f170f0376cd9623ada0c78c858ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.6
|
Release files / addressrec-0.0.14-py3-none-any.whl
| Download URL | addressrec-0.0.14-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
58aec4ae06bc82c98f4cabef51aa921092ccd9e10aebb0e065c46d9789f88a85
|
|
BLAKE2b-256 checksum How to use checksums |
7d772a55961b4051e29410db707c87610d98b64caf74f67e21ce2b89e59ccaa4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.6
|
Security for addressrec 0.0.14
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.