Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #17

Open
du1wu2lzlz opened this issue Jan 17, 2019 · 0 comments
Open

test #17

du1wu2lzlz opened this issue Jan 17, 2019 · 0 comments

Comments

@du1wu2lzlz
Copy link
Owner

介绍

本项目旨在将不规范(或者连续)的文本地址进行尽可能的标准化, 以及对两个地址进行相似度的计算

地理编码技术, 主要分为如下步骤

  • 地址标准库
  • 地址标准化
  • 相似度计算

pom

<dependencies>
    <dependency>
        <groupId>io.patamon.geocoding</groupId>
        <artifactId>geocoding</artifactId>
        <version>1.1</version>
    </dependency>
</dependencies>

<repositories>
    <repository>
        <id>patamon.release.repository</id>
        <name>github release repository</name>
        <url>https://raw.github.com/icemimosa/maven/release/</url>
    </repository>
</repositories>

1. 数据测试

方法调用: Geocoding

  • normalizing: 标准化
  • analyze: 解析成分词文档
  • similarity: 相似度计算
  • similarityWithResult: 相似度计算, 返回包含更多丰富的数据

1.1 标准化

>> 输入: 江苏南京市鼓楼区新模范马路66号
>> 输出:
Address(
	provinceId=320000000000, province=江苏省, 
	cityId=320100000000, city=南京市, 
	districtId=320103000000, district=鼓楼区, 
	streetId=320103030000, street=三牌楼街道, 
	townId=null, town=null, 
	villageId=null, village=null, 
	road=新模范马路, 
	roadNum=66, 
	buildingNum=3号楼2单元1303, 
	text=null
)
>> 输入: 上海上海宝山区宝山区新沪路58弄11-802  水韵华庭 】 (水韵华庭附近)
>> 输出: 
Address(
	provinceId=310000000000, province=上海, 
	cityId=310100000000, city=上海市, 
	districtId=310113000000, district=宝山区, 
	streetId=null, street=null, 
	townId=null, town=null, 
	villageId=null, village=null, 
	road=新沪路, 
	roadNum=58, 
	buildingNum=11-802, 
	text=水韵华庭水韵华庭附近
)
  • 返回的对象解释
    • province相关: 省
    • city相关: 市
    • district相关: 区、县
    • street相关: 街道
    • town相关: 乡镇
    • village相关: 村
    • road: 道路
    • roadNum: 路号
    • buildingNum: 建筑物号
    • text: 标准化后为匹配的地址。一般包含小区, 商场名称等信息

注: 如果对text的结果不是很满意, 比如出现重复或不准确, 可以通过分词的手段解决

1.2 相似度

>> 输入:
  浙江金华义乌市南陈小区8幢2号
  浙江金华义乌市稠城街道浙江省义乌市宾王路99号后面南陈小区8栋2号
>> 输出: 
  0.8451542547285166
>> 输入:
  山东省沂水县四十里堡镇东艾家庄村206号
  浙江金华义乌市南陈小区8幢2号
>> 输出:
  0.0

2. 说明

2.1 标准地址库

项目目前采用的是 淘宝物流4级地址 的标准地址库

也可以采用国家的标准地址库 (对应的github库, 中国5级行政区域mysql库)

2.2 标准化

  1. 首先基于正则提取出道路、建筑物号等信息
  2. 省市区等匹配
    1. 将标准的地址库建立倒排索引
    2. 将文本从起始位置开始, 采用最大长度优先的方式匹配所有词条
    3. 对所有匹配结果进行标准行政区域从属关系校验

2.3 相似度计算

  1. 对输入的两个地址进行标准化
  2. 对省市区等信息分配不同的权重
  3. 对道路号, 建筑号进行语义处理, 分配权重
  4. 对剩余文本(text)使用IK Analyzer进行分词
  5. 对两个结果集使用余弦相似度算法计算相似度

项目参考address-semantic-search,简化了流程,修复了各种不规则错误,使得使用更加方便。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant