当前位置:网站首页>一行代码实现地址信息解析
一行代码实现地址信息解析
2022-07-06 17:04:00 【朱卫军】
*本文完整示例代码及文件已上传至我的Github仓库https://github.com/CNFeffery/PythonPracticalSkills*
这是我的系列文章「「Python实用秘技」」的第8期,本系列立足于笔者日常工作中使用Python积累的心得体会,每一期为大家带来一个几分钟内就可学会的简单小技巧。
作为系列第8期,我们即将学习的是:一行代码解析地址信息。
在日常数据处理的过程中,有时候拿到手的是完整的地址信息,如果需要从地址信息中解析出相应的各级行政单元名称,方式有很多,而今天要介绍的方式只需要一行代码即可快速实现。
首先我们需要安装jionlp这个非常好用的文本预处理工具包,建议使用国内镜像安装:
pip install jionlp -i https://pypi.douban.com/simple/
安装完成后,只需要使用其parse_location()接口即可进行地址信息的解析,且具有多种不同的功能:
- 基础的省市区信息提取
- 街镇乡、村或居委会信息提取
通过设置参数town_village=True,还可以额外尝试提取出街镇乡、村或居委会信息等级别的信息字段:
- 自动补全省市信息
若地址信息中缺失省市信息也无妨,在不存在歧义的情况下,parse_location()会自动关联并补全相关信息:
除此之外,parse_location()还具有旧地名修正为新地名、自定义行政区划词典等功能,你可以在其官方文档https://github.com/dongrixinyu/JioNLP/wiki/Gadget-说明文档#地址解析中了解更多。
本期分享结束,咱们下回见~
边栏推荐
- Advanced learning of MySQL -- basics -- basic operation of transactions
- uniapp实现从本地上传头像并显示,同时将头像转化为base64格式存储在mysql数据库中
- MySQL learning notes (mind map)
- Basic information of mujoco
- 深度学习之环境配置 jupyter notebook
- fastDFS数据迁移操作记录
- [yolov5 6.0 | 6.1 deploy tensorrt to torch serve] environment construction | model transformation | engine model deployment (detailed packet file writing method)
- [software reverse automation] complete collection of reverse tools
- Win10 startup error, press F9 to enter how to repair?
- String comparison in batch file - string comparison in batch file
猜你喜欢

2022/2/12 summary

Threejs image deformation enlarge full screen animation JS special effect

5种不同的代码相似性检测,以及代码相似性检测的发展趋势

St table

Clipboard management tool paste Chinese version

AI超清修复出黄家驹眼里的光、LeCun大佬《深度学习》课程生还报告、绝美画作只需一行代码、AI最新论文 | ShowMeAI资讯日报 #07.06

用tkinter做一个简单图形界面
![【批处理DOS-CMD命令-汇总和小结】-跳转、循环、条件命令(goto、errorlevel、if、for[读取、切分、提取字符串]、)cmd命令错误汇总,cmd错误](/img/a5/41d4cbc070d421093323dc189a05cf.png)
【批处理DOS-CMD命令-汇总和小结】-跳转、循环、条件命令(goto、errorlevel、if、for[读取、切分、提取字符串]、)cmd命令错误汇总,cmd错误

Data analysis course notes (V) common statistical methods, data and spelling, index and composite index

一图看懂对程序员的误解:西方程序员眼中的中国程序员
随机推荐
Leecode brushes questions to record interview questions 17.16 massagist
基于SSM框架的文章管理系统
@TableId can‘t more than one in Class: “com.example.CloseContactSearcher.entity.Activity“.
什么是时间
Personal digestion of DDD
AI超清修复出黄家驹眼里的光、LeCun大佬《深度学习》课程生还报告、绝美画作只需一行代码、AI最新论文 | ShowMeAI资讯日报 #07.06
Encryption algorithm - password security
build. How to configure the dependent version number in the gradle file
Rails 4 asset pipeline vendor asset images are not precompiled
接口(接口相关含义,区别抽象类,接口回调)
37 page overall planning and construction plan for digital Village revitalization of smart agriculture
mongodb客户端操作(MongoRepository)
【JokerのZYNQ7020】AXI_ EMC。
Basic information of mujoco
Leecode brush questions record sword finger offer 43 The number of occurrences of 1 in integers 1 to n
JWT signature does not match locally computed signature. JWT validity cannot be asserted and should
Sword finger offer 26 Substructure of tree
Threejs image deformation enlarge full screen animation JS special effect
Advanced learning of MySQL -- basics -- multi table query -- inner join
Amazon MemoryDB for Redis 和 Amazon ElastiCache for Redis 的内存优化