Skip to main content

这是一个从文本中找地名信息和地区码的库

Project description

pcacode

这是一个从文本中找地名信息和地区码的库

安装

pip install pcacode

使用方法

1.基础使用:

from pcacode import pcacode

pca = pcacode.pcacode()
info = pca.get_info(province='北京',content='朝阳区')

print(info)

结果:[('北京市', '直辖市', '朝阳区', '110105')]

说明:

  • province 为省名称,已做了模糊处理,测试版必须带,带上有助于提高效率和精度。
  • content 为内容 ,内容随意只要包含市/区县信息会自动提取

2.一些初始化技巧:

from pcacode import pcacode

pca = pcacode.pcacode(file_page=u'data/2020年11月中华人民共和国县以上行政区划代码.xlsx',
                      nations_file=u'data/56_nations.xlsx',
                      switch_data={},
                      dict_data={})

说明:

file_page:地区码数据文件路径

数据来源于 民政部 整理成了xlsx 格式可以查看data目录下面的2020年11月中华人民共和国县以上行政区划代码.xlsx文件,可以替换成自己的文件(注意,清除xlsx文件中的空格)
需要替换时:
file_page=u'you_file_path/you_file.xlsx'

nations_file:民族数据文件路径

用于处理少数民族自治区自治州名称使用,不建议改动,你也可以改为自己的名族文件库,详细请参看data下面的56_nations.xlsx文件

需要替换时:

nations_file=u'you_nations_file_path/you_nations_file.xlsx'

switch_data :替换省名简称(只能新增省的简称)

目前已经默认可以不带 '省','市'
自治区也可以自动识别
需要替换时:
switch_data={'京','北京市','沪','上海市'}

dict_data :替换地区码信息

地区吗经常变动,每次维护地区码表很麻烦,在这里提供一个临时方案

需要替换时:

dict_data={'330205':'江北区'}

3.存在的问题(下个版本处理)

###1.必须是全称才能处理

例如:
北京市 朝阳
提取结果:
[('北京市', '北京市', '北京市', '110000')]
下个版本优先解决这个问题

###2.自治州简称目前暂未处理

例如:
延边朝鲜族自治州
恩施土家族苗族自治州
分别简称为 延边 恩施的暂时无法处理 只能处理全称
详细信息请查看百度百科:自治区

###3.自治县简称目前暂未处理

例如:
围场满族蒙古族自治县
丰宁满族自治县
分别简称为 围场 丰宁的暂时无法处理 只能处理全称
详细信息请查看百度百科:自治县

4.下个版本更新计划

增加不需要省名称的提取方式
增加城市名称模糊处理的方式
丰富函数的返回类型和模式

致谢

感谢袁隆平先生和钟南山先生,让我医食无忧。

尾声

只有无知,没有自满

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pcacode-1.0.0.tar.gz (80.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pcacode-1.0.0-py3-none-any.whl (81.7 kB view details)

Uploaded Python 3

File details

Details for the file pcacode-1.0.0.tar.gz.

File metadata

  • Download URL: pcacode-1.0.0.tar.gz
  • Upload date:
  • Size: 80.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3.post20210118 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.6.12

File hashes

Hashes for pcacode-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9643a07f4685359b24b1140809f398dbf87f2d18b99250c6669bdbd36156f496
MD5 ce4f752a780e82efe11c09d56f0c80c6
BLAKE2b-256 0130996b165a67590cfd47f55e57743bbc819b8163d403d79ba8560747f047de

See more details on using hashes here.

File details

Details for the file pcacode-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pcacode-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 81.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3.post20210118 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.6.12

File hashes

Hashes for pcacode-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 230bc9d63200936573ea57af0754f5ea75186f5815683c4ee236f824bf9c2c9e
MD5 dc67f98916c23293cc0985a38c26a71f
BLAKE2b-256 019eade01eed86b949e06cfdd7aef3dfe415ee326be663c3949ef0026d11de03

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page