哪里有好的地址解析器 [英] Where is a good Address Parser

查看:24
本文介绍了哪里有好的地址解析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个很好的工具,它可以获取完整的邮寄地址、格式化以供显示或与邮寄标签一起使用,并将其转换为结构化对象.

I'm looking for a good tool that can take a full mailing address, formatted for display or use with a mailing label, and convert it into a structured object.

例如:

// Start with a formatted address in a single string
string f = "18698 E. Main Street
Big Town, AZ, 86011";

// Parse into address
Address addr = new Address(f);

addr.Street; // 18698 E. Main Street
addr.Locality; // Big Town
addr.Region; // AZ
addr.PostalCode; // 86011

现在我可以使用 RegEx 做到这一点.但棘手的部分是保持它足够通用以处理世界上的任何地址!

Now I could do this using RegEx. But the tricky part is keeping it general enough to handle any address in the world!

我相信一定有什么东西可以做到这一点.

I'm sure there has to be something out there that can do it.

如果有人注意到,这实际上是 opensocial.address 对象.

If anyone noticed, this is actually the format of the opensocial.address object.

推荐答案

Googlemaps API 在这方面效果很好.例如,假设您收到字符串120 w 45 st nyc".将其传递到 Googlemaps API 中,如下所示:http://maps.google.com/maps/geo?q=120+w+45+st+nyc,您会得到以下响应:

The Googlemaps API works pretty well for this. E.g., suppose you are given the string "120 w 45 st nyc". Pass it into the Googlemaps API like so: http://maps.google.com/maps/geo?q=120+w+45+st+nyc and you get this response:

{
  "name": "120 w 45 st nyc",
  "Status": {
    "code": 200,
    "request": "geocode"
  },
  "Placemark": [ {
    "id": "p1",
    "address": "120 W 45th St, New York, NY 10036, USA",
    "AddressDetails": {"Country": {"CountryNameCode": "US","CountryName": "USA","AdministrativeArea": {"AdministrativeAreaName": "NY","Locality": {"LocalityName": "New York","Thoroughfare":{"ThoroughfareName": "120 W 45th St"},"PostalCode": {"PostalCodeNumber": "10036"}}}},"Accuracy": 8},
    "ExtendedData": {
      "LatLonBox": {
        "north": 40.7603883,
        "south": 40.7540931,
        "east": -73.9807141,
        "west": -73.9870093
      }
    },
    "Point": {
      "coordinates": [ -73.9838617, 40.7572407, 0 ]
    }
  } ]
}

这篇关于哪里有好的地址解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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