用于根据提交的字符串推断国家/位置的库或 API?

问题描述 投票:0回答:2

我正在追溯清理 Offer Drive 产品的大量数据 (http://offerletter.io/drive.html)。我正在尝试标准化自由格式的“位置”字段,以确定提交的位置是否位于美国(或不是)。

值的粒度可能有所不同,但都是“真实的”,例如

San Francisco, CA
Milwaukee
Bangalore
我的问题是,有没有一种好方法(某些 API 或库)可以根据用户提交的字符串智能地规范这些内容,这样我就可以说:

normalized = GeoNormalize.normalize("San Francisco")
return normalized.country() == "United States"

我真的很喜欢

chronyk
https://github.com/KoffeinFlummi/Chronyk),类似的地点会很棒。

python django-models geolocation sanitization
2个回答
3
投票

有很多,通常由地图或GIS供应商提供。

例如,Google 地理编码服务接受字符串并以标准格式返回一组经过排名的位置:

https://developers.google.com/maps/documentation/geocoding/?csw=1#Geocoding

雅虎也有一个:

https://developer.yahoo.com/boss/geo/#overview

就像我说的,有很多很多。它们通常在轻度使用时免费,但在一定时间后会产生使用费。


2
投票

尝试geograpy3

如果您使用 python 3.x 并且在安装过程中遇到问题,请尝试:

    python3 -m pip3 install git+https://github.com/somnathrakshit/geograpy3.git
    python3 geograpy-nltk
© www.soinside.com 2019 - 2024. All rights reserved.