从字符串中提取街道地址 [英] Extract street address from a string

查看:36
本文介绍了从字符串中提取街道地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用 python 从字符串(比如电子邮件)中提取街道地址?地址不是固定格式.它可以不带州、邮政编码、城市,但如果缺少这些参数,我可以猜测并提供它们.此外,地址可以由两条街道的拐角表示.提取地址后,我想将其发送到 Google 地图或其他类似服务以取回真实的格式化地址.

Is there any way to extract a street address from a string (say, email) using python? The address does not come in a set format. It can come without state, zip code, city, but I can guess and supply these parameters if they are missing. Also, the address may be represented by a corner of two streets. Once I extract the address, I want to send it to Google Map or other similar service to get back the real, formatted address.

它不需要 100% 准确,但是有没有图书馆可以做到这一点?如果它不存在,我应该如何开始?

It doesn't need to be 100% accurate, but is there any library to do that? If it doesn't exist, how should I start?

推荐答案

正如您自己所说的,地址可以采用多种格式.如果您将其他国家/地区的地址考虑在内,现实实际上会更糟.所以不,没有真正好的方法来解析和清理这些地址.您希望包含尽可能多的格式的区域越大,它就会变得越复杂.

As you already say yourself, an address can come in a large number of formats. And the reality is actually even worse if you take addresses from other countries into account. So no, there is not really a good way to parse and clean up such addresses. The larger the regional area is you want to include as possible formats, the more complicated it gets.

如果您无论如何都想将地址发送到 Google 地图,那么只需发送您的原始格式即可.谷歌有足够的数据来提取更有用的部分并尽可能地利用它.无论如何,当您将其发送给 Google 时,您可以首先进行.

If you want to send the address to Google Maps anyway, then just send your original format. Google has enough data to extract the more useful parts and make the best possible out of it. As you are sending it to Google anyway, you can just do it in the first place.

这篇关于从字符串中提取街道地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆