Skip to main content

这是一个从文本提取中文地区的包

Project description

这是一个专门从文本里面提取中国的省,市,县的一个python模块

例子:

from get_province_city_county.city import mycity
citys = mycity.get_city("我出生在一个名字叫安徽的省份,我去过浙江,江苏,合肥还有淮南,但我最喜欢的还是合肥,因为我在蜀山区生活过一段时间")
print(citys)

结果:[['安徽', 5, '淮南', 2, None, 0, False, [1, 1]]]

你也可以通过h_zd参数来指定要提取的省市范围,将提取范围缩小,以便得到更精确的结果

例子:

from get_province_city_county.city import mycity
citys = mycity.get_city("我出生在一个名字叫安徽的省份,我去过浙江,江苏,台州,合肥还有淮南,但我最喜欢的还是合肥,因为我在蜀山区生活过一段时间",h_zd="浙江")
print(citys)

结果:[['浙江', 5, '台州', 2, None, 0, False, [1, 1]]]

通过h_zd这个参数,就可以锁定范围了

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

get_province_city_county-1.3.0.tar.gz (36.0 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page