地址大写

发布于 2024-12-12 03:20:47 字数 983 浏览 0 评论 0原文

我正在考虑使用经过 CASS 认证的地址验证服务来更正用户提供的街道地址在入境时。 (具体来说,我正在查看 SmartyStreets 的 LiveAddress。)但是,USPS 规定正确的地址必须全部大写,因此 CASS 服务几乎统一以这种方式返回地址。然而,当邮寄到该地址的客户时,最好使用更人性化的传统包装。

当然,问题是如何实现这一目标。我知道,如果不涉及正确大写的街道和城市名称的完整全国数据库,就没有完美的解决方案。不过,一组可行的启发式方法可能就足够了,因为我们可能会将正确的地址踢回给用户,最终将其留给他们。

经过几分钟的思考,我想出了一个简短的问题列表:

  • SW FIRST ST 应该是 SW First St,而不是 Sw First St
  • MCDOUGLE ST 应该是 McDougle St,而不是 Mcdougle St
  • MACDOUGLE ST 可能应该是 Macdougle St 而不是 MacDougle St,因为 Macoroni Rd 通常不应该是 MacOroni 路。
  • 1ST ST 应该是 1st St,而不是 1St St
  • 不知道街道名称是否基于姓氏,我们可能无法安全地将 VAN 变成 van,但 VON 可能会变成

是否有任何现有的库至少可以让我开始?地址是复杂且变化无常的事情,如果不需要的话,我宁愿不自制整个事情。我正在使用 C#,但我愿意从其他语言移植代码。

除此之外,是否有人对街道和/或城市名称的常见大写例外有一个不错的参考?

I'm looking into using a CASS-Certified address validation service to correct user-provided street addresses at the time of entry. (Specifically, I'm looking at SmartyStreets' LiveAddress.) However, USPS dictates that a correct address must be in all caps, so CASS services almost uniformly return addresses that way. When mailing to the client at that address, though, it would be preferable to use a more humane, conventional casing.

The question, of course, is how to make that happen. I know there's no such thing as a perfect solution that doesn't involve an complete nation-wide database of correctly capitalized street and city names. A set of passable heuristics might be good enough, though, since we will probably be kicking the corrected address back to the user, ultimately leaving it up to them.

A short list of problems that I was able to come up with after a few minutes of thought:

  • SW FIRST ST should be SW First St, not Sw First St.
  • MCDOUGLE ST should be McDougle St, not Mcdougle St.
  • MACDOUGLE ST should probably be Macdougle St rather than MacDougle St, since Macoroni Rd should usually not be MacOroni Rd.
  • 1ST ST should be 1st St, not 1St St.
  • Not knowing if a street name is based on a surname, we can possibly not safely make VAN into van, but VON can probably become von.

Are there any existing libraries that could at least get me started? Addresses are complicated and fickle things, and I'd rather not home-brew the whole thing if I don't have to. I'm using C#, but I'm open to porting code from another language.

Barring that, does anyone have a decent reference of common capitalization exceptions for street and/or city names?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

撩发小公举 2024-12-19 03:20:47

很高兴看到您正在使用 LiveAddress 服务来促进地址验证和标准化。您可能需要注意一件事,它将在将大小写规则应用于标准化地址的过程中对您有很大帮助:

我们最近推出了新的 REST+JSON 端点,返回地址的标准化形式以及地址的各个组成部分。因此,可以很容易地将大小写规则应用于独立于街道后缀和前后方向返回的“street_name”和“city_name”值。

除了 Stack Overflow 上的问题(我们持续监控)之外,欢迎联系 SmartyStreet 支持人员以获得有关此问题的更多帮助。我或许还应该提到我是 SmartyStreets 的创始人。最后,我们正在努力返回正确大小写的地址,但我还没有任何类型的发布时间框架。

Great to see that you're using the LiveAddress service to facilitate address verification and standardization. There is one thing you may want to be aware of that will help you significantly in the process of applying casing rules to your standardized address:

We recently introduced a new REST+JSON endpoint that returns the standardized form of the address as well as various component parts of the address. Because of this, it's very easy to apply your casing rules to "street_name" and "city_name" values returned independent of the street suffix and pre/post-directionals.

You're welcome to contact SmartyStreets support for additional help with this issue in addition to questions here on Stack Overflow (which we monitor continually). I should probably also mention that I'm the founder of SmartyStreets. Lastly, we're working on being able to return properly cased addresses, but I don't have any kind of release time frame on it yet.

许一世地老天荒 2024-12-19 03:20:47

不是图书馆,但您可能可以使用 Google Maps API 解决问题,具体取决于根据您的要求。

Not a library, but you could probably solve the problem with the Google Maps API depending on your requirements.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文