解析 R 中的地址字符串

问题描述

我在 R 中有多种地址格式的地址数据,并且希望至少解析为重要的地址部分,以便我可以使用地址来合并多个数据集。但是,由于地址可以采用多种格式,因此我需要一些可以识别单元或公寓的信息,例如,根据街道和邮政编码。

问题:

testaddress1 <- "20 W 34th St,New York,NY 10001"
testaddress2 <- "20 West 34 St,New York City,NY 10001"
testaddress3 <- "20 WEST 34th,NYC,NY 10001"

在 R 中有没有一种简单的方法来解析地址部分?理想情况下,以下部分:

Number: 20; Direction: West; Street: 34; City: New York; State: NY; Zip: 10001

地址中的单位和收件人也存在问题:

#Problem with units/apartments
testunit1 <- "UNIT 9A 740 Park Ave,NY 10021"
testunit2 <- "740 Park Ave 9A,NY 10021"
testunit3 <- "APT 9A,740 Park Ave,NY 10021"

#Ideal parse
Unit: 9A; Number: 740; Street: Park Ave; City: New York; State: NY; Zip: 10021

#Problem with recipient
testrec1<- "John Doe UNIT 9A,NY 10021"
testrec2 <- "John Doe,740 Park Ave 9A,NY 10021"
testrec3 <- "JOHN DOE APT 9A,NY 10021"

#Ideal parse
Recipient: John Doe; Unit: 9A; Number: 740; Street: Park Ave; City: New York; State: NY; Zip: 10021

我发现了这个,但它看起来一团糟,我在实现它时遇到了麻烦: https://slu-opengis.github.io/postmastr/articles/postmastr.html

在 R 中有没有自动解析地址的东西?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)