# addana
[![image](https://img.shields.io/pypi/v/addana.svg)](https://pypi.python.org/pypi/addana)
[![image](https://img.shields.io/conda/vn/conda-forge/addana.svg)](https://anaconda.org/conda-forge/addana)
**address**
- Free software: MIT license
- Documentation: https://advancehs.github.io/addana
中文地址提取工具,支持中国三级区划地址(省、市、区)提取和级联映射,支持地址目的地热力图绘制。适配python2和python3。
## Feature
#### 地址提取
["徐汇区虹漕路461号58号楼5楼", "福建泉州市洛江区万安塘西工业区"]
↓ 转换
|省 |市 |区 |地名 |
|上海市|上海市|徐汇区|虹漕路461号58号楼5楼 |
|福建省|泉州市|洛江区|万安塘西工业区 |
> 注:“地名”列代表去除了省市区之后的具体地名
#### 数据集:中国行政区划地名
数据源:爬取自[国家统计局](http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/),[中华人民共和国民政局全国行政区划查询平台](http://xzqh.mca.gov.cn/map)
数据文件存储在:[addressparser2/resources/pca.csv](./addressparser2/resources/pca.csv),数据为[2021年统计用区划代码和城乡划分代码(截止时间:2021-10-31,发布时间:2021-12-30)](http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2021/index.html)
## Demo
http://42.193.145.218/product/address_extraction/
## Install
```
pip install addressparser2
```
or
```
git clone https://github.com/advancehs/addressparser2.git
cd addressparser2
python3 setup.py install
```
## Usage
- 省市区提取
示例[base_demo.py](examples/base_demo.py)
```python
location_str = ["徐汇区虹漕路461号58号楼5楼", "泉州市洛江区万安塘西工业区", "朝阳区北苑华贸城"]
import addressparser2
df = addressparser2.transform(location_str)
print(df)
```
output:
```
省 市 区 地名
0 上海市 上海市 徐汇区 虹漕路461号58号楼5楼
1 福建省 泉州市 洛江区 万安塘西工业区
2 北京市 北京市 朝阳区 北苑华贸城
```
> 程序的此处输入`location_str`可以是任意的可迭代类型,如list,tuple,set,pandas的Series类型等;
> 输出的`df`是一个Pandas的DataFrame类型变量,DataFrame可以非常轻易地转化为csv或者excel文件,Pandas的官方文档:http://pandas.pydata.org/pandas-docs/version/0.20/dsintro.html#dataframe
- 带位置索引的省市县提取
示例[pos_sensitive_demo.py](examples/pos_sensitive_demo.py)
```python
location_str = ["徐汇区虹漕路461号58号楼5楼", "泉州市洛江区万安塘西工业区", "朝阳区北苑华贸城"]
import addressparser2
df = addressparser2.transform(location_str, pos_sensitive=True)
print(df)
```
output:
```
省 市 区 地名 省_pos 市_pos 区_pos
0 上海市 上海市 徐汇区 虹漕路461号58号楼5楼 -1 -1 0
1 福建省 泉州市 洛江区 万安塘西工业区 -1 0 3
2 北京市 北京市 朝阳区 北苑华贸城 -1 -1 0
```
- 切词模式的省市区提取
默认采用全文匹配模式,不进行分词,直接全文匹配,这样速度慢,准确率高。
示例[enable_cut_demo.py](examples/enable_cut_demo.py)
```python
location_str = ["浙江省杭州市下城区青云街40号3楼"]
import addressparser2
df = addressparser2.transform(location_str)
print(df)
```
output:
```
省 市 区 地名
0 浙江省 杭州市 下城区 青云街40号3楼
```
可以先通过jieba分词,之后做省市区提取及映射,所以我们引入了切词模式,速度很快,使用方法如下:
```python
location_str = ["徐汇区虹漕路461号58号楼5楼", "泉州市洛江区万安塘西工业区", "朝阳区北苑华贸城"]
import addressparser2
df = addressparser2.transform(location_str, cut=True)
print(df)
```
output:
```
省 市 区 地名
0 上海市 上海市 徐汇区 虹漕路461号58号楼5楼
1 福建省 泉州市 洛江区 万安塘西工业区
2 北京市 北京市 朝阳区 北苑华贸城
```
但可能会出错,如下所示,这种错误的结果是因为jieba本身就将词给分错了:
```python
location_str = ["浙江省杭州市下城区青云街40号3楼"]
import addressparser2
df = addressparser2.transform(location_str, cut=True)
print(df)
```
output:
```
省 市 区 地名
0 浙江省 杭州市 城区 下城区青云街40号3楼
```
> 默认情况下transform方法的cut参数为False,即采用全文匹配的方式,这种方式准确率高,但是速度可能会有慢一点;
> 如果追求速度而不追求准确率的话,建议将cut设为True,使用切词模式。
- 地址经纬度、省市县级联关系查询
示例[find_place_demo.py](examples/find_place_demo.py)
```python
## 查询经纬度信息
from addressparser2 import latlng
latlng[('北京市','北京市','朝阳区')] #输出('39.95895316640668', '116.52169489108084')
## 查询含有"鼓楼区"的全部地址
from addressparser2 import area_map
area_map.get_relational_addrs('鼓楼区') #[('江苏省', '南京市', '鼓楼区'), ('江苏省', '徐州市', '鼓楼区'), ('福建省', '福州市', '鼓楼区'), ('河南省', '开封市', '鼓楼区')]
#### 注: city_map可以用来查询含有某个市的全部地址, province_map可以用来查询含有某个省的全部地址
## 查询含有"江苏省", "鼓楼区"的全部地址
from addressparser2 import province_area_map
province_area_map.get_relational_addrs(('江苏省', '鼓楼区')) # [('江苏省', '南京市', '鼓楼区'), ('江苏省', '徐州市', '鼓楼区')]
```
- 绘制echarts热力图
使用echarts的热力图绘图函数之前需要先用如下命令安装它的依赖(为了减少本模块的体积,所以这些依赖不会被自动安装):
```
pip install pyecharts==0.5.11
pip install echarts-countries-pypkg
pip install pyecharts-snapshot
```
使用本仓库提供的一万多条地址数据[tests/addr.csv](./tests/addr.csv)测试。
示例[draw_demo.py](examples/draw_demo.py)
```python
#读取数据
import pandas as pd
origin = pd.read_csv("tests/addr.csv")
#转换
import addressparser2
addr_df = addressparser2.transform(origin["原始地址"])
#输出
processed = pd.concat([origin, addr_df], axis=1)
processed.to_csv("processed.csv", index=False, encoding="utf-8")
from addressparser2 import drawer
drawer.echarts_draw(processed, "echarts.html")
```
output:
```
1) processed.csv:1万多地址的省市县提取结果
2)echarts.html:echarts热力图
```
浏览器打开`echarts.html`后:
![echarts热力图](./docs/echarts.png)
- 绘制分类信息图
样本分类绘制函数,通过额外传入一个样本的分类信息,能够在地图上以不同的颜色画出属于不同分类的样本散点图,以下代码以“省”作为类别信息绘制分类散点图(可以看到,属于不同省的样本被以不同的颜色标记了出来,这里以“省”作为分类标准只是举个例子,实际应用中可以选取更加有实际意义的分类指标):
示例[draw_demo.py](examples/draw_demo.py),接上面示例代码:
```python
from addressparser2 import drawer
drawer.echarts_cate_draw(processed, processed["省"], "echarts_cate.html")
```
浏览器打开输出的`echarts_cate.html`后:
![echarts分类散点图](./docs/echarts_cate.png)
## Command line usage
- 命令行模式
支持批量提取地址的省市区信息:
示例[cmd_demo.py](examples/cmd_demo.py)
```
python3 -m addressparser2 address_input.csv -o out.csv
usage: python3 -m addressparser2 [-h] -o OUTPUT [-c] input
@description:
positional arguments:
input the input file path, file encode need utf-8.
optional arguments:
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT
the output file path.
-c, --cut use cut mode.
```
> 输入文件:`address_input.csv`;输出文件:`out.csv`,省市县地址以`\t`间隔,`-c`表示使用切词
## Todo
- [x] bug修复,吉林省、广西省部分地址和上海浦东新区等三级区划地址匹配错误
- [x] 增加定期从民政局官网,统计局官网爬取最新省市县镇村划分的功能,延后,原因是2018年后官网未更新
- [x] 解决路名被误识别为省市名的问题,eg"天津空港经济区环河北路80号空港商务园"
- [x] 添加省市区提取后的级联校验逻辑
- [x] 大批量地址数据,准召率效果评估
- [x] 补充香港、澳门、台湾三级区划地址信息
## License
授权协议为 [The Apache License 2.0](/LICENSE),可免费用做商业用途。请在产品说明中附加addressparser2的链接和授权协议。
## Contribute
项目代码还很粗糙,如果大家对代码有所改进,欢迎提交回本项目,在提交之前,注意以下两点:
- 在`tests`添加相应的单元测试
- 使用`python -m pytest`来运行所有单元测试,确保所有单测都是通过的
之后即可提交PR。
## Reference
* [chinese_province_city_area_mapper](https://github.com/DQinYuan/chinese_province_city_area_mapper)
* [addressparser](https://github.com/shibing624/addressparser)
Raw data
{
"_id": null,
"home_page": "https://github.com/advancehs/addana",
"name": "addana",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "addana",
"author": "advancehs",
"author_email": "1019753743@11.com",
"download_url": "https://files.pythonhosted.org/packages/1b/44/0d68b90a18414e84a4eee9ae71eca7f3ac2690ecd3d200e9210396f92912/addana-0.0.28.tar.gz",
"platform": null,
"description": "# addana\n\n\n[![image](https://img.shields.io/pypi/v/addana.svg)](https://pypi.python.org/pypi/addana)\n[![image](https://img.shields.io/conda/vn/conda-forge/addana.svg)](https://anaconda.org/conda-forge/addana)\n\n\n**address**\n\n\n- Free software: MIT license\n- Documentation: https://advancehs.github.io/addana\n \n\n\u4e2d\u6587\u5730\u5740\u63d0\u53d6\u5de5\u5177\uff0c\u652f\u6301\u4e2d\u56fd\u4e09\u7ea7\u533a\u5212\u5730\u5740\uff08\u7701\u3001\u5e02\u3001\u533a\uff09\u63d0\u53d6\u548c\u7ea7\u8054\u6620\u5c04\uff0c\u652f\u6301\u5730\u5740\u76ee\u7684\u5730\u70ed\u529b\u56fe\u7ed8\u5236\u3002\u9002\u914dpython2\u548cpython3\u3002\n\n\n## Feature\n#### \u5730\u5740\u63d0\u53d6\n\n\n [\"\u5f90\u6c47\u533a\u8679\u6f15\u8def461\u53f758\u53f7\u697c5\u697c\", \"\u798f\u5efa\u6cc9\u5dde\u5e02\u6d1b\u6c5f\u533a\u4e07\u5b89\u5858\u897f\u5de5\u4e1a\u533a\"]\n \u2193 \u8f6c\u6362\n |\u7701 |\u5e02 |\u533a |\u5730\u540d |\n |\u4e0a\u6d77\u5e02|\u4e0a\u6d77\u5e02|\u5f90\u6c47\u533a|\u8679\u6f15\u8def461\u53f758\u53f7\u697c5\u697c |\n |\u798f\u5efa\u7701|\u6cc9\u5dde\u5e02|\u6d1b\u6c5f\u533a|\u4e07\u5b89\u5858\u897f\u5de5\u4e1a\u533a |\n\n> \u6ce8\uff1a\u201c\u5730\u540d\u201d\u5217\u4ee3\u8868\u53bb\u9664\u4e86\u7701\u5e02\u533a\u4e4b\u540e\u7684\u5177\u4f53\u5730\u540d\n\n\n#### \u6570\u636e\u96c6\uff1a\u4e2d\u56fd\u884c\u653f\u533a\u5212\u5730\u540d\n\n\u6570\u636e\u6e90\uff1a\u722c\u53d6\u81ea[\u56fd\u5bb6\u7edf\u8ba1\u5c40](http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/)\uff0c[\u4e2d\u534e\u4eba\u6c11\u5171\u548c\u56fd\u6c11\u653f\u5c40\u5168\u56fd\u884c\u653f\u533a\u5212\u67e5\u8be2\u5e73\u53f0](http://xzqh.mca.gov.cn/map)\n\n\u6570\u636e\u6587\u4ef6\u5b58\u50a8\u5728\uff1a[addressparser2/resources/pca.csv](./addressparser2/resources/pca.csv)\uff0c\u6570\u636e\u4e3a[2021\u5e74\u7edf\u8ba1\u7528\u533a\u5212\u4ee3\u7801\u548c\u57ce\u4e61\u5212\u5206\u4ee3\u7801\uff08\u622a\u6b62\u65f6\u95f4\uff1a2021-10-31\uff0c\u53d1\u5e03\u65f6\u95f4\uff1a2021-12-30\uff09](http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2021/index.html)\n\n## Demo\nhttp://42.193.145.218/product/address_extraction/\n\n## Install\n```\npip install addressparser2\n```\n\nor\n\n```\ngit clone https://github.com/advancehs/addressparser2.git\ncd addressparser2\npython3 setup.py install\n```\n\n## Usage\n\n- \u7701\u5e02\u533a\u63d0\u53d6\n\n\u793a\u4f8b[base_demo.py](examples/base_demo.py)\n\n```python\n\nlocation_str = [\"\u5f90\u6c47\u533a\u8679\u6f15\u8def461\u53f758\u53f7\u697c5\u697c\", \"\u6cc9\u5dde\u5e02\u6d1b\u6c5f\u533a\u4e07\u5b89\u5858\u897f\u5de5\u4e1a\u533a\", \"\u671d\u9633\u533a\u5317\u82d1\u534e\u8d38\u57ce\"]\nimport addressparser2\ndf = addressparser2.transform(location_str)\nprint(df)\n```\n\noutput:\n```\n \u7701 \u5e02 \u533a \u5730\u540d\n 0 \u4e0a\u6d77\u5e02 \u4e0a\u6d77\u5e02 \u5f90\u6c47\u533a \u8679\u6f15\u8def461\u53f758\u53f7\u697c5\u697c\n 1 \u798f\u5efa\u7701 \u6cc9\u5dde\u5e02 \u6d1b\u6c5f\u533a \u4e07\u5b89\u5858\u897f\u5de5\u4e1a\u533a\n 2 \u5317\u4eac\u5e02 \u5317\u4eac\u5e02 \u671d\u9633\u533a \u5317\u82d1\u534e\u8d38\u57ce\n```\n> \u7a0b\u5e8f\u7684\u6b64\u5904\u8f93\u5165`location_str`\u53ef\u4ee5\u662f\u4efb\u610f\u7684\u53ef\u8fed\u4ee3\u7c7b\u578b\uff0c\u5982list\uff0ctuple\uff0cset\uff0cpandas\u7684Series\u7c7b\u578b\u7b49;\n\n> \u8f93\u51fa\u7684`df`\u662f\u4e00\u4e2aPandas\u7684DataFrame\u7c7b\u578b\u53d8\u91cf\uff0cDataFrame\u53ef\u4ee5\u975e\u5e38\u8f7b\u6613\u5730\u8f6c\u5316\u4e3acsv\u6216\u8005excel\u6587\u4ef6\uff0cPandas\u7684\u5b98\u65b9\u6587\u6863\uff1ahttp://pandas.pydata.org/pandas-docs/version/0.20/dsintro.html#dataframe\n\n\n- \u5e26\u4f4d\u7f6e\u7d22\u5f15\u7684\u7701\u5e02\u53bf\u63d0\u53d6\n\n\u793a\u4f8b[pos_sensitive_demo.py](examples/pos_sensitive_demo.py)\n\n```python\nlocation_str = [\"\u5f90\u6c47\u533a\u8679\u6f15\u8def461\u53f758\u53f7\u697c5\u697c\", \"\u6cc9\u5dde\u5e02\u6d1b\u6c5f\u533a\u4e07\u5b89\u5858\u897f\u5de5\u4e1a\u533a\", \"\u671d\u9633\u533a\u5317\u82d1\u534e\u8d38\u57ce\"]\nimport addressparser2\ndf = addressparser2.transform(location_str, pos_sensitive=True)\nprint(df)\n```\n\noutput:\n\n```\n \u7701 \u5e02 \u533a \u5730\u540d \u7701_pos \u5e02_pos \u533a_pos\n0 \u4e0a\u6d77\u5e02 \u4e0a\u6d77\u5e02 \u5f90\u6c47\u533a \u8679\u6f15\u8def461\u53f758\u53f7\u697c5\u697c -1 -1 0\n1 \u798f\u5efa\u7701 \u6cc9\u5dde\u5e02 \u6d1b\u6c5f\u533a \u4e07\u5b89\u5858\u897f\u5de5\u4e1a\u533a -1 0 3\n2 \u5317\u4eac\u5e02 \u5317\u4eac\u5e02 \u671d\u9633\u533a \u5317\u82d1\u534e\u8d38\u57ce -1 -1 0\n```\n\n\n- \u5207\u8bcd\u6a21\u5f0f\u7684\u7701\u5e02\u533a\u63d0\u53d6\n\n\u9ed8\u8ba4\u91c7\u7528\u5168\u6587\u5339\u914d\u6a21\u5f0f\uff0c\u4e0d\u8fdb\u884c\u5206\u8bcd\uff0c\u76f4\u63a5\u5168\u6587\u5339\u914d\uff0c\u8fd9\u6837\u901f\u5ea6\u6162\uff0c\u51c6\u786e\u7387\u9ad8\u3002\n\n\u793a\u4f8b[enable_cut_demo.py](examples/enable_cut_demo.py)\n\n```python\nlocation_str = [\"\u6d59\u6c5f\u7701\u676d\u5dde\u5e02\u4e0b\u57ce\u533a\u9752\u4e91\u885740\u53f73\u697c\"]\nimport addressparser2\ndf = addressparser2.transform(location_str)\nprint(df)\n```\n\noutput:\n\n```\n \u7701 \u5e02 \u533a \u5730\u540d\n0 \u6d59\u6c5f\u7701 \u676d\u5dde\u5e02 \u4e0b\u57ce\u533a \u9752\u4e91\u885740\u53f73\u697c\n```\n\n\u53ef\u4ee5\u5148\u901a\u8fc7jieba\u5206\u8bcd\uff0c\u4e4b\u540e\u505a\u7701\u5e02\u533a\u63d0\u53d6\u53ca\u6620\u5c04\uff0c\u6240\u4ee5\u6211\u4eec\u5f15\u5165\u4e86\u5207\u8bcd\u6a21\u5f0f\uff0c\u901f\u5ea6\u5f88\u5feb\uff0c\u4f7f\u7528\u65b9\u6cd5\u5982\u4e0b:\n```python\n\nlocation_str = [\"\u5f90\u6c47\u533a\u8679\u6f15\u8def461\u53f758\u53f7\u697c5\u697c\", \"\u6cc9\u5dde\u5e02\u6d1b\u6c5f\u533a\u4e07\u5b89\u5858\u897f\u5de5\u4e1a\u533a\", \"\u671d\u9633\u533a\u5317\u82d1\u534e\u8d38\u57ce\"]\nimport addressparser2\ndf = addressparser2.transform(location_str, cut=True)\nprint(df)\n```\n\noutput:\n```\n \u7701 \u5e02 \u533a \u5730\u540d\n 0 \u4e0a\u6d77\u5e02 \u4e0a\u6d77\u5e02 \u5f90\u6c47\u533a \u8679\u6f15\u8def461\u53f758\u53f7\u697c5\u697c\n 1 \u798f\u5efa\u7701 \u6cc9\u5dde\u5e02 \u6d1b\u6c5f\u533a \u4e07\u5b89\u5858\u897f\u5de5\u4e1a\u533a\n 2 \u5317\u4eac\u5e02 \u5317\u4eac\u5e02 \u671d\u9633\u533a \u5317\u82d1\u534e\u8d38\u57ce\n```\n\n\u4f46\u53ef\u80fd\u4f1a\u51fa\u9519\uff0c\u5982\u4e0b\u6240\u793a\uff0c\u8fd9\u79cd\u9519\u8bef\u7684\u7ed3\u679c\u662f\u56e0\u4e3ajieba\u672c\u8eab\u5c31\u5c06\u8bcd\u7ed9\u5206\u9519\u4e86\uff1a\n```python\nlocation_str = [\"\u6d59\u6c5f\u7701\u676d\u5dde\u5e02\u4e0b\u57ce\u533a\u9752\u4e91\u885740\u53f73\u697c\"]\nimport addressparser2\ndf = addressparser2.transform(location_str, cut=True)\nprint(df)\n```\n\noutput:\n\n```\n \u7701 \u5e02 \u533a \u5730\u540d\n0 \u6d59\u6c5f\u7701 \u676d\u5dde\u5e02 \u57ce\u533a \u4e0b\u57ce\u533a\u9752\u4e91\u885740\u53f73\u697c\n```\n\n> \u9ed8\u8ba4\u60c5\u51b5\u4e0btransform\u65b9\u6cd5\u7684cut\u53c2\u6570\u4e3aFalse\uff0c\u5373\u91c7\u7528\u5168\u6587\u5339\u914d\u7684\u65b9\u5f0f\uff0c\u8fd9\u79cd\u65b9\u5f0f\u51c6\u786e\u7387\u9ad8\uff0c\u4f46\u662f\u901f\u5ea6\u53ef\u80fd\u4f1a\u6709\u6162\u4e00\u70b9\uff1b\n> \u5982\u679c\u8ffd\u6c42\u901f\u5ea6\u800c\u4e0d\u8ffd\u6c42\u51c6\u786e\u7387\u7684\u8bdd\uff0c\u5efa\u8bae\u5c06cut\u8bbe\u4e3aTrue\uff0c\u4f7f\u7528\u5207\u8bcd\u6a21\u5f0f\u3002\n\n\n- \u5730\u5740\u7ecf\u7eac\u5ea6\u3001\u7701\u5e02\u53bf\u7ea7\u8054\u5173\u7cfb\u67e5\u8be2\n\n\u793a\u4f8b[find_place_demo.py](examples/find_place_demo.py)\n\n```python\n## \u67e5\u8be2\u7ecf\u7eac\u5ea6\u4fe1\u606f\nfrom addressparser2 import latlng\nlatlng[('\u5317\u4eac\u5e02','\u5317\u4eac\u5e02','\u671d\u9633\u533a')] #\u8f93\u51fa('39.95895316640668', '116.52169489108084')\n\n## \u67e5\u8be2\u542b\u6709\"\u9f13\u697c\u533a\"\u7684\u5168\u90e8\u5730\u5740\nfrom addressparser2 import area_map\narea_map.get_relational_addrs('\u9f13\u697c\u533a') #[('\u6c5f\u82cf\u7701', '\u5357\u4eac\u5e02', '\u9f13\u697c\u533a'), ('\u6c5f\u82cf\u7701', '\u5f90\u5dde\u5e02', '\u9f13\u697c\u533a'), ('\u798f\u5efa\u7701', '\u798f\u5dde\u5e02', '\u9f13\u697c\u533a'), ('\u6cb3\u5357\u7701', '\u5f00\u5c01\u5e02', '\u9f13\u697c\u533a')]\n#### \u6ce8: city_map\u53ef\u4ee5\u7528\u6765\u67e5\u8be2\u542b\u6709\u67d0\u4e2a\u5e02\u7684\u5168\u90e8\u5730\u5740, province_map\u53ef\u4ee5\u7528\u6765\u67e5\u8be2\u542b\u6709\u67d0\u4e2a\u7701\u7684\u5168\u90e8\u5730\u5740\n\n## \u67e5\u8be2\u542b\u6709\"\u6c5f\u82cf\u7701\", \"\u9f13\u697c\u533a\"\u7684\u5168\u90e8\u5730\u5740\nfrom addressparser2 import province_area_map\nprovince_area_map.get_relational_addrs(('\u6c5f\u82cf\u7701', '\u9f13\u697c\u533a')) # [('\u6c5f\u82cf\u7701', '\u5357\u4eac\u5e02', '\u9f13\u697c\u533a'), ('\u6c5f\u82cf\u7701', '\u5f90\u5dde\u5e02', '\u9f13\u697c\u533a')]\n```\n\n- \u7ed8\u5236echarts\u70ed\u529b\u56fe\n\n\u4f7f\u7528echarts\u7684\u70ed\u529b\u56fe\u7ed8\u56fe\u51fd\u6570\u4e4b\u524d\u9700\u8981\u5148\u7528\u5982\u4e0b\u547d\u4ee4\u5b89\u88c5\u5b83\u7684\u4f9d\u8d56\uff08\u4e3a\u4e86\u51cf\u5c11\u672c\u6a21\u5757\u7684\u4f53\u79ef\uff0c\u6240\u4ee5\u8fd9\u4e9b\u4f9d\u8d56\u4e0d\u4f1a\u88ab\u81ea\u52a8\u5b89\u88c5\uff09\uff1a\n\n```\npip install pyecharts==0.5.11\npip install echarts-countries-pypkg\npip install pyecharts-snapshot\n```\n\n\u4f7f\u7528\u672c\u4ed3\u5e93\u63d0\u4f9b\u7684\u4e00\u4e07\u591a\u6761\u5730\u5740\u6570\u636e[tests/addr.csv](./tests/addr.csv)\u6d4b\u8bd5\u3002\n\n\u793a\u4f8b[draw_demo.py](examples/draw_demo.py)\n\n```python\n#\u8bfb\u53d6\u6570\u636e\nimport pandas as pd\norigin = pd.read_csv(\"tests/addr.csv\")\n#\u8f6c\u6362\nimport addressparser2\naddr_df = addressparser2.transform(origin[\"\u539f\u59cb\u5730\u5740\"])\n#\u8f93\u51fa\nprocessed = pd.concat([origin, addr_df], axis=1)\nprocessed.to_csv(\"processed.csv\", index=False, encoding=\"utf-8\")\n\nfrom addressparser2 import drawer\ndrawer.echarts_draw(processed, \"echarts.html\")\n```\n\noutput:\n```\n1) processed.csv\uff1a1\u4e07\u591a\u5730\u5740\u7684\u7701\u5e02\u53bf\u63d0\u53d6\u7ed3\u679c\n2\uff09echarts.html\uff1aecharts\u70ed\u529b\u56fe\n```\n\u6d4f\u89c8\u5668\u6253\u5f00`echarts.html`\u540e\uff1a\n\n![echarts\u70ed\u529b\u56fe](./docs/echarts.png)\n\n- \u7ed8\u5236\u5206\u7c7b\u4fe1\u606f\u56fe\n\n\n\u6837\u672c\u5206\u7c7b\u7ed8\u5236\u51fd\u6570\uff0c\u901a\u8fc7\u989d\u5916\u4f20\u5165\u4e00\u4e2a\u6837\u672c\u7684\u5206\u7c7b\u4fe1\u606f\uff0c\u80fd\u591f\u5728\u5730\u56fe\u4e0a\u4ee5\u4e0d\u540c\u7684\u989c\u8272\u753b\u51fa\u5c5e\u4e8e\u4e0d\u540c\u5206\u7c7b\u7684\u6837\u672c\u6563\u70b9\u56fe\uff0c\u4ee5\u4e0b\u4ee3\u7801\u4ee5\u201c\u7701\u201d\u4f5c\u4e3a\u7c7b\u522b\u4fe1\u606f\u7ed8\u5236\u5206\u7c7b\u6563\u70b9\u56fe\uff08\u53ef\u4ee5\u770b\u5230\uff0c\u5c5e\u4e8e\u4e0d\u540c\u7701\u7684\u6837\u672c\u88ab\u4ee5\u4e0d\u540c\u7684\u989c\u8272\u6807\u8bb0\u4e86\u51fa\u6765\uff0c\u8fd9\u91cc\u4ee5\u201c\u7701\u201d\u4f5c\u4e3a\u5206\u7c7b\u6807\u51c6\u53ea\u662f\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5b9e\u9645\u5e94\u7528\u4e2d\u53ef\u4ee5\u9009\u53d6\u66f4\u52a0\u6709\u5b9e\u9645\u610f\u4e49\u7684\u5206\u7c7b\u6307\u6807\uff09\uff1a\n\n\u793a\u4f8b[draw_demo.py](examples/draw_demo.py)\uff0c\u63a5\u4e0a\u9762\u793a\u4f8b\u4ee3\u7801\uff1a\n```python\nfrom addressparser2 import drawer\ndrawer.echarts_cate_draw(processed, processed[\"\u7701\"], \"echarts_cate.html\")\n```\n\n\u6d4f\u89c8\u5668\u6253\u5f00\u8f93\u51fa\u7684`echarts_cate.html`\u540e\uff1a\n\n![echarts\u5206\u7c7b\u6563\u70b9\u56fe](./docs/echarts_cate.png)\n\n## Command line usage\n- \u547d\u4ee4\u884c\u6a21\u5f0f\n\n\u652f\u6301\u6279\u91cf\u63d0\u53d6\u5730\u5740\u7684\u7701\u5e02\u533a\u4fe1\u606f\uff1a\n\n\u793a\u4f8b[cmd_demo.py](examples/cmd_demo.py)\n\n```\npython3 -m addressparser2 address_input.csv -o out.csv\n\nusage: python3 -m addressparser2 [-h] -o OUTPUT [-c] input\n@description:\n\npositional arguments:\n input the input file path, file encode need utf-8.\n\noptional arguments:\n -h, --help show this help message and exit\n -o OUTPUT, --output OUTPUT\n the output file path.\n -c, --cut use cut mode.\n\n```\n> \u8f93\u5165\u6587\u4ef6\uff1a`address_input.csv`\uff1b\u8f93\u51fa\u6587\u4ef6\uff1a`out.csv`\uff0c\u7701\u5e02\u53bf\u5730\u5740\u4ee5`\\t`\u95f4\u9694\uff0c`-c`\u8868\u793a\u4f7f\u7528\u5207\u8bcd\n\n## Todo\n- [x] bug\u4fee\u590d\uff0c\u5409\u6797\u7701\u3001\u5e7f\u897f\u7701\u90e8\u5206\u5730\u5740\u548c\u4e0a\u6d77\u6d66\u4e1c\u65b0\u533a\u7b49\u4e09\u7ea7\u533a\u5212\u5730\u5740\u5339\u914d\u9519\u8bef\n- [x] \u589e\u52a0\u5b9a\u671f\u4ece\u6c11\u653f\u5c40\u5b98\u7f51\uff0c\u7edf\u8ba1\u5c40\u5b98\u7f51\u722c\u53d6\u6700\u65b0\u7701\u5e02\u53bf\u9547\u6751\u5212\u5206\u7684\u529f\u80fd\uff0c\u5ef6\u540e\uff0c\u539f\u56e0\u662f2018\u5e74\u540e\u5b98\u7f51\u672a\u66f4\u65b0\n- [x] \u89e3\u51b3\u8def\u540d\u88ab\u8bef\u8bc6\u522b\u4e3a\u7701\u5e02\u540d\u7684\u95ee\u9898\uff0ceg\"\u5929\u6d25\u7a7a\u6e2f\u7ecf\u6d4e\u533a\u73af\u6cb3\u5317\u8def80\u53f7\u7a7a\u6e2f\u5546\u52a1\u56ed\"\n- [x] \u6dfb\u52a0\u7701\u5e02\u533a\u63d0\u53d6\u540e\u7684\u7ea7\u8054\u6821\u9a8c\u903b\u8f91\n- [x] \u5927\u6279\u91cf\u5730\u5740\u6570\u636e\uff0c\u51c6\u53ec\u7387\u6548\u679c\u8bc4\u4f30\n- [x] \u8865\u5145\u9999\u6e2f\u3001\u6fb3\u95e8\u3001\u53f0\u6e7e\u4e09\u7ea7\u533a\u5212\u5730\u5740\u4fe1\u606f\n\n\n\n\n\n\n## License\n\n\n\u6388\u6743\u534f\u8bae\u4e3a [The Apache License 2.0](/LICENSE)\uff0c\u53ef\u514d\u8d39\u7528\u505a\u5546\u4e1a\u7528\u9014\u3002\u8bf7\u5728\u4ea7\u54c1\u8bf4\u660e\u4e2d\u9644\u52a0addressparser2\u7684\u94fe\u63a5\u548c\u6388\u6743\u534f\u8bae\u3002\n\n\n## Contribute\n\u9879\u76ee\u4ee3\u7801\u8fd8\u5f88\u7c97\u7cd9\uff0c\u5982\u679c\u5927\u5bb6\u5bf9\u4ee3\u7801\u6709\u6240\u6539\u8fdb\uff0c\u6b22\u8fce\u63d0\u4ea4\u56de\u672c\u9879\u76ee\uff0c\u5728\u63d0\u4ea4\u4e4b\u524d\uff0c\u6ce8\u610f\u4ee5\u4e0b\u4e24\u70b9\uff1a\n\n - \u5728`tests`\u6dfb\u52a0\u76f8\u5e94\u7684\u5355\u5143\u6d4b\u8bd5\n - \u4f7f\u7528`python -m pytest`\u6765\u8fd0\u884c\u6240\u6709\u5355\u5143\u6d4b\u8bd5\uff0c\u786e\u4fdd\u6240\u6709\u5355\u6d4b\u90fd\u662f\u901a\u8fc7\u7684\n\n\u4e4b\u540e\u5373\u53ef\u63d0\u4ea4PR\u3002\n\n\n## Reference\n\n* [chinese_province_city_area_mapper](https://github.com/DQinYuan/chinese_province_city_area_mapper)\n* [addressparser](https://github.com/shibing624/addressparser)\n",
"bugtrack_url": null,
"license": "MIT license",
"summary": "address",
"version": "0.0.28",
"project_urls": {
"Homepage": "https://github.com/advancehs/addana"
},
"split_keywords": [
"addana"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "508a2eb7a42f6e59e975f79f14aeda711add6ac111eeb5e79ed9a54e8209ad24",
"md5": "e8adb0416c6f05b7585e997403be1020",
"sha256": "13fa4256534ac623360106cbfbe0bc8680725f12487ba038126c32385422cd8c"
},
"downloads": -1,
"filename": "addana-0.0.28-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "e8adb0416c6f05b7585e997403be1020",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.7",
"size": 106427,
"upload_time": "2023-05-23T07:39:57",
"upload_time_iso_8601": "2023-05-23T07:39:57.398705Z",
"url": "https://files.pythonhosted.org/packages/50/8a/2eb7a42f6e59e975f79f14aeda711add6ac111eeb5e79ed9a54e8209ad24/addana-0.0.28-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1b440d68b90a18414e84a4eee9ae71eca7f3ac2690ecd3d200e9210396f92912",
"md5": "7606296948a2a56ca1b3a60d12bff2b3",
"sha256": "d04f35d1af64521462da2458000d2a26661bad01a896b682cb70bf48cc1212c7"
},
"downloads": -1,
"filename": "addana-0.0.28.tar.gz",
"has_sig": false,
"md5_digest": "7606296948a2a56ca1b3a60d12bff2b3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 109107,
"upload_time": "2023-05-23T07:39:59",
"upload_time_iso_8601": "2023-05-23T07:39:59.520603Z",
"url": "https://files.pythonhosted.org/packages/1b/44/0d68b90a18414e84a4eee9ae71eca7f3ac2690ecd3d200e9210396f92912/addana-0.0.28.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-23 07:39:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "advancehs",
"github_project": "addana",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "pyecharts",
"specs": []
},
{
"name": "pandas",
"specs": []
},
{
"name": "jieba",
"specs": []
},
{
"name": "folium",
"specs": []
}
],
"lcname": "addana"
}