修改代码字符编码
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>fangjia-service</name>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>GBK</project.build.sourceEncoding>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<build>
|
||||
<finalName>fangjia-service</finalName>
|
||||
@@ -19,7 +19,7 @@
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<encoding>GBK</encoding>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
+15
-15
@@ -1,66 +1,66 @@
|
||||
package com.fangjia.service.address;
|
||||
|
||||
/**
|
||||
* 地址解析结果key
|
||||
* 地址解析结果key
|
||||
*
|
||||
* @author yk
|
||||
*
|
||||
*/
|
||||
public enum AddressAnalyseResultKeyEnum {
|
||||
/**
|
||||
* 原始输入地址
|
||||
* 原始输入地址
|
||||
*/
|
||||
orgAddress,
|
||||
/**
|
||||
* 省
|
||||
* 省
|
||||
*/
|
||||
province,
|
||||
/**
|
||||
* 城市
|
||||
* 城市
|
||||
*/
|
||||
city,
|
||||
/**
|
||||
* 区域
|
||||
* 区域
|
||||
*/
|
||||
region,
|
||||
/**
|
||||
* 板块
|
||||
* 板块
|
||||
*/
|
||||
block,
|
||||
/**
|
||||
* 解析后的完整地址
|
||||
* 解析后的完整地址
|
||||
*/
|
||||
address,
|
||||
/**
|
||||
* 解析后的最短地址
|
||||
* 解析后的最短地址
|
||||
*/
|
||||
shortAddress,
|
||||
/**
|
||||
* 房号
|
||||
* 房号
|
||||
*/
|
||||
houseNum,
|
||||
/**
|
||||
* 单元号
|
||||
* 单元号
|
||||
*/
|
||||
unitNum,
|
||||
/**
|
||||
* 室号
|
||||
* 室号
|
||||
*/
|
||||
roomNum,
|
||||
/**
|
||||
* 楼层
|
||||
* 楼层
|
||||
*/
|
||||
floor,
|
||||
/**
|
||||
* 子区,有些小区会分区,1、2、3、4区,东南西北区等
|
||||
* 子区,有些小区会分区,1、2、3、4区,东南西北区等
|
||||
*/
|
||||
zone,
|
||||
/**
|
||||
* 地址中包含的小区名
|
||||
* 地址中包含的小区名
|
||||
*/
|
||||
orgName,
|
||||
/**
|
||||
* 最终匹配到结果的模式
|
||||
* 最终匹配到结果的模式
|
||||
*/
|
||||
mode
|
||||
}
|
||||
|
||||
+13
-13
@@ -4,7 +4,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 基于分词的地址解析器
|
||||
* 基于分词的地址解析器
|
||||
*
|
||||
* @author yk
|
||||
*/
|
||||
@@ -12,16 +12,16 @@ import java.util.Map;
|
||||
@Deprecated
|
||||
public interface AddressParser {
|
||||
public enum StatusEnum{
|
||||
//0=匹配成功
|
||||
//0=匹配成功
|
||||
SUCCESS,
|
||||
//匹配失败
|
||||
//匹配失败
|
||||
FAIL
|
||||
}
|
||||
//指示匹配的小区来源
|
||||
//指示匹配的小区来源
|
||||
public enum PreciseEnum{
|
||||
//0=编辑过的小区库
|
||||
//0=编辑过的小区库
|
||||
FROM_EDITED,
|
||||
//1=地图上的地址库
|
||||
//1=地图上的地址库
|
||||
FROM_MAP,
|
||||
//2=ALL
|
||||
FROM_ALL
|
||||
@@ -31,19 +31,19 @@ public interface AddressParser {
|
||||
* @deprecated see parse2
|
||||
* @param orgCity
|
||||
* @param orgAddress
|
||||
* @param target 想把地址解析成什么对象,默认为district,可以取值为district:小区,office:写字楼,shop:商铺
|
||||
* @param isNearby 当没有找到匹配的小区,是否返回根据位置获得的最近的小区
|
||||
* @param target 想把地址解析成什么对象,默认为district,可以取值为district:小区,office:写字楼,shop:商铺
|
||||
* @param isNearby 当没有找到匹配的小区,是否返回根据位置获得的最近的小区
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> parse(String orgCity, String orgAddress, String target, boolean isNearby);
|
||||
public Map<String, Object> parse2(String orgCity, String orgAddress, String target, boolean isNearby);
|
||||
|
||||
/**
|
||||
* 解析地址,能够返回多个结果
|
||||
* @param city 城市
|
||||
* @param address 地址
|
||||
* @param includeMaps 匹配的结果是否包含来自地图的数据,true表示结果包含来自地图的数据
|
||||
* @param max 返回的结果集中最多条数
|
||||
* 解析地址,能够返回多个结果
|
||||
* @param city 城市
|
||||
* @param address 地址
|
||||
* @param includeMaps 匹配的结果是否包含来自地图的数据,true表示结果包含来自地图的数据
|
||||
* @param max 返回的结果集中最多条数
|
||||
* @return
|
||||
*/
|
||||
public List<Map> parseAsList(String city, String address, boolean includeMaps, int max);
|
||||
|
||||
+216
-216
File diff suppressed because it is too large
Load Diff
+9
-9
@@ -3,18 +3,18 @@ package com.fangjia.service.address;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 地址解析正则表达式
|
||||
* 地址解析正则表达式
|
||||
*/
|
||||
public interface AddressParserPatterns {
|
||||
|
||||
Pattern FULL_ADDRESS = Pattern.compile("^.{2,}(路|街|大道|巷|道|((零|一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)[线环条甲])|(胡同))(交汇|.{0,3}段|.*弄)?((([甲乙]?[零一二三四五六七八九十百千\\d]+甲?号?)(?!楼)[~\\-~、,-])?([甲乙]?[零一二三四五六七八九十百千\\d])+甲?(号)(?!楼)+([付附]+[零一二三四五六七八九十百千\\d]+(号)?+([-]+[零一二三四五六七八九十百千\\d]+(号)?)?)?)");
|
||||
Pattern STREET = Pattern.compile("^.{2,}(路|街|大道|巷|道|((零|一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)[线环条甲])|(胡同))(交汇|.{0,3}段|.*弄)?");
|
||||
Pattern STREET_NUMBER = Pattern.compile(".*([甲乙]?[零一二三四五六七八九十百千\\d]+甲?(号)(?!楼)?[~\\--~、,])?([甲乙]?[零一二三四五六七八九十百千\\d]+甲?(号)(?!楼)+([付附]+[零一二三四五六七八九十百千\\d]+(号)?+([-]+[零一二三四五六七八九十百千\\d]+(号)?)?)?)");
|
||||
Pattern STAGE_PATTERN = Pattern.compile("(([零一二三四五六七八九十百千\\d]+)期?[,、至到]?)?([零一二三四五六七八九十百千\\d]+)期");
|
||||
Pattern PARTITION_PATTERN = Pattern.compile("(\\w|东|南|北|中|西|甲|乙|丙|丁|零|一|二|三|四|五|六|七|八|九|十)+(区|坊)");
|
||||
Pattern TOWN = Pattern.compile("^.+?(乡|镇|街道)+");
|
||||
Pattern FULL_ADDRESS = Pattern.compile("^.{2,}(路|街|大道|巷|道|((零|一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)[线环条甲])|(胡同))(交汇|.{0,3}段|.*弄)?((([甲乙]?[零一二三四五六七八九十百千\\d]+甲?号?)(?!楼)[~\\-~、,-])?([甲乙]?[零一二三四五六七八九十百千\\d])+甲?(号)(?!楼)+([付附]+[零一二三四五六七八九十百千\\d]+(号)?+([-]+[零一二三四五六七八九十百千\\d]+(号)?)?)?)");
|
||||
Pattern STREET = Pattern.compile("^.{2,}(路|街|大道|巷|道|((零|一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)[线环条甲])|(胡同))(交汇|.{0,3}段|.*弄)?");
|
||||
Pattern STREET_NUMBER = Pattern.compile(".*([甲乙]?[零一二三四五六七八九十百千\\d]+甲?(号)(?!楼)?[~\\--~、,])?([甲乙]?[零一二三四五六七八九十百千\\d]+甲?(号)(?!楼)+([付附]+[零一二三四五六七八九十百千\\d]+(号)?+([-]+[零一二三四五六七八九十百千\\d]+(号)?)?)?)");
|
||||
Pattern STAGE_PATTERN = Pattern.compile("(([零一二三四五六七八九十百千\\d]+)期?[,、至到]?)?([零一二三四五六七八九十百千\\d]+)期");
|
||||
Pattern PARTITION_PATTERN = Pattern.compile("(\\w|东|南|北|中|西|甲|乙|丙|丁|零|一|二|三|四|五|六|七|八|九|十)+(区|坊)");
|
||||
Pattern TOWN = Pattern.compile("^.+?(乡|镇|街道)+");
|
||||
Pattern NUMBER = Pattern.compile("\\d+");
|
||||
Pattern STANDARD_ADDRESS = Pattern.compile("^.{2,}(路|街|大道|巷|道|((零|一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)[线环条甲])|(胡同))(交汇|.{0,3}段|.*弄)?((([零一二三四五六七八九十百千\\d])+弄)|([甲乙]?([零一二三四五六七八九十百千\\d]))+号(?!楼)+([付附]+[零一二三四五六七八九十百千\\d]+(号)?+([-]+[零一二三四五六七八九十百千\\d]+(号)?)?)?)");
|
||||
Pattern DISTRICT = Pattern.compile("^.{2,}?(区|县)");
|
||||
Pattern STANDARD_ADDRESS = Pattern.compile("^.{2,}(路|街|大道|巷|道|((零|一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)[线环条甲])|(胡同))(交汇|.{0,3}段|.*弄)?((([零一二三四五六七八九十百千\\d])+弄)|([甲乙]?([零一二三四五六七八九十百千\\d]))+号(?!楼)+([付附]+[零一二三四五六七八九十百千\\d]+(号)?+([-]+[零一二三四五六七八九十百千\\d]+(号)?)?)?)");
|
||||
Pattern DISTRICT = Pattern.compile("^.{2,}?(区|县)");
|
||||
|
||||
}
|
||||
|
||||
+10
-10
@@ -5,28 +5,28 @@ import com.fangjia.service.address.mode.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 地址解析接口
|
||||
* 地址解析接口
|
||||
* @author wenyan
|
||||
*/
|
||||
public interface AddressParserService {
|
||||
|
||||
|
||||
/**
|
||||
* 根据地址信息匹配出库中最优的小区
|
||||
* 根据地址信息匹配出库中最优的小区
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
Building parser(MatchParams params);
|
||||
|
||||
/**
|
||||
* 根据地址信息匹配出库中所有可能的小区
|
||||
* 根据地址信息匹配出库中所有可能的小区
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
AddressParseResult parserAll(MatchParams params);
|
||||
|
||||
/**
|
||||
* 地址标准化
|
||||
* 地址标准化
|
||||
* @param city
|
||||
* @param address
|
||||
* @return
|
||||
@@ -34,7 +34,7 @@ public interface AddressParserService {
|
||||
Address standardize(String city, String address);
|
||||
|
||||
/**
|
||||
* 计算address和datas数据相似度得分
|
||||
* 计算address和datas数据相似度得分
|
||||
* @param city
|
||||
* @param address
|
||||
* @param datas
|
||||
@@ -43,31 +43,31 @@ public interface AddressParserService {
|
||||
AddressRate rate(String city, String address, List<AddressMatchMetaData> datas);
|
||||
|
||||
/**
|
||||
* 加载CPDB库中的数据
|
||||
* 加载CPDB库中的数据
|
||||
*/
|
||||
void loadData();
|
||||
|
||||
/**
|
||||
* 清理缓存
|
||||
* 清理缓存
|
||||
* @param city
|
||||
*/
|
||||
void clearCache(String city);
|
||||
|
||||
/**
|
||||
* 地址认证接口
|
||||
* 地址认证接口
|
||||
* @param params
|
||||
*/
|
||||
Building certificate(MatchParams params);
|
||||
|
||||
/**
|
||||
* 地址标准化接口
|
||||
* 地址标准化接口
|
||||
* @param params
|
||||
*/
|
||||
Building standard(MatchParams params);
|
||||
|
||||
|
||||
/**
|
||||
* 标准化地址用于地址搜索
|
||||
* 标准化地址用于地址搜索
|
||||
* @param city
|
||||
* @param address
|
||||
* @return
|
||||
|
||||
+50
-50
@@ -33,7 +33,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 地址解析服务
|
||||
* 地址解析服务
|
||||
*
|
||||
* @author wenyan
|
||||
*/
|
||||
@@ -65,9 +65,9 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
List<AddressMatchMetaData> matchMetaDataList = findAllDistrictByCityAndCategory(city,buildingType);
|
||||
if(!matchMetaDataList.isEmpty()){
|
||||
SEAWEED_LOCAL_CACHE.put(new MetaDataCacheKey(city, buildingType, MetaDataType.CPDB), matchMetaDataList);
|
||||
logger.warn("重新加载数据:" + city + "," + buildingType.toString() + "," + MetaDataType.CPDB.toString() + "加载数据量:" + matchMetaDataList.size());
|
||||
logger.warn("重新加载数据:" + city + "," + buildingType.toString() + "," + MetaDataType.CPDB.toString() + "加载数据量:" + matchMetaDataList.size());
|
||||
}else{
|
||||
logger.warn("数据加载失败:" + city + "," + buildingType.toString() + "," + MetaDataType.CPDB.toString());
|
||||
logger.warn("数据加载失败:" + city + "," + buildingType.toString() + "," + MetaDataType.CPDB.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,13 +146,13 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
|
||||
public void loadData(){
|
||||
|
||||
logger.warn("开始加载CPDB数据");
|
||||
logger.warn("开始加载CPDB数据");
|
||||
List<ServerArea> serverAreaList = ServerAreaData.getServerAreaList();
|
||||
for(ServerArea area : serverAreaList){
|
||||
clearCache(area.getDisplay());
|
||||
logger.warn(area.getDisplay() + "加载结束");
|
||||
logger.warn(area.getDisplay() + "加载结束");
|
||||
}
|
||||
logger.warn("加载数据CPDB结束");
|
||||
logger.warn("加载数据CPDB结束");
|
||||
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO 省市区乡镇采用原始拆分数据,若乡镇数据没有使用
|
||||
* TODO 省市区乡镇采用原始拆分数据,若乡镇数据没有使用
|
||||
* @param address
|
||||
* @return
|
||||
*/
|
||||
@@ -233,7 +233,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
return null;
|
||||
}*/
|
||||
/**
|
||||
* 信息不全时使用阿里接口补全数据
|
||||
* 信息不全时使用阿里接口补全数据
|
||||
* @param matchedBuilding
|
||||
* @param aliyunBo
|
||||
* @return
|
||||
@@ -279,7 +279,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
addr.setBuildingNumber(aliyunBo.getHouseno());
|
||||
addr.setOrgUnitNumber(aliyunBo.getCellno());
|
||||
addr.setUnitNumber(aliyunBo.getCellno());*/
|
||||
/*if(aliyunBo.getRoomno()!=null && !aliyunBo.getRoomno().matches(".*(层|楼)$")){
|
||||
/*if(aliyunBo.getRoomno()!=null && !aliyunBo.getRoomno().matches(".*(层|楼)$")){
|
||||
addr.setOrgRoomNumber(aliyunBo.getRoomno());
|
||||
addr.setRoomNumber(aliyunBo.getRoomno());
|
||||
}else{
|
||||
@@ -325,27 +325,27 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
if(matchedMate.getMetaDataType() == MetaDataType.CPDB){
|
||||
District district = districtService.findById(matchedMate.getId(), MATCH_PROPERTY_FIELDS);
|
||||
if("1".equals(addr.getPropertyType())){
|
||||
if(!district.getEstateType2().equals("别墅") || !district.getName().endsWith("别墅")){
|
||||
District districtNew = districtService.findDistrict(new DistrictKey(district.getCity(), district.getRegion(), district.getName() + "别墅"), district.getCategory());
|
||||
if(!district.getEstateType2().equals("别墅") || !district.getName().endsWith("别墅")){
|
||||
District districtNew = districtService.findDistrict(new DistrictKey(district.getCity(), district.getRegion(), district.getName() + "别墅"), district.getCategory());
|
||||
if(districtNew != null){
|
||||
district = districtNew;
|
||||
}
|
||||
}
|
||||
}else if("2".equals(addr.getPropertyType())){
|
||||
if(!district.getEstateType2().equals("商住") || !district.getName().endsWith("商住楼")){
|
||||
District districtNew = districtService.findDistrict(new DistrictKey(district.getCity(), district.getRegion(), district.getName() + "商住楼"), district.getCategory());
|
||||
if(!district.getEstateType2().equals("商住") || !district.getName().endsWith("商住楼")){
|
||||
District districtNew = districtService.findDistrict(new DistrictKey(district.getCity(), district.getRegion(), district.getName() + "商住楼"), district.getCategory());
|
||||
if(districtNew != null){
|
||||
district = districtNew;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(district == null){
|
||||
logger.error("未找到匹配的CPDB数据:" + addr + "ID:" + matchedMate.getId());
|
||||
logger.error("未找到匹配的CPDB数据:" + addr + "ID:" + matchedMate.getId());
|
||||
}else{
|
||||
district = districtService.findById(district.getId(), MATCH_PROPERTY_FIELDS);
|
||||
}
|
||||
if(district == null){
|
||||
logger.error("未找到匹配的CPDB数据:" + addr + "ID:" + matchedMate.getId());
|
||||
logger.error("未找到匹配的CPDB数据:" + addr + "ID:" + matchedMate.getId());
|
||||
return new Building();
|
||||
}
|
||||
return new Building(district, scoreResult.getScore(matchedMate));
|
||||
@@ -383,7 +383,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
@Override
|
||||
public AddressRate rate(String city, String address, List<AddressMatchMetaData> datas) {
|
||||
|
||||
AddressMatchMetaData firstData = datas.get(0);//使用第一条数据的经纬度作为改地址的经纬度
|
||||
AddressMatchMetaData firstData = datas.get(0);//使用第一条数据的经纬度作为改地址的经纬度
|
||||
Address addr = buildAddress(city, address,firstData.getLng(), firstData.getLat());//TODO
|
||||
AddressRate result = new AddressRate();
|
||||
for(AddressMatchMetaData mate : datas){
|
||||
@@ -395,7 +395,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据匹配参数构建一个标准的地址信息
|
||||
* 根据匹配参数构建一个标准的地址信息
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@@ -417,7 +417,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
|
||||
|
||||
/**
|
||||
* 根据输入地址构建一个标准的地址信息
|
||||
* 根据输入地址构建一个标准的地址信息
|
||||
*
|
||||
* @param city
|
||||
* @param address
|
||||
@@ -431,7 +431,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据输入地址构建一个标准的地址信息
|
||||
* 根据输入地址构建一个标准的地址信息
|
||||
* @param city
|
||||
* @param address
|
||||
* @param lng
|
||||
@@ -475,7 +475,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
|
||||
|
||||
/**
|
||||
* 获得某城市所有小区
|
||||
* 获得某城市所有小区
|
||||
*
|
||||
* @param city
|
||||
* @return
|
||||
@@ -495,7 +495,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
data.setCity(city);
|
||||
data.setDistrict(district.getRegion());
|
||||
data.addNames(district.getAlias(), MatchText.ALIAS_PRIORITY);
|
||||
data.addName(district.getName(), MatchText.MAIN_NAME_PRIORITY);//先加别名 再加主名 降低别字名称的优先级
|
||||
data.addName(district.getName(), MatchText.MAIN_NAME_PRIORITY);//先加别名 再加主名 降低别字名称的优先级
|
||||
data.addAddrs(district.getAddrAlias(), MatchText.ADDR_ALIAS_PRIORITY);
|
||||
data.addAddress(district.getAddress(), MatchText.MAIN_ADDR_PRIORITY);
|
||||
data.setBuildingType(buildingType);
|
||||
@@ -519,7 +519,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 分割地址 把"呼玛路2-4号" 分割成呼玛路2号,呼玛路3号,呼玛路4号
|
||||
* 分割地址 把"呼玛路2-4号" 分割成呼玛路2号,呼玛路3号,呼玛路4号
|
||||
*
|
||||
* @param address
|
||||
* @param addrAlias
|
||||
@@ -532,9 +532,9 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
if (connStreetNumber != null) {
|
||||
int index = address.indexOf(connStreetNumber);
|
||||
String remain = address.substring(0, index);
|
||||
String[] split = connStreetNumber.split("(~|-|~)");
|
||||
String[] splitComma = connStreetNumber.split("(,|,|、)");
|
||||
// String unit = "号";
|
||||
String[] split = connStreetNumber.split("(~|-|~)");
|
||||
String[] splitComma = connStreetNumber.split("(,|,|、)");
|
||||
// String unit = "号";
|
||||
// String[] split = connStreetNumber.substring(0, connStreetNumber.length() - 1).split("-");
|
||||
if(remain.length() > 1){
|
||||
if (split.length > 1) {
|
||||
@@ -570,13 +570,13 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
}else{
|
||||
String street = AddressParserUtil.match(AddressParserPatterns.STANDARD_ADDRESS,address);
|
||||
if(StringUtils.isNotBlank(street)){
|
||||
if(street.endsWith("弄")){
|
||||
String simAddr = street.replaceAll("弄$","号");
|
||||
if(street.endsWith("弄")){
|
||||
String simAddr = street.replaceAll("弄$","号");
|
||||
if(!addrAlias.contains(simAddr)){
|
||||
addrAlias.add(simAddr);
|
||||
}
|
||||
}else if(street.endsWith("号")){
|
||||
String simAddr = street.replaceAll("号$","弄");
|
||||
}else if(street.endsWith("号")){
|
||||
String simAddr = street.replaceAll("号$","弄");
|
||||
if(!addrAlias.contains(simAddr)){
|
||||
addrAlias.add(simAddr);
|
||||
}
|
||||
@@ -596,7 +596,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
return unitList;
|
||||
}
|
||||
/**
|
||||
* 在CPDB库中查询匹配到的数据
|
||||
* 在CPDB库中查询匹配到的数据
|
||||
*
|
||||
* @param addr
|
||||
* @param buildingType
|
||||
@@ -632,7 +632,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选出得分大于0的建筑物
|
||||
* 筛选出得分大于0的建筑物
|
||||
*
|
||||
* @param districts
|
||||
* @param address
|
||||
@@ -652,7 +652,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
}
|
||||
long time = System.currentTimeMillis() - start;
|
||||
if(time > 500){
|
||||
logger.warn("打分耗时:" + time + "ms");
|
||||
logger.warn("打分耗时:" + time + "ms");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -673,7 +673,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
if(PreciseLevel.STRICT == address.getPreciseLevel() && !sameDistrict){
|
||||
return 0;
|
||||
}
|
||||
// //当地图解析出来的区域和用户地址中的区域一致时,只匹配指定区域下面的小区
|
||||
// //当地图解析出来的区域和用户地址中的区域一致时,只匹配指定区域下面的小区
|
||||
// if(address.getGeoRegion() != null && address.getGeoRegion().equals(address.getDistrict()) && !sameDistrict){
|
||||
// return 0;
|
||||
// }
|
||||
@@ -687,7 +687,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
String addrPinYin = addrEntry.getKey();
|
||||
String streetPinYin = address.getStreetPinYin();
|
||||
String street = address.getStreet();
|
||||
/**输入地址是精确地址*/
|
||||
/**输入地址是精确地址*/
|
||||
if(address.isStandardAddress()) {
|
||||
Map<String, String> standardAddressMap = address.getStandardAddressMap();
|
||||
for(String standardAddressPinYin : standardAddressMap.keySet()){
|
||||
@@ -755,7 +755,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
}
|
||||
if(StringUtils.isNotBlank(fuzzyKeywords)){
|
||||
double similar = AddressParserUtil.getSimilarityRatio(name, fuzzyKeywords);
|
||||
if(similar == 1){//对和小区名一致的模糊关键词进行加权
|
||||
if(similar == 1){//对和小区名一致的模糊关键词进行加权
|
||||
keywordScore = Math.max(similar * namePriority, keywordScore) * 1.0001;
|
||||
}
|
||||
if(name.length() == 2 || fuzzyKeywords.length() == 2){
|
||||
@@ -771,7 +771,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
}
|
||||
}
|
||||
if(similar >= 0.6 && namePinYin.contains(fuzzyKeywordsPinYin)){
|
||||
//名称一致,或者多个修饰词,排除新泾苑 <--> 新泾
|
||||
//名称一致,或者多个修饰词,排除新泾苑 <--> 新泾
|
||||
if(name.length() == fuzzyKeywords.length() || Math.abs(name.length() - fuzzyKeywords.length()) > 1){
|
||||
fuzzyKeywordsScore = Math.max(similar * namePriority, fuzzyKeywordsScore);
|
||||
}
|
||||
@@ -780,7 +780,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
}
|
||||
if(StringUtils.isNotBlank(suggestName)){
|
||||
double similar = AddressParserUtil.getSimilarityRatio(name, suggestName);
|
||||
if(similar == 1){//对和小区名一致的模糊关键词进行加权
|
||||
if(similar == 1){//对和小区名一致的模糊关键词进行加权
|
||||
keywordScore = Math.max(similar * namePriority, keywordScore) * 1.0001;
|
||||
}
|
||||
if(suggestNamePinYin.contains(namePinYin)){
|
||||
@@ -796,7 +796,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
}
|
||||
if(fuzzyKeywordsScore <= 0 && (enhanceContains(address.getOrgAddress(), name) || (address.isPinYin() && address.getOrgAddrePinYin().contains(namePinYin)))){
|
||||
double similar;
|
||||
if(address.isPinYin()){//当用户的输入全是拼音时,使用拼音的相似度
|
||||
if(address.isPinYin()){//当用户的输入全是拼音时,使用拼音的相似度
|
||||
similar = AddressParserUtil.getSimilarityRatio(namePinYin, address.getOrgAddrePinYin()) * namePriority;
|
||||
}else{
|
||||
similar = AddressParserUtil.getSimilarityRatio(name, address.getOrgAddress()) * namePriority;
|
||||
@@ -858,19 +858,19 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
if(sameDistrict){
|
||||
similarityScore += 0.02;
|
||||
}
|
||||
if(metaData.getMetaDataType() == MetaDataType.MAP && metaData.getType() != null && metaData.getType().contains("住宅区")){
|
||||
if(metaData.getMetaDataType() == MetaDataType.MAP && metaData.getType() != null && metaData.getType().contains("住宅区")){
|
||||
similarityScore += 0.005;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* similarityScore = 相似度部分(0.07) + 类型部分(0.01) < 0.1
|
||||
* similarityScore = 相似度部分(0.07) + 类型部分(0.01) < 0.1
|
||||
* */
|
||||
double score = matchLevelScore + similarityScore;
|
||||
return score;
|
||||
|
||||
}
|
||||
|
||||
static final Pattern NUMBER_PATTERN = Pattern.compile("[\\d一二三四五六七八九十千百万]+");
|
||||
static final Pattern NUMBER_PATTERN = Pattern.compile("[\\d一二三四五六七八九十千百万]+");
|
||||
|
||||
private static boolean enhanceContains(String str1, String str2){
|
||||
if(!str1.contains(str2)){
|
||||
@@ -890,7 +890,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否在相同区域
|
||||
* 是否在相同区域
|
||||
* @param address
|
||||
* @param metaData
|
||||
* @return
|
||||
@@ -970,7 +970,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 在楼栋库中验证单元号是否存在
|
||||
* 在楼栋库中验证单元号是否存在
|
||||
* @param key
|
||||
* @param buildingNumber
|
||||
* @param unitNumber
|
||||
@@ -1003,7 +1003,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 在楼栋库中验证楼栋号否存在
|
||||
* 在楼栋库中验证楼栋号否存在
|
||||
* @param key
|
||||
* @param buildingNumber
|
||||
* @return
|
||||
@@ -1043,7 +1043,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
}
|
||||
}
|
||||
String cityDisplay = CityData.getCityDisplay(address.getCity());
|
||||
formattedAddressBuilder.append(cityDisplay != null ? cityDisplay : (StringUtils.isNotBlank(address.getCity())?(address.getCity()+ "市"):""));
|
||||
formattedAddressBuilder.append(cityDisplay != null ? cityDisplay : (StringUtils.isNotBlank(address.getCity())?(address.getCity()+ "市"):""));
|
||||
if(StringUtils.isNotBlank(address.getDistrict())){
|
||||
String orgDistrict = RegionData.getOrgName(address.getCity(), address.getDistrict());
|
||||
if(StringUtils.isNotBlank(orgDistrict) && formattedAddressBuilder.indexOf(orgDistrict) == -1){
|
||||
@@ -1090,30 +1090,30 @@ public class AddressParserServiceImpl implements AddressParserService {
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(address.getOrgBuildingNumber())){
|
||||
if(StringUtils.isNotBlank(address.getStreet()) && address.getStreet().endsWith("弄")
|
||||
if(StringUtils.isNotBlank(address.getStreet()) && address.getStreet().endsWith("弄")
|
||||
&& StringUtils.isNotBlank(address.getStreetNumber())
|
||||
&& address.getStreetNumber().endsWith(address.getOrgBuildingNumber())){
|
||||
|
||||
}else{
|
||||
// formattedAddressBuilder.append(address.getBuildingNumber());
|
||||
formattedAddressBuilder.append(address.getBuildingNumber() + "栋");
|
||||
formattedAddressBuilder.append(address.getBuildingNumber() + "栋");
|
||||
}
|
||||
|
||||
}
|
||||
if(StringUtils.isNotBlank(address.getOrgUnitNumber())){
|
||||
// formattedAddressBuilder.append(address.getUnitNumber());
|
||||
formattedAddressBuilder.append(address.getUnitNumber() + "单元");
|
||||
formattedAddressBuilder.append(address.getUnitNumber() + "单元");
|
||||
}
|
||||
if(StringUtils.isNotBlank(address.getRoomNumber())){
|
||||
// formattedAddressBuilder.append(address.getRoomNumber());
|
||||
formattedAddressBuilder.append(address.getRoomNumber() + "室");
|
||||
formattedAddressBuilder.append(address.getRoomNumber() + "室");
|
||||
}
|
||||
address.setFormattedAddress(formattedAddressBuilder.toString());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 相似度比重
|
||||
* 相似度比重
|
||||
*/
|
||||
public static final double SIMILARITY_RATE = 0.06;
|
||||
|
||||
|
||||
+52
-52
@@ -21,39 +21,39 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class AddressParserUtil {
|
||||
|
||||
static final Pattern STREET_PATTERN = Pattern.compile("^.+(路|街道|弄|街|道|巷)");
|
||||
static final Pattern CONNECTOR_PATTERN = Pattern.compile("~|-|~");
|
||||
public static final Pattern STREET_NUMBER_CONNECTOR_PATTERN = Pattern.compile("(\\d+)(支弄|号|弄)?(~|-|~|,|,|、)\\d+(支弄|号|弄)");
|
||||
static final Pattern SEPARATOR_PATTERN = Pattern.compile("、|,");
|
||||
static final Pattern STREET_NUMBER_PATTERN = Pattern.compile("(\\d+(~|-|~|、|,))*\\d+(号|栋|幢)");
|
||||
static final Pattern UNIT_NUMBER_PATTERN = Pattern.compile("(\\w+室)|(\\w+(号|栋|幢|单元))\\w+(室)*");
|
||||
static final Pattern FLOOR_PATTERN = Pattern.compile("((\\d|一|二|三|四|五|六|七|八|九|十|零|百|千)+(楼|层)*(-|~|到|至)*)*((\\d+|一|二|三|四|五|六|七|八|九|十|零|百|千)(楼|层))");
|
||||
static final Pattern BRACKET_PATTERN = Pattern.compile("(\\(|()+.+(\\)|))+");
|
||||
static final Pattern LOOP_LINE_PATTERN = Pattern.compile("((一|二|三|四|五|六|七|八|九|十|外|中|内)环(以内|以外)*)+(((到|至)*(一|二|三|四|五|六|七|八|九|十|外|中|内)环)*(之间)*)*");
|
||||
static final Pattern STAGE_PATTERN = Pattern.compile("((一|二|三|四|五|六|七|八|九|十)|\\d+)+期");
|
||||
static final Pattern PARTITION_PATTERN = Pattern.compile("(\\w|东|南|北|中|西|甲|乙|丙|丁|一|二|三|四|五|六|七|八|九|十)+区");
|
||||
static final Pattern INVALID_PATTERN = Pattern.compile("^(\\-|\\\\|、)+$");
|
||||
static final Pattern CHINESE_CONTAINS_DOT = Pattern.compile("[\\u4e00-\\u9fa5]+(·|\\.)+[\\u4e00-\\u9fa5]+");
|
||||
static final Pattern BUILDING_NUMBER_PATTERN = Pattern.compile("\\w+((号楼)|(#楼)|栋|幢|座|#)");
|
||||
static final Pattern STREET_PATTERN = Pattern.compile("^.+(路|街道|弄|街|道|巷)");
|
||||
static final Pattern CONNECTOR_PATTERN = Pattern.compile("~|-|~");
|
||||
public static final Pattern STREET_NUMBER_CONNECTOR_PATTERN = Pattern.compile("(\\d+)(支弄|号|弄)?(~|-|~|,|,|、)\\d+(支弄|号|弄)");
|
||||
static final Pattern SEPARATOR_PATTERN = Pattern.compile("、|,");
|
||||
static final Pattern STREET_NUMBER_PATTERN = Pattern.compile("(\\d+(~|-|~|、|,))*\\d+(号|栋|幢)");
|
||||
static final Pattern UNIT_NUMBER_PATTERN = Pattern.compile("(\\w+室)|(\\w+(号|栋|幢|单元))\\w+(室)*");
|
||||
static final Pattern FLOOR_PATTERN = Pattern.compile("((\\d|一|二|三|四|五|六|七|八|九|十|零|百|千)+(楼|层)*(-|~|到|至)*)*((\\d+|一|二|三|四|五|六|七|八|九|十|零|百|千)(楼|层))");
|
||||
static final Pattern BRACKET_PATTERN = Pattern.compile("(\\(|()+.+(\\)|))+");
|
||||
static final Pattern LOOP_LINE_PATTERN = Pattern.compile("((一|二|三|四|五|六|七|八|九|十|外|中|内)环(以内|以外)*)+(((到|至)*(一|二|三|四|五|六|七|八|九|十|外|中|内)环)*(之间)*)*");
|
||||
static final Pattern STAGE_PATTERN = Pattern.compile("((一|二|三|四|五|六|七|八|九|十)|\\d+)+期");
|
||||
static final Pattern PARTITION_PATTERN = Pattern.compile("(\\w|东|南|北|中|西|甲|乙|丙|丁|一|二|三|四|五|六|七|八|九|十)+区");
|
||||
static final Pattern INVALID_PATTERN = Pattern.compile("^(\\-|\\\\|、)+$");
|
||||
static final Pattern CHINESE_CONTAINS_DOT = Pattern.compile("[\\u4e00-\\u9fa5]+(·|\\.)+[\\u4e00-\\u9fa5]+");
|
||||
static final Pattern BUILDING_NUMBER_PATTERN = Pattern.compile("\\w+((号楼)|(#楼)|栋|幢|座|#)");
|
||||
static final Pattern ALL_LETTER_PATTERN = Pattern.compile("^\\w+$");
|
||||
public static int count = 0;
|
||||
|
||||
|
||||
static final HashMap<Character,Character> DIGITAL_MAP = new HashMap<Character, Character>(){{
|
||||
put('1','一'); put('壹','一'); put('I','一');
|
||||
put('2','二'); put('贰','二'); put('Ⅱ','一');
|
||||
put('3','三'); put('叁','三'); put('Ⅲ','一');
|
||||
put('4','四'); put('肆','四'); put('Ⅳ','一');
|
||||
put('5','五'); put('伍','五'); put('Ⅴ','一');
|
||||
put('6','六'); put('陆','六'); put('Ⅵ','一');
|
||||
put('7','七'); put('柒','七'); put('Ⅶ','一');
|
||||
put('8','八'); put('捌','八'); put('Ⅷ','一');
|
||||
put('9','九'); put('玖','九'); put('Ⅸ','一');
|
||||
put('0','零'); put('Ⅺ','零'); put('Ⅹ','十');
|
||||
put('1','一'); put('壹','一'); put('I','一');
|
||||
put('2','二'); put('贰','二'); put('Ⅱ','一');
|
||||
put('3','三'); put('叁','三'); put('Ⅲ','一');
|
||||
put('4','四'); put('肆','四'); put('Ⅳ','一');
|
||||
put('5','五'); put('伍','五'); put('Ⅴ','一');
|
||||
put('6','六'); put('陆','六'); put('Ⅵ','一');
|
||||
put('7','七'); put('柒','七'); put('Ⅶ','一');
|
||||
put('8','八'); put('捌','八'); put('Ⅷ','一');
|
||||
put('9','九'); put('玖','九'); put('Ⅸ','一');
|
||||
put('0','零'); put('Ⅺ','零'); put('Ⅹ','十');
|
||||
}};
|
||||
|
||||
|
||||
static final String[] PROVINCE_LIST = new String[]{"河北","河南","云南","辽宁","黑龙江","湖南","安徽","山东","新疆维吾尔","江苏","浙江","江西","湖北","广西","甘肃","山西","内蒙","陕西","吉林","福建","贵州","广东","青海","西藏","四川省","宁夏回族","海南","台湾"};
|
||||
static final String[] PROVINCE_LIST = new String[]{"河北","河南","云南","辽宁","黑龙江","湖南","安徽","山东","新疆维吾尔","江苏","浙江","江西","湖北","广西","甘肃","山西","内蒙","陕西","吉林","福建","贵州","广东","青海","西藏","四川省","宁夏回族","海南","台湾"};
|
||||
public static String extractProvince(String address){
|
||||
for(String p :PROVINCE_LIST){
|
||||
if(address.startsWith(p)){
|
||||
@@ -68,7 +68,7 @@ public class AddressParserUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否为无效字符
|
||||
* 判断字符串是否为无效字符
|
||||
* @param keywords
|
||||
* @return
|
||||
*/
|
||||
@@ -87,11 +87,11 @@ public class AddressParserUtil {
|
||||
}
|
||||
|
||||
public static String standardAddressAndName(String str){
|
||||
str = str.replace(".", "").replace("·","");
|
||||
str = str.replace(".", "").replace("·","");
|
||||
str = CNNMFilter.convertArabicToCnNumeric(str).replaceAll("\\s+$", "").replaceAll("^\\s+", "");
|
||||
return str;
|
||||
}
|
||||
static final Pattern NUMBER_PATTERN = Pattern.compile("[一二三四五六七八九十千百万]+");
|
||||
static final Pattern NUMBER_PATTERN = Pattern.compile("[一二三四五六七八九十千百万]+");
|
||||
|
||||
public static String toHanYuPinYin(String str){
|
||||
if(str == null){
|
||||
@@ -134,12 +134,12 @@ public class AddressParserUtil {
|
||||
if(match(SEPARATOR_PATTERN,removedUnitStr) != null && match(CONNECTOR_PATTERN, removedUnitStr) != null){
|
||||
streetNumbers.add(streetNumberStr);
|
||||
}else if(match(SEPARATOR_PATTERN,removedUnitStr) != null){
|
||||
String[] strings = removedUnitStr.split(",|、");
|
||||
String[] strings = removedUnitStr.split(",|、");
|
||||
for(String s:strings){
|
||||
streetNumbers.add(s + unit);
|
||||
}
|
||||
}else if(match(CONNECTOR_PATTERN, removedUnitStr) != null){
|
||||
String[] strings = removedUnitStr.split("~|-|~");
|
||||
String[] strings = removedUnitStr.split("~|-|~");
|
||||
int start = Integer.valueOf(strings[0]);
|
||||
int end = Integer.valueOf(strings[1]);
|
||||
if(end < start){
|
||||
@@ -147,7 +147,7 @@ public class AddressParserUtil {
|
||||
start = end;
|
||||
end = temp;
|
||||
}
|
||||
for(int i = start,count = 0;i <= end && count < 10 ; i++,count++){//最多只取10个街道号码
|
||||
for(int i = start,count = 0;i <= end && count < 10 ; i++,count++){//最多只取10个街道号码
|
||||
streetNumbers.add(i + unit);
|
||||
}
|
||||
}else{
|
||||
@@ -240,9 +240,9 @@ public class AddressParserUtil {
|
||||
if(result == null){
|
||||
return null;
|
||||
}else{
|
||||
int post = Math.abs(result.indexOf('号')*result.indexOf('栋')*result.indexOf('幢')*result.indexOf("单元"));
|
||||
int post = Math.abs(result.indexOf('号')*result.indexOf('栋')*result.indexOf('幢')*result.indexOf("单元"));
|
||||
if(post > 0){
|
||||
if(result.contains("单元")){
|
||||
if(result.contains("单元")){
|
||||
return result.substring(post+2);
|
||||
}else{
|
||||
return result.substring(post+1);
|
||||
@@ -301,20 +301,20 @@ public class AddressParserUtil {
|
||||
if(str == null){
|
||||
return null;
|
||||
}
|
||||
return str.replaceAll("(号楼)|(#楼)|栋|幢|座|(单元)|#","");
|
||||
return str.replaceAll("(号楼)|(#楼)|栋|幢|座|(单元)|#","");
|
||||
}
|
||||
|
||||
public static String standardizeRoomNumber(String roomNumber){
|
||||
if(StringUtils.isBlank(roomNumber)){
|
||||
return null;
|
||||
}
|
||||
return roomNumber.replaceAll("号|室","");
|
||||
return roomNumber.replaceAll("号|室","");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取两字符串的相似度
|
||||
* 获取两字符串的相似度
|
||||
* @param str
|
||||
* @param target
|
||||
* @return
|
||||
@@ -330,7 +330,7 @@ public class AddressParserUtil {
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取两字符串的相似度 新版
|
||||
* 获取两字符串的相似度 新版
|
||||
* @param first
|
||||
* @param second
|
||||
* @return
|
||||
@@ -345,10 +345,10 @@ public class AddressParserUtil {
|
||||
return ((double) (maxLength - computeEditDistance(first, second)))/maxLength;
|
||||
}
|
||||
|
||||
private static final Pattern STREET_NUMBER_END_PATTERN = Pattern.compile(".*[\\d+一二三四五六七八九十千百万零](?:号|弄|支弄).*");
|
||||
private static final Pattern STREET_NUMBER_END_PATTERN = Pattern.compile(".*[\\d+一二三四五六七八九十千百万零](?:号|弄|支弄).*");
|
||||
|
||||
/**
|
||||
* 判断地址是否以数字+号结尾
|
||||
* 判断地址是否以数字+号结尾
|
||||
*
|
||||
* @param address
|
||||
* @return
|
||||
@@ -362,7 +362,7 @@ public class AddressParserUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 用简单的方式来计算两字符串的相似度,结果为100分制
|
||||
* 用简单的方式来计算两字符串的相似度,结果为100分制
|
||||
* @param s1
|
||||
* @param s2
|
||||
* @return
|
||||
@@ -381,14 +381,14 @@ public class AddressParserUtil {
|
||||
|
||||
|
||||
public static int compare(String str, String target) {
|
||||
int d[][]; // 矩阵
|
||||
int d[][]; // 矩阵
|
||||
int n = str.length();
|
||||
int m = target.length();
|
||||
int i; // 遍历str的
|
||||
int j; // 遍历target的
|
||||
char ch1; // str的
|
||||
char ch2; // target的
|
||||
int temp; // 记录相同字符,在某个矩阵位置值的增量,不是0就是1
|
||||
int i; // 遍历str的
|
||||
int j; // 遍历target的
|
||||
char ch1; // str的
|
||||
char ch2; // target的
|
||||
int temp; // 记录相同字符,在某个矩阵位置值的增量,不是0就是1
|
||||
if (n == 0) {
|
||||
return m;
|
||||
}
|
||||
@@ -396,17 +396,17 @@ public class AddressParserUtil {
|
||||
return n;
|
||||
}
|
||||
d = new int[n + 1][m + 1];
|
||||
for (i = 0; i <= n; i++) { // 初始化第一列
|
||||
for (i = 0; i <= n; i++) { // 初始化第一列
|
||||
d[i][0] = i;
|
||||
}
|
||||
|
||||
for (j = 0; j <= m; j++) { // 初始化第一行
|
||||
for (j = 0; j <= m; j++) { // 初始化第一行
|
||||
d[0][j] = j;
|
||||
}
|
||||
|
||||
for (i = 1; i <= n; i++) { // 遍历str
|
||||
for (i = 1; i <= n; i++) { // 遍历str
|
||||
ch1 = str.charAt(i - 1);
|
||||
// 去匹配target
|
||||
// 去匹配target
|
||||
for (j = 1; j <= m; j++) {
|
||||
ch2 = target.charAt(j - 1);
|
||||
if (ch1 == ch2) {
|
||||
@@ -415,7 +415,7 @@ public class AddressParserUtil {
|
||||
temp = 1;
|
||||
}
|
||||
|
||||
// 左边+1,上边+1, 左上角+temp取最小
|
||||
// 左边+1,上边+1, 左上角+temp取最小
|
||||
d[i][j] = min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + temp);
|
||||
}
|
||||
}
|
||||
@@ -458,7 +458,7 @@ public class AddressParserUtil {
|
||||
return CharUtils.isAsciiAlpha(c) || CharUtils.isAsciiNumeric(c) || DIGITAL_MAP.containsKey(c) || DIGITAL_MAP.containsValue(c);
|
||||
}
|
||||
|
||||
static final List<String> STOP_WORDS = Arrays.asList("住宅");
|
||||
static final List<String> STOP_WORDS = Arrays.asList("住宅");
|
||||
|
||||
static String removeStopWord(String str){
|
||||
for(String stopWord : STOP_WORDS){
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.jar.JarFile;
|
||||
import com.fangjia.service.address.picker.Test;
|
||||
|
||||
/**
|
||||
* 类相关的工具类
|
||||
* 类相关的工具类
|
||||
*
|
||||
*/
|
||||
public class ClassUtil {
|
||||
@@ -28,19 +28,19 @@ public class ClassUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得某个接口下所有实现这个接口的类
|
||||
* 取得某个接口下所有实现这个接口的类
|
||||
* */
|
||||
public static List<Class> getAllClassByInterface(Class c) {
|
||||
List<Class> returnClassList = null;
|
||||
|
||||
// 获取当前的包名
|
||||
// 获取当前的包名
|
||||
String packageName = c.getPackage().getName();
|
||||
// 获取当前包下以及子包下所以的类
|
||||
// 获取当前包下以及子包下所以的类
|
||||
List<Class<?>> allClass = getClasses(packageName);
|
||||
if (allClass != null) {
|
||||
returnClassList = new ArrayList<Class>();
|
||||
for (Class classes : allClass) {
|
||||
// 本身不加入进去
|
||||
// 本身不加入进去
|
||||
if (!c.equals(classes)) {
|
||||
returnClassList.add(classes);
|
||||
}
|
||||
@@ -51,10 +51,10 @@ public class ClassUtil {
|
||||
}
|
||||
|
||||
/*
|
||||
* 取得某一类所在包的所有类名 不含迭代
|
||||
* 取得某一类所在包的所有类名 不含迭代
|
||||
*/
|
||||
public static String[] getPackageAllClassName(String classLocation, String packageName) {
|
||||
// 将packageName分解
|
||||
// 将packageName分解
|
||||
String[] packagePathSplit = packageName.split("[.]");
|
||||
String realClassLocation = classLocation;
|
||||
int packageLength = packagePathSplit.length;
|
||||
@@ -70,70 +70,70 @@ public class ClassUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 从包package中获取所有的Class
|
||||
* 从包package中获取所有的Class
|
||||
*
|
||||
* @param pack
|
||||
* @return
|
||||
*/
|
||||
public static List<Class<?>> getClasses(String packageName) {
|
||||
|
||||
// 第一个class类的集合
|
||||
// 第一个class类的集合
|
||||
List<Class<?>> classes = new ArrayList<Class<?>>();
|
||||
// 是否循环迭代
|
||||
// 是否循环迭代
|
||||
boolean recursive = true;
|
||||
// 获取包的名字 并进行替换
|
||||
// 获取包的名字 并进行替换
|
||||
String packageDirName = packageName.replace('.', '/');
|
||||
// 定义一个枚举的集合 并进行循环来处理这个目录下的things
|
||||
// 定义一个枚举的集合 并进行循环来处理这个目录下的things
|
||||
Enumeration<URL> dirs;
|
||||
try {
|
||||
dirs = Thread.currentThread().getContextClassLoader().getResources(packageDirName);
|
||||
// 循环迭代下去
|
||||
// 循环迭代下去
|
||||
while (dirs.hasMoreElements()) {
|
||||
// 获取下一个元素
|
||||
// 获取下一个元素
|
||||
URL url = dirs.nextElement();
|
||||
// 得到协议的名称
|
||||
// 得到协议的名称
|
||||
String protocol = url.getProtocol();
|
||||
// 如果是以文件的形式保存在服务器上
|
||||
// 如果是以文件的形式保存在服务器上
|
||||
if ("file".equals(protocol)) {
|
||||
// 获取包的物理路径
|
||||
// 获取包的物理路径
|
||||
String filePath = URLDecoder.decode(url.getFile(), "UTF-8");
|
||||
// 以文件的方式扫描整个包下的文件 并添加到集合中
|
||||
// 以文件的方式扫描整个包下的文件 并添加到集合中
|
||||
findAndAddClassesInPackageByFile(packageName, filePath, recursive, classes);
|
||||
} else if ("jar".equals(protocol)) {
|
||||
// 如果是jar包文件
|
||||
// 定义一个JarFile
|
||||
// 如果是jar包文件
|
||||
// 定义一个JarFile
|
||||
JarFile jar;
|
||||
try {
|
||||
// 获取jar
|
||||
// 获取jar
|
||||
jar = ((JarURLConnection) url.openConnection()).getJarFile();
|
||||
// 从此jar包 得到一个枚举类
|
||||
// 从此jar包 得到一个枚举类
|
||||
Enumeration<JarEntry> entries = jar.entries();
|
||||
// 同样的进行循环迭代
|
||||
// 同样的进行循环迭代
|
||||
while (entries.hasMoreElements()) {
|
||||
// 获取jar里的一个实体 可以是目录 和一些jar包里的其他文件 如META-INF等文件
|
||||
// 获取jar里的一个实体 可以是目录 和一些jar包里的其他文件 如META-INF等文件
|
||||
JarEntry entry = entries.nextElement();
|
||||
String name = entry.getName();
|
||||
// 如果是以/开头的
|
||||
// 如果是以/开头的
|
||||
if (name.charAt(0) == '/') {
|
||||
// 获取后面的字符串
|
||||
// 获取后面的字符串
|
||||
name = name.substring(1);
|
||||
}
|
||||
// 如果前半部分和定义的包名相同
|
||||
// 如果前半部分和定义的包名相同
|
||||
if (name.startsWith(packageDirName)) {
|
||||
int idx = name.lastIndexOf('/');
|
||||
// 如果以"/"结尾 是一个包
|
||||
// 如果以"/"结尾 是一个包
|
||||
if (idx != -1) {
|
||||
// 获取包名 把"/"替换成"."
|
||||
// 获取包名 把"/"替换成"."
|
||||
packageName = name.substring(0, idx).replace('/', '.');
|
||||
}
|
||||
// 如果可以迭代下去 并且是一个包
|
||||
// 如果可以迭代下去 并且是一个包
|
||||
if ((idx != -1) || recursive) {
|
||||
// 如果是一个.class文件 而且不是目录
|
||||
// 如果是一个.class文件 而且不是目录
|
||||
if (name.endsWith(".class") && !entry.isDirectory()) {
|
||||
// 去掉后面的".class" 获取真正的类名
|
||||
// 去掉后面的".class" 获取真正的类名
|
||||
String className = name.substring(packageName.length() + 1, name.length() - 6);
|
||||
try {
|
||||
// 添加到classes
|
||||
// 添加到classes
|
||||
classes.add(Class.forName(packageName + '.' + className));
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
@@ -155,7 +155,7 @@ public class ClassUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 以文件的形式来获取包下的所有Class
|
||||
* 以文件的形式来获取包下的所有Class
|
||||
*
|
||||
* @param packageName
|
||||
* @param packagePath
|
||||
@@ -164,29 +164,29 @@ public class ClassUtil {
|
||||
*/
|
||||
public static void findAndAddClassesInPackageByFile(String packageName, String packagePath, final boolean recursive,
|
||||
List<Class<?>> classes) {
|
||||
// 获取此包的目录 建立一个File
|
||||
// 获取此包的目录 建立一个File
|
||||
File dir = new File(packagePath);
|
||||
// 如果不存在或者 也不是目录就直接返回
|
||||
// 如果不存在或者 也不是目录就直接返回
|
||||
if (!dir.exists() || !dir.isDirectory()) {
|
||||
return;
|
||||
}
|
||||
// 如果存在 就获取包下的所有文件 包括目录
|
||||
// 如果存在 就获取包下的所有文件 包括目录
|
||||
File[] dirfiles = dir.listFiles(new FileFilter() {
|
||||
// 自定义过滤规则 如果可以循环(包含子目录) 或则是以.class结尾的文件(编译好的java类文件)
|
||||
// 自定义过滤规则 如果可以循环(包含子目录) 或则是以.class结尾的文件(编译好的java类文件)
|
||||
public boolean accept(File file) {
|
||||
return (recursive && file.isDirectory()) || (file.getName().endsWith(".class"));
|
||||
}
|
||||
});
|
||||
// 循环所有文件
|
||||
// 循环所有文件
|
||||
for (File file : dirfiles) {
|
||||
// 如果是目录 则继续扫描
|
||||
// 如果是目录 则继续扫描
|
||||
if (file.isDirectory()) {
|
||||
findAndAddClassesInPackageByFile(packageName + "." + file.getName(), file.getAbsolutePath(), recursive, classes);
|
||||
} else {
|
||||
// 如果是java类文件 去掉后面的.class 只留下类名
|
||||
// 如果是java类文件 去掉后面的.class 只留下类名
|
||||
String className = file.getName().substring(0, file.getName().length() - 6);
|
||||
try {
|
||||
// 添加到集合中去
|
||||
// 添加到集合中去
|
||||
classes.add(Class.forName(packageName + '.' + className));
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
+13
-13
@@ -5,39 +5,39 @@ import com.fangjia.dal.mongo.address.model.AddressAnalyticsResult;
|
||||
|
||||
public interface AddressAnalyticsResultService {
|
||||
/**
|
||||
* 根据任务ID查询分析之后的价格信息
|
||||
* 根据任务ID查询分析之后的价格信息
|
||||
* @author yinjihuan
|
||||
* @date 2016年6月27日
|
||||
* @param taskId 任务ID
|
||||
* @param curPage 当前页数
|
||||
* @param pageSize 页数大小
|
||||
* @date 2016年6月27日
|
||||
* @param taskId 任务ID
|
||||
* @param curPage 当前页数
|
||||
* @param pageSize 页数大小
|
||||
* @return
|
||||
*/
|
||||
public List<AddressAnalyticsResult> queryAddressAnalyticsResultByTaskId(String taskId, Integer curPage, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 根据任务ID查询分析之后的价格信息数量
|
||||
* 根据任务ID查询分析之后的价格信息数量
|
||||
* @author yinjihuan
|
||||
* @date 2016年6月27日
|
||||
* @date 2016年6月27日
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
public Integer queryAddressAnalyticsResultCountByTaskId(String taskId);
|
||||
|
||||
/**
|
||||
* 查询涨跌幅信息
|
||||
* 查询涨跌幅信息
|
||||
* @author yinjihuan
|
||||
* @date 2016年6月28日
|
||||
* @param taskId 任务ID
|
||||
* @param type 类型 rise涨 fall跌
|
||||
* @date 2016年6月28日
|
||||
* @param taskId 任务ID
|
||||
* @param type 类型 rise涨 fall跌
|
||||
* @return
|
||||
*/
|
||||
public Integer queryDistrictFloatInfo(String taskId, String type);
|
||||
|
||||
/**
|
||||
* 查询所有信息
|
||||
* 查询所有信息
|
||||
* @author yinjihuan
|
||||
* @date 2016年6月28日
|
||||
* @date 2016年6月28日
|
||||
* @return
|
||||
*/
|
||||
public List<AddressAnalyticsResult> queryAddressAnalyticsResults(String taskId);
|
||||
|
||||
+2
-2
@@ -5,9 +5,9 @@ import com.fangjia.dal.mongo.address.model.AddressRegionCount;
|
||||
|
||||
public interface AddressRegionCountService {
|
||||
/**
|
||||
* 根据任务ID和城市查询区域数量
|
||||
* 根据任务ID和城市查询区域数量
|
||||
* @author yinjihuan
|
||||
* @date 2016年6月27日
|
||||
* @date 2016年6月27日
|
||||
* @param taskId
|
||||
* @param city
|
||||
* @return
|
||||
|
||||
+3
-3
@@ -26,11 +26,11 @@ public abstract class AbstractAddressFormatter implements AddressFormatter{
|
||||
|
||||
@Override
|
||||
public boolean format(Address address) {
|
||||
/*不满指定的正则表达式不进行处理*/
|
||||
/*不满指定的正则表达式不进行处理*/
|
||||
if(DataUtil.match(address.getAddress(), pattern) == null){
|
||||
return false;
|
||||
}
|
||||
/*如果规则指定使用城市,如果城市条件不满足则不进行处理*/
|
||||
/*如果规则指定使用城市,如果城市条件不满足则不进行处理*/
|
||||
if(cities != null && !cities.contains(address.getCity())){
|
||||
return false;
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public abstract class AbstractAddressFormatter implements AddressFormatter{
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化地址
|
||||
* 格式化地址
|
||||
* @param address
|
||||
* @return
|
||||
*/
|
||||
|
||||
+3
-3
@@ -2,14 +2,14 @@ package com.fangjia.service.address.format;
|
||||
|
||||
import com.fangjia.service.address.mode.Address;
|
||||
/**
|
||||
* 華硊跡宒趙諉諳
|
||||
* 地址格式化接口
|
||||
*/
|
||||
public interface AddressFormatter {
|
||||
|
||||
/**
|
||||
* 跡宒趙華硊
|
||||
* 格式化地址
|
||||
* @param address
|
||||
* @return 瘁岆跡宒華硊
|
||||
* @return 否是格式地址
|
||||
*/
|
||||
boolean format(Address address);
|
||||
|
||||
|
||||
+84
-84
@@ -24,273 +24,273 @@ public class AddressFormatterFactory {
|
||||
|
||||
private void createFormatter(){
|
||||
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*[路街道巷]\\d+-\\d+-\\d+-\\d+.*")) {
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*[路街道巷]\\d+-\\d+-\\d+-\\d+.*")) {
|
||||
|
||||
final Pattern TARGET_PATTERN = Pattern.compile("(?<=[路街道巷])\\d+-\\d+-\\d+-\\d+");
|
||||
final Pattern TARGET_PATTERN = Pattern.compile("(?<=[路街道巷])\\d+-\\d+-\\d+-\\d+");
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
String targetStr = DataUtil.match(address, TARGET_PATTERN);
|
||||
String newStr = targetStr.replaceFirst("-", "号");
|
||||
String newStr = targetStr.replaceFirst("-", "号");
|
||||
return address.replace(targetStr, newStr);
|
||||
}
|
||||
});
|
||||
|
||||
/*兴源北路818B-1202 --> 兴源北路818号B单元1202室*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*[路|弄]\\d+[a-zA-Z]-\\d{3,4}$")) {
|
||||
/*兴源北路818B-1202 --> 兴源北路818号B单元1202室*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*[路|弄]\\d+[a-zA-Z]-\\d{3,4}$")) {
|
||||
|
||||
final Pattern TARGET_PATTERN = Pattern.compile("(?<=(路|号))\\d+[a-zA-Z]-\\d{3,4}$");
|
||||
final Pattern TARGET_PATTERN = Pattern.compile("(?<=(路|号))\\d+[a-zA-Z]-\\d{3,4}$");
|
||||
final Pattern NUMBER_PATTERN = Pattern.compile("^\\d+");
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
String targetStr = DataUtil.match(address, TARGET_PATTERN);
|
||||
String num = DataUtil.match(targetStr, NUMBER_PATTERN);
|
||||
String newStr = targetStr.replace(num, num + "号").replace("-", "单元") + "室";
|
||||
String newStr = targetStr.replace(num, num + "号").replace("-", "单元") + "室";
|
||||
return address.replace(targetStr, newStr);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/*洛社镇人民南路1-5-201 --> 洛社镇人民南路1号5栋201室*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*[路|弄]\\d+-\\d+-\\d{3,4}$")) {
|
||||
/*洛社镇人民南路1-5-201 --> 洛社镇人民南路1号5栋201室*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*[路|弄]\\d+-\\d+-\\d{3,4}$")) {
|
||||
|
||||
final Pattern TARGET_PATTERN = Pattern.compile("(?<=(路|号))\\d+-\\d+-\\d{3,4}$");
|
||||
final Pattern TARGET_PATTERN = Pattern.compile("(?<=(路|号))\\d+-\\d+-\\d{3,4}$");
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
String targetStr = DataUtil.match(address, TARGET_PATTERN);
|
||||
String newStr = targetStr.replace("-", "号").replace("-", "栋") + "室";
|
||||
String newStr = targetStr.replace("-", "号").replace("-", "栋") + "室";
|
||||
return address.replace(targetStr, newStr);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/*人民中路123-128 -->人民中路123号-3501号*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*(路|街|大道|巷|道|((零|一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)[线环条甲])|(胡同))(交汇|.{0,3}段|.*弄)?\\d+-\\d{3,4}(号)?$")) {
|
||||
/*人民中路123-128 -->人民中路123号-3501号*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*(路|街|大道|巷|道|((零|一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)[线环条甲])|(胡同))(交汇|.{0,3}段|.*弄)?\\d+-\\d{3,4}(号)?$")) {
|
||||
|
||||
final Pattern TARGET_PATTERN = Pattern.compile("(路|街|大道|巷|道|((零|一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)[线环条甲])|(胡同))(交汇|.{0,3}段|.*弄)?\\d+-\\d{3,4}(号)?$");
|
||||
final Pattern TARGET_PATTERN = Pattern.compile("(路|街|大道|巷|道|((零|一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)[线环条甲])|(胡同))(交汇|.{0,3}段|.*弄)?\\d+-\\d{3,4}(号)?$");
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
String targetStr = DataUtil.match(address, TARGET_PATTERN);
|
||||
if(targetStr.endsWith("号")){
|
||||
return address.replace(targetStr, targetStr.replace("-", "号-"));
|
||||
if(targetStr.endsWith("号")){
|
||||
return address.replace(targetStr, targetStr.replace("-", "号-"));
|
||||
}else{
|
||||
return address.replace(targetStr, targetStr.replace("-", "号-") + "号");
|
||||
return address.replace(targetStr, targetStr.replace("-", "号-") + "号");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/*御品华府5幢125单元2层204号*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*\\d+幢\\d+单元\\d+号$")) {
|
||||
/*御品华府5幢125单元2层204号*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*\\d+幢\\d+单元\\d+号$")) {
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
return address.replaceAll("号$", "室");
|
||||
return address.replaceAll("号$", "室");
|
||||
}
|
||||
});
|
||||
/*
|
||||
*晨晖路377 --> 晨晖路377号
|
||||
*唐家路44-12 --> 唐家路44-12号
|
||||
*晨晖路377 --> 晨晖路377号
|
||||
*唐家路44-12 --> 唐家路44-12号
|
||||
*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile("^.+(路|街道|街|大道|巷|道|((一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)线))(\\d+)([-~]\\d+)?$")) {
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile("^.+(路|街道|街|大道|巷|道|((一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)线))(\\d+)([-~]\\d+)?$")) {
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
return address + "号";
|
||||
return address + "号";
|
||||
}
|
||||
});
|
||||
/*
|
||||
*阜康西路51附近 --> 阜康西路51号附近
|
||||
*阜康西路51附近 --> 阜康西路51号附近
|
||||
*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile("^.+(路|街道|街|大道|巷|道|((一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)线)).*附\\d+$")) {
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile("^.+(路|街道|街|大道|巷|道|((一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)线)).*附\\d+$")) {
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
return address.replaceAll("附近$","号附近");
|
||||
return address.replaceAll("附近$","号附近");
|
||||
}
|
||||
});
|
||||
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*邮政编(号|码)(:|:|\\s)*\\d{5,}")) {
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*邮政编(号|码)(:|:|\\s)*\\d{5,}")) {
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
return address.replaceAll("邮政编(号|码)(:|:|\\s)*\\d{5,}", "");
|
||||
return address.replaceAll("邮政编(号|码)(:|:|\\s)*\\d{5,}", "");
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* 建新镇金榕北路与金林路交叉处观邸花园观澜2#楼1101单元 -> 建新镇金榕北路与金林路交叉处观邸花园观澜2#楼1101室
|
||||
* 武陵区皂果路富园小区C-3栋2301号 --> 武陵区皂果路富园小区C-3栋2301室
|
||||
* 建新镇金榕北路与金林路交叉处观邸花园观澜2#楼1101单元 -> 建新镇金榕北路与金林路交叉处观邸花园观澜2#楼1101室
|
||||
* 武陵区皂果路富园小区C-3栋2301号 --> 武陵区皂果路富园小区C-3栋2301室
|
||||
*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*((号楼)|(#楼)|栋|幢|座|#|楼|门|层)\\d{3,4}(单元|号房|号)$")) {
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*((号楼)|(#楼)|栋|幢|座|#|楼|门|层)\\d{3,4}(单元|号房|号)$")) {
|
||||
|
||||
final Pattern TARGET_PATTERN = Pattern.compile("(?<=((号楼)|(#楼)|栋|幢|座|#|楼|门|层))\\d+(单元|号房|号)$");
|
||||
final Pattern TARGET_PATTERN = Pattern.compile("(?<=((号楼)|(#楼)|栋|幢|座|#|楼|门|层))\\d+(单元|号房|号)$");
|
||||
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
String targetStr = DataUtil.match(address, TARGET_PATTERN);
|
||||
return address.replaceAll(targetStr, targetStr.replaceAll("(单元|号房|号)$", "室"));
|
||||
return address.replaceAll(targetStr, targetStr.replaceAll("(单元|号房|号)$", "室"));
|
||||
}
|
||||
});
|
||||
/*
|
||||
* 东部英郡假日广场栋2单元/座11层1102号房 --> 东部英郡假日广场栋2单元11层1102号房
|
||||
* 东部英郡假日广场栋2单元/座11层1102号房 --> 东部英郡假日广场栋2单元11层1102号房
|
||||
*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*单元/座.*")) {
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*单元/座.*")) {
|
||||
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
return address.replaceAll("单元/座", "单元");
|
||||
return address.replaceAll("单元/座", "单元");
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* 津南区小站镇福林庭苑10号楼-2-201 --> 津南区小站镇福林庭苑10号楼2单元-201室
|
||||
* 津南区小站镇福林庭苑10号楼-2-201 --> 津南区小站镇福林庭苑10号楼2单元-201室
|
||||
*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile("\\w+号楼-\\w-\\d+")) {
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile("\\w+号楼-\\w-\\d+")) {
|
||||
|
||||
final Pattern TARGET_PATTERN = Pattern.compile("\\w+号楼-.+-\\d+");
|
||||
final Pattern TARGET_PATTERN = Pattern.compile("\\w+号楼-.+-\\d+");
|
||||
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
String target = DataUtil.match(address, TARGET_PATTERN);
|
||||
String[] fragment = target.replace("号楼", "").split("-");
|
||||
String formatStr = fragment[0] + "栋" + fragment[1] + "单元" + fragment[2] + "室";
|
||||
String[] fragment = target.replace("号楼", "").split("-");
|
||||
String formatStr = fragment[0] + "栋" + fragment[1] + "单元" + fragment[2] + "室";
|
||||
return address.replace(target, formatStr);
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* 武侯区新希望路7号2层2号 --> 武侯区新希望路7号2层2室
|
||||
* 武侯区新希望路7号2层2号 --> 武侯区新希望路7号2层2室
|
||||
*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*\\d+层\\w+(号|房).*")) {
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*\\d+层\\w+(号|房).*")) {
|
||||
|
||||
final Pattern TARGET_PATTERN = Pattern.compile("(?<=层)\\w+[号房]+");
|
||||
final Pattern TARGET_PATTERN = Pattern.compile("(?<=层)\\w+[号房]+");
|
||||
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
String target = DataUtil.match(address, TARGET_PATTERN);
|
||||
String formatStr = target.replaceAll("[号房]+", "室");
|
||||
String formatStr = target.replaceAll("[号房]+", "室");
|
||||
return address.replace(target, formatStr);
|
||||
}
|
||||
});
|
||||
/**
|
||||
* 诸暨国用(2010)第00700444号
|
||||
* 诸暨国用(2010)第00700444号
|
||||
*
|
||||
* */
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*第(\\d{6,}-)?\\d{6,}号.*")) {
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*第(\\d{6,}-)?\\d{6,}号.*")) {
|
||||
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
return address.replaceAll("第(\\d{6,}-)?\\d{6,}号", "");
|
||||
return address.replaceAll("第(\\d{6,}-)?\\d{6,}号", "");
|
||||
}
|
||||
|
||||
});
|
||||
/**
|
||||
* 瑞安市城关镇安阳A区清莲小区13幢1-401室
|
||||
* 瑞安市城关镇安阳A区清莲小区13幢1-401室
|
||||
* */
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*幢\\w+-\\d{2,4}室.*")) {
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*幢\\w+-\\d{2,4}室.*")) {
|
||||
|
||||
final Pattern TARGET = Pattern.compile("幢\\w+-\\d{2,4}室");
|
||||
final Pattern TARGET = Pattern.compile("幢\\w+-\\d{2,4}室");
|
||||
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
String matchStr = DataUtil.match(address, TARGET);
|
||||
return address.replaceAll(matchStr, matchStr.replace("-", "单元"));
|
||||
return address.replaceAll(matchStr, matchStr.replace("-", "单元"));
|
||||
}
|
||||
|
||||
});
|
||||
/**
|
||||
* 城关区雁滩乡天庆嘉园9-2-1002号
|
||||
* 城关区雁滩乡天庆嘉园9-2-1002号
|
||||
*
|
||||
*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*\\w+-\\w+-\\d{1,4}号.*")) {
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*\\w+-\\w+-\\d{1,4}号.*")) {
|
||||
|
||||
final Pattern TARGET = Pattern.compile("\\w+-\\w+-\\d{1,4}号");
|
||||
final Pattern TARGET = Pattern.compile("\\w+-\\w+-\\d{1,4}号");
|
||||
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
String matchStr = DataUtil.match(address, TARGET);
|
||||
String formatStr = matchStr.replaceFirst("-", "栋")
|
||||
.replaceFirst("-","单元").replaceFirst("号", "室");
|
||||
String formatStr = matchStr.replaceFirst("-", "栋")
|
||||
.replaceFirst("-","单元").replaceFirst("号", "室");
|
||||
return address.replace(matchStr,formatStr);
|
||||
}
|
||||
});
|
||||
/**
|
||||
* 秦州区岷山路88号畅和居5-201号
|
||||
* 秦州区岷山路88号畅和居5-201号
|
||||
*
|
||||
*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*\\w+-\\d{3,4}号$")) {
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*\\w+-\\d{3,4}号$")) {
|
||||
|
||||
final Pattern TARGET = Pattern.compile("\\w+-\\d{3,4}号");
|
||||
final Pattern TARGET = Pattern.compile("\\w+-\\d{3,4}号");
|
||||
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
String matchStr = DataUtil.match(address, TARGET);
|
||||
String formatStr = matchStr.replaceFirst("-", "栋").replaceFirst("号", "室");
|
||||
String formatStr = matchStr.replaceFirst("-", "栋").replaceFirst("号", "室");
|
||||
return address.replace(matchStr,formatStr);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 梓园第营业房幢00单元000107号 --> 梓园第营业房幢00单元107室
|
||||
* 梓园第营业房幢00单元000107号 --> 梓园第营业房幢00单元107室
|
||||
*
|
||||
*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*单元0*\\d{3,4}号.*")) {
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*单元0*\\d{3,4}号.*")) {
|
||||
|
||||
final Pattern TARGET = Pattern.compile("单元0*\\d{3,4}号");
|
||||
final Pattern TARGET = Pattern.compile("单元0*\\d{3,4}号");
|
||||
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
String matchStr = DataUtil.match(address, TARGET);
|
||||
String formatStr = matchStr.replaceFirst("单元0+", "单元").replaceFirst("号", "室");
|
||||
String formatStr = matchStr.replaceFirst("单元0+", "单元").replaceFirst("号", "室");
|
||||
return address.replace(matchStr,formatStr);
|
||||
}
|
||||
});
|
||||
/**
|
||||
* 泗州大街北侧(衡山花园)29幢3-606
|
||||
* 泗州大街北侧(衡山花园)29幢3-606
|
||||
*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*幢\\w+-\\d{3,4}.*")) {
|
||||
final Pattern TARGET = Pattern.compile("幢\\w+-\\d{3,4}");
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*幢\\w+-\\d{3,4}.*")) {
|
||||
final Pattern TARGET = Pattern.compile("幢\\w+-\\d{3,4}");
|
||||
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
String matchStr = DataUtil.match(address, TARGET);
|
||||
String formatStr = matchStr.replace("-", "单元");
|
||||
String formatStr = matchStr.replace("-", "单元");
|
||||
return address.replace(matchStr,formatStr);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 一环路东二段162
|
||||
* 一环路东二段162
|
||||
*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*(路|街|大道|巷|道|((零|一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)[线环条甲])|(胡同))(交汇|.{0,3}段|.*弄)?((([零一二三四五六七八九十百千\\d])+弄)|([甲乙]?\\d+$))")) {
|
||||
final Pattern TARGET = Pattern.compile("(路|街|大道|巷|道|((零|一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)[线环条甲])|(胡同))(交汇|.{0,3}段|.*弄)?((([零一二三四五六七八九十百千\\d])+弄)|([甲乙]?\\d+$))");
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*(路|街|大道|巷|道|((零|一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)[线环条甲])|(胡同))(交汇|.{0,3}段|.*弄)?((([零一二三四五六七八九十百千\\d])+弄)|([甲乙]?\\d+$))")) {
|
||||
final Pattern TARGET = Pattern.compile("(路|街|大道|巷|道|((零|一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)[线环条甲])|(胡同))(交汇|.{0,3}段|.*弄)?((([零一二三四五六七八九十百千\\d])+弄)|([甲乙]?\\d+$))");
|
||||
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
String matchStr = DataUtil.match(address, TARGET);
|
||||
String formatStr = matchStr.replaceAll("段-","段");
|
||||
if(!matchStr.endsWith("号")){
|
||||
formatStr += "号";
|
||||
String formatStr = matchStr.replaceAll("段-","段");
|
||||
if(!matchStr.endsWith("号")){
|
||||
formatStr += "号";
|
||||
}
|
||||
return address.replace(matchStr,formatStr);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 剑南路东段-12号-18号
|
||||
* 剑南路东段-12号-18号
|
||||
*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*(路|街|大道|巷|道|((零|一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)[线环条甲])|(胡同))(交汇|.{0,3}段|.*弄)?((([零一二三四五六七八九十百千\\d])+弄)|([甲乙-]?\\d+[号](附\\d+(号)?(-\\d+(号)?)?)?([-][附付、]?\\d+(号(附近)?)?)?))")) {
|
||||
final Pattern TARGET = Pattern.compile("(路|街|大道|巷|道|((零|一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)[线环条甲])|(胡同))(交汇|.{0,3}段|.*弄)?((([零一二三四五六七八九十百千\\d])+弄)|([甲乙-]?\\d+[号](附\\d+(号)?(-\\d+(号)?)?)?([-][附付、]?\\d+(号(附近)?)?)?))");
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile(".*(路|街|大道|巷|道|((零|一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)[线环条甲])|(胡同))(交汇|.{0,3}段|.*弄)?((([零一二三四五六七八九十百千\\d])+弄)|([甲乙-]?\\d+[号](附\\d+(号)?(-\\d+(号)?)?)?([-][附付、]?\\d+(号(附近)?)?)?))")) {
|
||||
final Pattern TARGET = Pattern.compile("(路|街|大道|巷|道|((零|一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)[线环条甲])|(胡同))(交汇|.{0,3}段|.*弄)?((([零一二三四五六七八九十百千\\d])+弄)|([甲乙-]?\\d+[号](附\\d+(号)?(-\\d+(号)?)?)?([-][附付、]?\\d+(号(附近)?)?)?))");
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
String matchStr = DataUtil.match(address, TARGET);
|
||||
String formatStr = matchStr;
|
||||
if(!matchStr.endsWith("号")){
|
||||
formatStr += "号";
|
||||
if(!matchStr.endsWith("号")){
|
||||
formatStr += "号";
|
||||
}
|
||||
return address.replace(matchStr,formatStr);
|
||||
}
|
||||
});
|
||||
/**
|
||||
* 剑南路东段-12号-18号
|
||||
* 剑南路东段-12号-18号
|
||||
*/
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile("(((路|街|大道|巷|道|段|附|付)-)|(-(附|付)))")) {
|
||||
final Pattern TARGET = Pattern.compile("(((路|街|大道|巷|道|段|附|付)-)|(-(附|付)))");
|
||||
formatters.add(new AbstractAddressFormatter(Pattern.compile("(((路|街|大道|巷|道|段|附|付)-)|(-(附|付)))")) {
|
||||
final Pattern TARGET = Pattern.compile("(((路|街|大道|巷|道|段|附|付)-)|(-(附|付)))");
|
||||
@Override
|
||||
protected String doFormat(String address) {
|
||||
String matchStr = DataUtil.match(address, TARGET);
|
||||
|
||||
+4
-4
@@ -1,18 +1,18 @@
|
||||
package com.fangjia.service.address.mode;
|
||||
|
||||
/**
|
||||
* 提供一些通用方法
|
||||
* 提供一些通用方法
|
||||
*
|
||||
* @author yk
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractAddressModeParser implements AddressModeParser {
|
||||
// 为效率,以下方法都没做参数检查,调用处要确保传入参数不为null
|
||||
// 为效率,以下方法都没做参数检查,调用处要确保传入参数不为null
|
||||
protected boolean isRoad(String s) {
|
||||
return s.startsWith("路") || s.startsWith("镇") || s.startsWith("大道");
|
||||
return s.startsWith("路") || s.startsWith("镇") || s.startsWith("大道");
|
||||
}
|
||||
|
||||
protected boolean isRoadNum(String s) {
|
||||
return "号".equals(s) || "弄".equals(s);
|
||||
return "号".equals(s) || "弄".equals(s);
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -10,7 +10,7 @@ import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* 地址结构化对象
|
||||
* 地址结构化对象
|
||||
* @author wenyan
|
||||
*/
|
||||
public class Address {
|
||||
@@ -77,11 +77,11 @@ public class Address {
|
||||
private String parsedPropertyName;
|
||||
private List<String> certified = new ArrayList<String>();
|
||||
private Map<String, String> standardAddressMap = new LinkedHashMap<String, String>();
|
||||
/**调试时断点小区名*/
|
||||
/**调试时断点小区名*/
|
||||
private String debugName;
|
||||
|
||||
private AliyunBo aliyunBo;
|
||||
//使用CRF切分的地址
|
||||
//使用CRF切分的地址
|
||||
private String crfAddress;
|
||||
|
||||
public String getCrfAddress() {
|
||||
@@ -100,7 +100,7 @@ public class Address {
|
||||
this.addressParserGoal = addressParserGoal;
|
||||
}
|
||||
|
||||
/**地址解析目的*/
|
||||
/**地址解析目的*/
|
||||
private AddressParserGoal addressParserGoal;
|
||||
public AliyunBo getAliyunBo() {
|
||||
return aliyunBo;
|
||||
@@ -112,7 +112,7 @@ public class Address {
|
||||
|
||||
|
||||
/**
|
||||
* 判断地址是否是一个标准地址
|
||||
* 判断地址是否是一个标准地址
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -141,7 +141,7 @@ public class Address {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(getStreet()) && getStreet().endsWith("弄")){
|
||||
if(StringUtils.isNotBlank(getStreet()) && getStreet().endsWith("弄")){
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
@@ -226,19 +226,19 @@ public class Address {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据地址信息猜测可能的建筑类型
|
||||
* 根据地址信息猜测可能的建筑类型
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public BuildingType[] guessBuildType() {
|
||||
|
||||
if (orgAddress.contains("办公楼") || orgAddress.contains("商务楼") || orgAddress.contains("写字楼") || orgAddress.contains("商务中心")) {
|
||||
if (orgAddress.contains("办公楼") || orgAddress.contains("商务楼") || orgAddress.contains("写字楼") || orgAddress.contains("商务中心")) {
|
||||
return new BuildingType[]{BuildingType.OFFICE};
|
||||
}
|
||||
if (orgAddress.contains("商铺") || orgAddress.contains("商场") || orgAddress.contains("购物")) {
|
||||
if (orgAddress.contains("商铺") || orgAddress.contains("商场") || orgAddress.contains("购物")) {
|
||||
return new BuildingType[]{BuildingType.SHOP};
|
||||
}
|
||||
if (orgAddress.contains("小区") || orgAddress.contains("村") || orgAddress.contains("庄")) {
|
||||
if (orgAddress.contains("小区") || orgAddress.contains("村") || orgAddress.contains("庄")) {
|
||||
return new BuildingType[]{BuildingType.DISTRICT};
|
||||
}
|
||||
return BuildingType.values();
|
||||
@@ -400,7 +400,7 @@ public class Address {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得有效地址
|
||||
* 获得有效地址
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -412,7 +412,7 @@ public class Address {
|
||||
orgAddress = orgAddress.toUpperCase();
|
||||
setAddress(orgAddress);
|
||||
if(this.orgAddress != null){
|
||||
throw new UnsupportedOperationException("原始地址不能被修改");
|
||||
throw new UnsupportedOperationException("原始地址不能被修改");
|
||||
}else{
|
||||
this.orgAddress = orgAddress;
|
||||
}
|
||||
|
||||
+15
-15
@@ -9,7 +9,7 @@ import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 地址匹配元数据
|
||||
* 地址匹配元数据
|
||||
*/
|
||||
public class AddressMatchMetaData {
|
||||
|
||||
@@ -19,25 +19,25 @@ public class AddressMatchMetaData {
|
||||
public static final String PIN_YIN_SEPARATOR = " ";
|
||||
|
||||
private String id;
|
||||
/**小区主名*/
|
||||
/**小区主名*/
|
||||
private String mainName;
|
||||
/**小区地址*/
|
||||
/**小区地址*/
|
||||
private String address;
|
||||
/**小区所在区域*/
|
||||
/**小区所在区域*/
|
||||
private String district;
|
||||
/**小区所在城市*/
|
||||
/**小区所在城市*/
|
||||
private String city;
|
||||
/**名称拼音映射表*/
|
||||
/**名称拼音映射表*/
|
||||
private Map<String,MatchText> namesPinYinMap = new IdentityHashMap<String,MatchText>();
|
||||
/**POI类型*/
|
||||
/**POI类型*/
|
||||
private BuildingType buildingType;
|
||||
/**地址拼音映射表*/
|
||||
/**地址拼音映射表*/
|
||||
private Map<String,MatchText> addrePinYinMap = new IdentityHashMap<String,MatchText>();
|
||||
/**POI来源**/
|
||||
/**POI来源**/
|
||||
private MetaDataType metaDataType;
|
||||
/**物业类型*/
|
||||
/**物业类型*/
|
||||
private PropertyType propertyType;
|
||||
/**使用高德地图时地图返回的类型*/
|
||||
/**使用高德地图时地图返回的类型*/
|
||||
private String type;
|
||||
private Double score;
|
||||
private Double lng;
|
||||
@@ -83,13 +83,13 @@ public class AddressMatchMetaData {
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是垃圾小区名
|
||||
* 是否是垃圾小区名
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
private boolean isDirty(String name){
|
||||
if(name.length() < 2){
|
||||
logger.info("发现来垃圾小区名:{ city:" + city + ", name:" + name + ", mainName: " + mainName + "}");
|
||||
logger.info("发现来垃圾小区名:{ city:" + city + ", name:" + name + ", mainName: " + mainName + "}");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -97,9 +97,9 @@ public class AddressMatchMetaData {
|
||||
|
||||
|
||||
|
||||
final static List<Pattern> DIRTY_ADDRESS_PATTERNS = Arrays.asList(Pattern.compile("^\\d+号院$"));
|
||||
final static List<Pattern> DIRTY_ADDRESS_PATTERNS = Arrays.asList(Pattern.compile("^\\d+号院$"));
|
||||
/**
|
||||
* 是否是垃圾地址
|
||||
* 是否是垃圾地址
|
||||
* @param address
|
||||
* @return
|
||||
*/
|
||||
|
||||
+6
-6
@@ -5,22 +5,22 @@ import java.util.Map;
|
||||
import com.fangjia.service.address.AddressAnalyseResultKeyEnum;
|
||||
|
||||
/**
|
||||
* 基于模式的地址解析接口<br/>
|
||||
* 基于模式的地址解析接口<br/>
|
||||
*
|
||||
* @author yk
|
||||
*
|
||||
*/
|
||||
public interface AddressModeParser {
|
||||
/**
|
||||
* 进行解析
|
||||
* 进行解析
|
||||
*
|
||||
* @param orgCity
|
||||
* 输入的原始城市
|
||||
* 输入的原始城市
|
||||
* @param orgAddress
|
||||
* 输入的原始地址
|
||||
* 输入的原始地址
|
||||
* @param ret
|
||||
* key值定义见 {@link AddressAnalyseResultKeyEnum}<br/>
|
||||
* 解析时,map中传入原始输入地址,key为
|
||||
* key值定义见 {@link AddressAnalyseResultKeyEnum}<br/>
|
||||
* 解析时,map中传入原始输入地址,key为
|
||||
* {@link AddressAnalyseResultKeyEnum.orgAddress}
|
||||
*/
|
||||
public void doParse(String orgCity, String orgAddress, Map<String, Object> ret);
|
||||
|
||||
+2
-2
@@ -8,9 +8,9 @@ import org.apache.commons.collections.CollectionUtils;
|
||||
import com.fangjia.service.address.AddressAnalyseResultKeyEnum;
|
||||
|
||||
/**
|
||||
* 基于模式的地址解析链条<br>
|
||||
* 基于模式的地址解析链条<br>
|
||||
*
|
||||
* 半成品,没有仔细调测过
|
||||
* 半成品,没有仔细调测过
|
||||
*
|
||||
* @author yk
|
||||
*
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package com.fangjia.service.address.mode;
|
||||
|
||||
/**
|
||||
* 地址解析的目的
|
||||
* 地址解析的目的
|
||||
* @author wenyan
|
||||
*/
|
||||
public enum AddressParserGoal {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import com.fangjia.service.address.AddressParserUtil;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author ÍõÎÄÑÞ
|
||||
* @author 王文艳
|
||||
* @create 2016-11-23
|
||||
**/
|
||||
public class AddressScoreResult {
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import com.fangjia.core.BlockData;
|
||||
import com.fangjia.service.address.AddressAnalyseResultKeyEnum;
|
||||
|
||||
/**
|
||||
* °å¿é½âÎö
|
||||
* 板块解析
|
||||
*
|
||||
* @author yk
|
||||
*
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package com.fangjia.service.address.mode;
|
||||
|
||||
/**
|
||||
* ½¨ÖþÎïÀàÐÍ
|
||||
* 建筑物类型
|
||||
* @author wenyan
|
||||
*/
|
||||
public enum BuildingType {
|
||||
|
||||
+26
-26
@@ -5,37 +5,37 @@ import org.apache.commons.lang.StringUtils;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author 王文艳
|
||||
* @author 王文艳
|
||||
* @create 2016-11-09
|
||||
**/
|
||||
public class CityData {
|
||||
|
||||
static final Map<String, List<String>> data = new HashMap<String, List<String>>() {{
|
||||
|
||||
put("文山州", Arrays.asList("文山壮族苗族自治州"));
|
||||
put("凉山州", Arrays.asList("凉山彝族自治州"));
|
||||
// put("呼和浩特", Arrays.asList("呼市"));
|
||||
// put("乌鲁木齐", Arrays.asList("乌市"));
|
||||
put("阿里", Arrays.asList("阿里地区"));
|
||||
put("红河", Arrays.asList("红河哈尼族彝族自治州"));
|
||||
put("克孜勒苏", Arrays.asList("克孜勒苏柯尔克孜自治州", "克州"));
|
||||
put("巴音郭楞", Arrays.asList("巴音郭楞蒙古自治州", "巴州"));
|
||||
put("博尔塔拉", Arrays.asList("博尔塔拉蒙古自治州", "博州"));
|
||||
put("阿勒泰", Arrays.asList("阿勒泰地区"));
|
||||
put("昌吉", Arrays.asList("昌吉回族自治州"));
|
||||
put("西双版纳州", Arrays.asList("西双版纳傣族自治州"));
|
||||
put("德宏州", Arrays.asList("德宏傣族景颇族自治州"));
|
||||
put("喀什", Arrays.asList("喀什噶尔", "喀什地区"));
|
||||
put("恩施", Arrays.asList("恩施土家族苗族自治州", "恩施州"));
|
||||
put("塔尔", Arrays.asList("塔尔巴哈台城"));
|
||||
put("黔南", Arrays.asList("黔南布依族苗族自治州", "黔南州"));
|
||||
put("迪庆州", Arrays.asList("迪庆藏族自治州"));
|
||||
put("白沙", Arrays.asList("白沙黎族自治县"));
|
||||
put("昌江", Arrays.asList("昌江黎族自治县"));
|
||||
put("乐东", Arrays.asList("乐东黎族自治县"));
|
||||
put("陵水", Arrays.asList("陵水黎族自治县"));
|
||||
put("保亭", Arrays.asList("保亭黎族苗族自治县"));
|
||||
put("琼中", Arrays.asList("琼中黎族苗族自治县"));
|
||||
put("文山州", Arrays.asList("文山壮族苗族自治州"));
|
||||
put("凉山州", Arrays.asList("凉山彝族自治州"));
|
||||
// put("呼和浩特", Arrays.asList("呼市"));
|
||||
// put("乌鲁木齐", Arrays.asList("乌市"));
|
||||
put("阿里", Arrays.asList("阿里地区"));
|
||||
put("红河", Arrays.asList("红河哈尼族彝族自治州"));
|
||||
put("克孜勒苏", Arrays.asList("克孜勒苏柯尔克孜自治州", "克州"));
|
||||
put("巴音郭楞", Arrays.asList("巴音郭楞蒙古自治州", "巴州"));
|
||||
put("博尔塔拉", Arrays.asList("博尔塔拉蒙古自治州", "博州"));
|
||||
put("阿勒泰", Arrays.asList("阿勒泰地区"));
|
||||
put("昌吉", Arrays.asList("昌吉回族自治州"));
|
||||
put("西双版纳州", Arrays.asList("西双版纳傣族自治州"));
|
||||
put("德宏州", Arrays.asList("德宏傣族景颇族自治州"));
|
||||
put("喀什", Arrays.asList("喀什噶尔", "喀什地区"));
|
||||
put("恩施", Arrays.asList("恩施土家族苗族自治州", "恩施州"));
|
||||
put("塔尔", Arrays.asList("塔尔巴哈台城"));
|
||||
put("黔南", Arrays.asList("黔南布依族苗族自治州", "黔南州"));
|
||||
put("迪庆州", Arrays.asList("迪庆藏族自治州"));
|
||||
put("白沙", Arrays.asList("白沙黎族自治县"));
|
||||
put("昌江", Arrays.asList("昌江黎族自治县"));
|
||||
put("乐东", Arrays.asList("乐东黎族自治县"));
|
||||
put("陵水", Arrays.asList("陵水黎族自治县"));
|
||||
put("保亭", Arrays.asList("保亭黎族苗族自治县"));
|
||||
put("琼中", Arrays.asList("琼中黎族苗族自治县"));
|
||||
|
||||
|
||||
}};
|
||||
@@ -89,7 +89,7 @@ public class CityData {
|
||||
if(StringUtils.isBlank(address)){
|
||||
return false;
|
||||
}
|
||||
if(address.contains("自治州") || address.contains("自治县") || address.contains("地区")){
|
||||
if(address.contains("自治州") || address.contains("自治县") || address.contains("地区")){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
+6
-6
@@ -12,7 +12,7 @@ import com.fangjia.dal.mongo.fangjia.model.ServerArea;
|
||||
import com.fangjia.service.address.AddressAnalyseResultKeyEnum;
|
||||
|
||||
/**
|
||||
* 城市解析
|
||||
* 城市解析
|
||||
*
|
||||
* @author yk
|
||||
*
|
||||
@@ -22,18 +22,18 @@ public class CityParser extends AbstractAddressModeParser {
|
||||
@Override
|
||||
public void doParse(String orgCity, String orgAddress, Map<String, Object> ret) {
|
||||
String city = orgCity;
|
||||
// 省、市map
|
||||
// 省、市map
|
||||
Map<String, String> cityMap = new HashMap<String, String>();
|
||||
for (ServerArea serverArea : ServerAreaData.values()) {
|
||||
cityMap.put(serverArea.getDisplay(), serverArea.getProvince());
|
||||
}
|
||||
|
||||
Set<String> set = cityMap.keySet();
|
||||
if (orgAddress.indexOf("市") > 0) {
|
||||
city = orgAddress.substring(0, orgAddress.indexOf("市"));
|
||||
if (orgAddress.indexOf("市") > 0) {
|
||||
city = orgAddress.substring(0, orgAddress.indexOf("市"));
|
||||
|
||||
if (set.contains(city)) {
|
||||
orgAddress = orgAddress.replaceAll("^(" + city + "市)+", "").replaceAll("^(" + city + ")+", "");
|
||||
orgAddress = orgAddress.replaceAll("^(" + city + "市)+", "").replaceAll("^(" + city + ")+", "");
|
||||
|
||||
ret.put(AddressAnalyseResultKeyEnum.city.name(), city);
|
||||
// ret.put(AddressAnalyseResultKeyEnum.province.name(),
|
||||
@@ -55,7 +55,7 @@ public class CityParser extends AbstractAddressModeParser {
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(city)) {
|
||||
orgAddress = orgAddress.replaceAll("^(" + city + "市)+", "").replaceAll("^(" + city + ")+", "");
|
||||
orgAddress = orgAddress.replaceAll("^(" + city + "市)+", "").replaceAll("^(" + city + ")+", "");
|
||||
|
||||
ret.put(AddressAnalyseResultKeyEnum.city.name(), city);
|
||||
// ret.put(AddressAnalyseResultKeyEnum.province.name(),
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
package com.fangjia.service.address.mode;
|
||||
|
||||
/**
|
||||
* 城市匹配状态定义
|
||||
* 城市匹配状态定义
|
||||
* @author wenyan
|
||||
*/
|
||||
public enum CityStatus {
|
||||
SURE,/**确定城市正确*/
|
||||
UN_SURE_DEFINITE; /**不确定状态*/
|
||||
SURE,/**确定城市正确*/
|
||||
UN_SURE_DEFINITE; /**不确定状态*/
|
||||
}
|
||||
|
||||
+6
-6
@@ -9,12 +9,12 @@ import org.apache.commons.lang.StringUtils;
|
||||
import com.fangjia.service.address.AddressAnalyseResultKeyEnum;
|
||||
|
||||
public class DetailParser extends AbstractAddressModeParser {
|
||||
private static final Pattern HOUSE_P1 = Pattern.compile("([a-zA-Z\\d\\-负一二三四五六七八九十零壹两个百千万亿]+)(#|号楼|号|弄|幢|橦|栋|座)");
|
||||
private static final Pattern HOUSE_P2 = Pattern.compile("([东南西北]楼)");
|
||||
private static final Pattern UNIT_P = Pattern.compile("([a-zA-Z\\d\\-负一二三四五六七八九十零壹两个百千万亿]+)(单元|门)");
|
||||
private static final Pattern FLOOR_P = Pattern.compile("([a-zA-Z\\d\\-负一二三四五六七八九十零壹两个百千万亿]+)[楼层fF]");
|
||||
private static final Pattern ROOM_P1 = Pattern.compile("([a-zA-Z\\d\\-负一二三四五六七八九十零壹两个百千万亿]+)[室房]");
|
||||
private static final Pattern ROOM_P2 = Pattern.compile("([a-zA-Z\\d\\-负一二三四五六七八九十零壹两个百千万亿]+)$");
|
||||
private static final Pattern HOUSE_P1 = Pattern.compile("([a-zA-Z\\d\\-负一二三四五六七八九十零壹两个百千万亿]+)(#|号楼|号|弄|幢|橦|栋|座)");
|
||||
private static final Pattern HOUSE_P2 = Pattern.compile("([东南西北]楼)");
|
||||
private static final Pattern UNIT_P = Pattern.compile("([a-zA-Z\\d\\-负一二三四五六七八九十零壹两个百千万亿]+)(单元|门)");
|
||||
private static final Pattern FLOOR_P = Pattern.compile("([a-zA-Z\\d\\-负一二三四五六七八九十零壹两个百千万亿]+)[楼层fF]");
|
||||
private static final Pattern ROOM_P1 = Pattern.compile("([a-zA-Z\\d\\-负一二三四五六七八九十零壹两个百千万亿]+)[室房]");
|
||||
private static final Pattern ROOM_P2 = Pattern.compile("([a-zA-Z\\d\\-负一二三四五六七八九十零壹两个百千万亿]+)$");
|
||||
|
||||
@Override
|
||||
public void doParse(String orgCity, String orgAddress, Map<String, Object> ret) {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package com.fangjia.service.address.mode;
|
||||
|
||||
/**
|
||||
* Îı¾È¨ÖØ
|
||||
* 文本权重
|
||||
*/
|
||||
public class FragmentWeight implements Comparable<FragmentWeight>{
|
||||
|
||||
|
||||
+14
-14
@@ -1,31 +1,31 @@
|
||||
package com.fangjia.service.address.mode;
|
||||
|
||||
/**
|
||||
* 地址匹配参数封装
|
||||
* 地址匹配参数封装
|
||||
*/
|
||||
public class MatchParams {
|
||||
/**省份*/
|
||||
/**省份*/
|
||||
private String province;
|
||||
/**城市*/
|
||||
/**城市*/
|
||||
private String city;
|
||||
/**建议所在区域,当preciseLevel为PreciseLevel.STRICT时,强制验证区域*/
|
||||
/**建议所在区域,当preciseLevel为PreciseLevel.STRICT时,强制验证区域*/
|
||||
private String suggestDistrict;
|
||||
/**建议小区名 suggestName*/
|
||||
/**建议小区名 suggestName*/
|
||||
private String suggestName;
|
||||
/**调试时断点小区名*/
|
||||
/**调试时断点小区名*/
|
||||
private String debugName;
|
||||
private String propertyType;
|
||||
/**用户输入地址*/
|
||||
/**用户输入地址*/
|
||||
private String address;
|
||||
/**建筑类型解析出对应的建筑物*/
|
||||
/**建筑类型解析出对应的建筑物*/
|
||||
private BuildingType buildingType;
|
||||
/**匹配验证等级要求*/
|
||||
/**匹配验证等级要求*/
|
||||
private PreciseLevel preciseLevel;
|
||||
/**是否使用地图库*/
|
||||
/**是否使用地图库*/
|
||||
private boolean useMap;
|
||||
/**是否使用阿里云接口*/
|
||||
/**是否使用阿里云接口*/
|
||||
private boolean useAliyunApi;
|
||||
//是否使用CRF算法
|
||||
//是否使用CRF算法
|
||||
private boolean useCrf;
|
||||
public boolean isUseCrf() {
|
||||
return useCrf;
|
||||
@@ -42,9 +42,9 @@ public class MatchParams {
|
||||
this.containsLocation = containsLocation;
|
||||
}
|
||||
|
||||
/**是否输出经纬度*/
|
||||
/**是否输出经纬度*/
|
||||
private boolean containsLocation;
|
||||
/**地址解析目的*/
|
||||
/**地址解析目的*/
|
||||
private AddressParserGoal addressParserGoal;
|
||||
|
||||
|
||||
|
||||
+4
-4
@@ -1,10 +1,10 @@
|
||||
package com.fangjia.service.address.mode;
|
||||
|
||||
/**
|
||||
* 正则表达式匹配结果
|
||||
* 正则表达式匹配结果
|
||||
*/
|
||||
public class MatchResult {
|
||||
public String matchContent;//匹配到的内容
|
||||
public int start;//内容开始位置
|
||||
public int end; //内容结束位置
|
||||
public String matchContent;//匹配到的内容
|
||||
public int start;//内容开始位置
|
||||
public int end; //内容结束位置
|
||||
}
|
||||
|
||||
+7
-7
@@ -1,22 +1,22 @@
|
||||
package com.fangjia.service.address.mode;
|
||||
|
||||
/**
|
||||
* 匹配文本辅助类
|
||||
* 匹配文本辅助类
|
||||
* @author wenyan
|
||||
*/
|
||||
public class MatchText {
|
||||
|
||||
/**主名优先级*/
|
||||
/**主名优先级*/
|
||||
public static final float MAIN_NAME_PRIORITY = 1f;
|
||||
/**别名优先级*/
|
||||
/**别名优先级*/
|
||||
public static final float ALIAS_PRIORITY = 0.9f;
|
||||
/**主地址优先级*/
|
||||
/**主地址优先级*/
|
||||
public static final float MAIN_ADDR_PRIORITY = 1f;
|
||||
/**地址别名优先级*/
|
||||
/**地址别名优先级*/
|
||||
public static final float ADDR_ALIAS_PRIORITY = 0.9f;
|
||||
/**
|
||||
* 产生地址优先级
|
||||
* 程序会把呼玛路58-60号 拆出呼玛路58号,呼玛路59号,呼玛路60号
|
||||
* 产生地址优先级
|
||||
* 程序会把呼玛路58-60号 拆出呼玛路58号,呼玛路59号,呼玛路60号
|
||||
* */
|
||||
public static final float GEN_ADDR_PRIORITY = 0.8f;
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package com.fangjia.service.address.mode;
|
||||
|
||||
/**
|
||||
* @author ÍõÎÄÑÞ
|
||||
* @author 王文艳
|
||||
* @create 2016-09-21
|
||||
**/
|
||||
public class MetaDataCacheKey {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package com.fangjia.service.address.mode;
|
||||
|
||||
|
||||
/**
|
||||
* @author 王文艳
|
||||
* @author 王文艳
|
||||
* @create 2016-09-21
|
||||
**/
|
||||
public enum MetaDataType {
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
package com.fangjia.service.address.mode;
|
||||
|
||||
/**
|
||||
* 匹配精度
|
||||
* 匹配精度
|
||||
*/
|
||||
public enum PreciseLevel {
|
||||
STRICT,/*验证区域*/
|
||||
FUZZY /*不验证区域*/
|
||||
STRICT,/*验证区域*/
|
||||
FUZZY /*不验证区域*/
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package com.fangjia.service.address.mode;
|
||||
|
||||
public enum PropertyType {
|
||||
|
||||
APARTMENT("ÆÕͨסլ"), VILLA("±ðÊû"), BUSINESS("ÉÌס");
|
||||
APARTMENT("普通住宅"), VILLA("别墅"), BUSINESS("商住");
|
||||
private String name;
|
||||
PropertyType(String name){
|
||||
this.name = name;
|
||||
|
||||
+44
-44
@@ -12,7 +12,7 @@ import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* 全国省份简称 全称数据
|
||||
* 全国省份简称 全称数据
|
||||
* @author wenyan
|
||||
*/
|
||||
public class ProvinceData {
|
||||
@@ -20,64 +20,64 @@ public class ProvinceData {
|
||||
final static Logger logger = Logger.getLogger(ProvinceData.class);
|
||||
|
||||
static final Map<String, List<String>> data = new HashMap<String, List<String>>() {{
|
||||
put("河北", Arrays.asList("河北省", "冀"));
|
||||
put("河南", Arrays.asList("河南省", "豫"));
|
||||
put("云南", Arrays.asList("云南省", "滇"));
|
||||
put("辽宁", Arrays.asList("辽宁省", "辽"));
|
||||
put("黑龙江", Arrays.asList("黑龙江省", "黑"));
|
||||
put("湖南", Arrays.asList("湖南省", "湘"));
|
||||
put("湖北", Arrays.asList("湖北省", "鄂"));
|
||||
put("安徽", Arrays.asList("安徽省", "皖"));
|
||||
put("山东", Arrays.asList("山东省", "鲁"));
|
||||
put("新疆", Arrays.asList("新疆维吾尔自治区", "新疆省","新"));
|
||||
put("江苏", Arrays.asList("江苏省", "苏"));
|
||||
put("浙江", Arrays.asList("浙江省", "浙"));
|
||||
put("江西", Arrays.asList("江西省", "赣"));
|
||||
put("广西", Arrays.asList("广西省","广西壮族自治区", "桂"));
|
||||
put("甘肃", Arrays.asList("甘肃省", "甘"));
|
||||
put("山西", Arrays.asList("山西省", "晋"));
|
||||
put("内蒙古", Arrays.asList("内蒙古自治区", "内蒙古省","蒙"));
|
||||
put("陕西", Arrays.asList("陕西省", "陜西", "陜西省", "陕"));
|
||||
put("吉林", Arrays.asList("吉林省", "吉"));
|
||||
put("福建", Arrays.asList("福建省", "褔建省", "闽"));
|
||||
put("贵州", Arrays.asList("贵州省", "黔"));
|
||||
put("广东", Arrays.asList("广东省", "粤"));
|
||||
put("青海", Arrays.asList("青海省", "青"));
|
||||
put("西藏", Arrays.asList("西藏自治区", "藏"));
|
||||
put("四川", Arrays.asList("四川省", "川"));
|
||||
put("宁夏", Arrays.asList("宁夏回族自治区", "宁夏省", "宁"));
|
||||
put("海南", Arrays.asList("海南省", "琼"));
|
||||
put("台湾", Arrays.asList("台湾省", "台"));
|
||||
put("河北", Arrays.asList("河北省", "冀"));
|
||||
put("河南", Arrays.asList("河南省", "豫"));
|
||||
put("云南", Arrays.asList("云南省", "滇"));
|
||||
put("辽宁", Arrays.asList("辽宁省", "辽"));
|
||||
put("黑龙江", Arrays.asList("黑龙江省", "黑"));
|
||||
put("湖南", Arrays.asList("湖南省", "湘"));
|
||||
put("湖北", Arrays.asList("湖北省", "鄂"));
|
||||
put("安徽", Arrays.asList("安徽省", "皖"));
|
||||
put("山东", Arrays.asList("山东省", "鲁"));
|
||||
put("新疆", Arrays.asList("新疆维吾尔自治区", "新疆省","新"));
|
||||
put("江苏", Arrays.asList("江苏省", "苏"));
|
||||
put("浙江", Arrays.asList("浙江省", "浙"));
|
||||
put("江西", Arrays.asList("江西省", "赣"));
|
||||
put("广西", Arrays.asList("广西省","广西壮族自治区", "桂"));
|
||||
put("甘肃", Arrays.asList("甘肃省", "甘"));
|
||||
put("山西", Arrays.asList("山西省", "晋"));
|
||||
put("内蒙古", Arrays.asList("内蒙古自治区", "内蒙古省","蒙"));
|
||||
put("陕西", Arrays.asList("陕西省", "陜西", "陜西省", "陕"));
|
||||
put("吉林", Arrays.asList("吉林省", "吉"));
|
||||
put("福建", Arrays.asList("福建省", "褔建省", "闽"));
|
||||
put("贵州", Arrays.asList("贵州省", "黔"));
|
||||
put("广东", Arrays.asList("广东省", "粤"));
|
||||
put("青海", Arrays.asList("青海省", "青"));
|
||||
put("西藏", Arrays.asList("西藏自治区", "藏"));
|
||||
put("四川", Arrays.asList("四川省", "川"));
|
||||
put("宁夏", Arrays.asList("宁夏回族自治区", "宁夏省", "宁"));
|
||||
put("海南", Arrays.asList("海南省", "琼"));
|
||||
put("台湾", Arrays.asList("台湾省", "台"));
|
||||
|
||||
}};
|
||||
|
||||
static final Map<String, List<String>> GOVERNMENT_CITY_LIST = new HashMap<String, List<String>>(){{
|
||||
put("上海", Arrays.asList("上海市", "沪"));
|
||||
put("北京", Arrays.asList("北京市", "京"));
|
||||
put("天津", Arrays.asList("天津市", "津"));
|
||||
put("重庆", Arrays.asList("重庆市", "渝"));
|
||||
put("上海", Arrays.asList("上海市", "沪"));
|
||||
put("北京", Arrays.asList("北京市", "京"));
|
||||
put("天津", Arrays.asList("天津市", "津"));
|
||||
put("重庆", Arrays.asList("重庆市", "渝"));
|
||||
}};
|
||||
|
||||
static final Map<String,List<String>> SPECIAL_ADMIN_REGION = new HashMap<String, List<String>>(){{
|
||||
put("香港",new ArrayList<String>() {{add("港");add("香港特别行政区");add("Hong Kong");add("HK");add("HKSAR");}});
|
||||
put("澳门",new ArrayList<String>() {{add("澳");add("澳门特别行政区");add("Macao");add("Macau");}});
|
||||
put("香港",new ArrayList<String>() {{add("港");add("香港特别行政区");add("Hong Kong");add("HK");add("HKSAR");}});
|
||||
put("澳门",new ArrayList<String>() {{add("澳");add("澳门特别行政区");add("Macao");add("Macau");}});
|
||||
}};
|
||||
|
||||
/**城市:省份*/
|
||||
/**城市:省份*/
|
||||
public static Map<String, String> CITY_PROVINCE_MAP = new HashMap<String, String>();
|
||||
static DBCollection SERVER_AREA = MongoUtils.getDbCollection(Constants.FANGJIA_MONGO_URI, "fangjia", "server_area");
|
||||
|
||||
static {
|
||||
logger.info("开始加载省份信息");
|
||||
logger.info("开始加载省份信息");
|
||||
DBCursor cursor = SERVER_AREA.find(new BasicDBObject(), new BasicDBObject("province", 1).append("display", 1)).batchSize(300);
|
||||
BasicDBObject dbo;
|
||||
while(cursor.hasNext()){
|
||||
dbo = (BasicDBObject)cursor.next();
|
||||
if(!"全国".equals(dbo.getString("display"))){
|
||||
if(!"全国".equals(dbo.getString("display"))){
|
||||
CITY_PROVINCE_MAP.put(dbo.getString("display"),dbo.getString("province"));
|
||||
}
|
||||
}
|
||||
logger.info("省份信息加载结束");
|
||||
logger.info("省份信息加载结束");
|
||||
}
|
||||
|
||||
private ProvinceData(){}
|
||||
@@ -95,7 +95,7 @@ public class ProvinceData {
|
||||
|
||||
|
||||
/**
|
||||
* 判断城市是不是直辖市
|
||||
* 判断城市是不是直辖市
|
||||
* @param city
|
||||
* @return
|
||||
*/
|
||||
@@ -123,7 +123,7 @@ public class ProvinceData {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得城市所在的省份
|
||||
* 获得城市所在的省份
|
||||
* @param city
|
||||
* @return
|
||||
*/
|
||||
@@ -132,7 +132,7 @@ public class ProvinceData {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取省份下的所有城市
|
||||
* 获取省份下的所有城市
|
||||
* @param province
|
||||
* @return
|
||||
*/
|
||||
@@ -147,7 +147,7 @@ public class ProvinceData {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有的兄弟城市
|
||||
* 获取所有的兄弟城市
|
||||
* @param city
|
||||
* @return
|
||||
*/
|
||||
@@ -160,7 +160,7 @@ public class ProvinceData {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取城市列表
|
||||
* 获取城市列表
|
||||
* @return
|
||||
*/
|
||||
public static List<String> getAllCity(){
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ import com.fangjia.core.RegionData;
|
||||
import com.fangjia.service.address.AddressAnalyseResultKeyEnum;
|
||||
|
||||
/**
|
||||
* 区域解析
|
||||
* 区域解析
|
||||
*
|
||||
* @author yk
|
||||
*
|
||||
@@ -28,7 +28,7 @@ public class RegionParser extends AbstractAddressModeParser {
|
||||
return;
|
||||
}
|
||||
|
||||
// 城市下所有区域
|
||||
// 城市下所有区域
|
||||
Map<String, List<String>> allRegionsMap = RegionData.getAllRegions(city);
|
||||
if (MapUtils.isEmpty(allRegionsMap)) {
|
||||
return;
|
||||
|
||||
+2
-2
@@ -9,13 +9,13 @@ import org.apache.commons.lang.StringUtils;
|
||||
import com.fangjia.service.address.AddressAnalyseResultKeyEnum;
|
||||
|
||||
/**
|
||||
* 路名解析,把原始地址分成路名信息、小区内信息两大部分
|
||||
* 路名解析,把原始地址分成路名信息、小区内信息两大部分
|
||||
*
|
||||
* @author yk
|
||||
*
|
||||
*/
|
||||
public class RoadParser extends AbstractAddressModeParser {
|
||||
private static final Pattern P = Pattern.compile("((路|街道?|[^1-9一二三四五六七八九十新]村)\\d+)");
|
||||
private static final Pattern P = Pattern.compile("((路|街道?|[^1-9一二三四五六七八九十新]村)\\d+)");
|
||||
|
||||
@Override
|
||||
public void doParse(String orgCity, String orgAddress, Map<String, Object> ret) {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package com.fangjia.service.address.mode;
|
||||
|
||||
/**
|
||||
* 乡镇街道数据实体
|
||||
* 乡镇街道数据实体
|
||||
*/
|
||||
public class Township {
|
||||
|
||||
|
||||
+22
-22
@@ -6,38 +6,38 @@ import java.util.regex.Pattern;
|
||||
import com.fangjia.service.cnAnalyzer.KeywordEnum;
|
||||
|
||||
/**
|
||||
* 提供一些通用方法
|
||||
* 提供一些通用方法
|
||||
*
|
||||
* @author yk
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractAddressPicker implements AddressPicker {
|
||||
protected final static Pattern ALPHA_PATTERN = Pattern.compile("[a-zA-Z\\d\\-负一二三四五六七八九十零壹两个百千万亿]+");
|
||||
protected final static String WORDS_NONG = "弄";
|
||||
protected final static String WORDS_ZHINONG = "支弄";
|
||||
protected final static String WORDS_ZU = "组";
|
||||
protected final static Pattern ALPHA_PATTERN = Pattern.compile("[a-zA-Z\\d\\-负一二三四五六七八九十零壹两个百千万亿]+");
|
||||
protected final static String WORDS_NONG = "弄";
|
||||
protected final static String WORDS_ZHINONG = "支弄";
|
||||
protected final static String WORDS_ZU = "组";
|
||||
protected final static String WORDS_JING = "#";
|
||||
protected final static String WORDS_HAO = "号";
|
||||
protected final static String WORDS_SHI = "室";
|
||||
protected final static String WORDS_FANG = "房";
|
||||
protected final static String WORDS_LOU = "楼";
|
||||
protected final static String WORDS_CENG = "层";
|
||||
protected final static String WORDS_HAO = "号";
|
||||
protected final static String WORDS_SHI = "室";
|
||||
protected final static String WORDS_FANG = "房";
|
||||
protected final static String WORDS_LOU = "楼";
|
||||
protected final static String WORDS_CENG = "层";
|
||||
protected final static String WORDS_f = "f";
|
||||
protected final static String WORDS_F = "F";
|
||||
protected final static String WORDS_DANYUAN = "单元";
|
||||
protected final static String WORDS_MENG = "门";
|
||||
protected final static String WORDS_ZHUANG = "幢";
|
||||
protected final static String WORDS_TONG = "橦";
|
||||
protected final static String WORDS_DONG = "栋";
|
||||
protected final static String WORDS_ZUO = "座";
|
||||
protected final static String WORDS_HAOLOU = "号楼";
|
||||
protected final static String WORDS_QI = "期";
|
||||
protected final static String WORDS_QU = "区";
|
||||
protected final static String WORDS_KUAI = "块";
|
||||
protected final static String WORDS_DANYUAN = "单元";
|
||||
protected final static String WORDS_MENG = "门";
|
||||
protected final static String WORDS_ZHUANG = "幢";
|
||||
protected final static String WORDS_TONG = "橦";
|
||||
protected final static String WORDS_DONG = "栋";
|
||||
protected final static String WORDS_ZUO = "座";
|
||||
protected final static String WORDS_HAOLOU = "号楼";
|
||||
protected final static String WORDS_QI = "期";
|
||||
protected final static String WORDS_QU = "区";
|
||||
protected final static String WORDS_KUAI = "块";
|
||||
|
||||
// #|支?弄|号楼?|[甲乙丙丁]?室|幢|橦|栋|座|口|楼|房|单元|区|层|组
|
||||
// #|支?弄|号楼?|[甲乙丙丁]?室|幢|橦|栋|座|口|楼|房|单元|区|层|组
|
||||
|
||||
// 为效率,以下方法都没做参数检查,调用处要确保传入参数不为null
|
||||
// 为效率,以下方法都没做参数检查,调用处要确保传入参数不为null
|
||||
protected boolean isCity(String type) {
|
||||
return type.contains(KeywordEnum.city.name());
|
||||
}
|
||||
|
||||
+6
-6
@@ -7,22 +7,22 @@ import com.fangjia.service.address.AddressAnalyseResultKeyEnum;
|
||||
import com.fangjia.service.cnAnalyzer.Token;
|
||||
|
||||
/**
|
||||
* 基于分词的模式化地址解析接口<br/>
|
||||
* 基于分词的模式化地址解析接口<br/>
|
||||
*
|
||||
* 或者叫“捡取器”更为合适,通过一串捡取链条,从原始地址中捡取出一个个地址元素,如:城市、区域、板块、路名、小区名、楼号、室号等等
|
||||
* 或者叫“捡取器”更为合适,通过一串捡取链条,从原始地址中捡取出一个个地址元素,如:城市、区域、板块、路名、小区名、楼号、室号等等
|
||||
*
|
||||
* @author yk
|
||||
*
|
||||
*/
|
||||
public interface AddressPicker {
|
||||
/**
|
||||
* 进行模式化解析
|
||||
* 进行模式化解析
|
||||
*
|
||||
* @param tokens
|
||||
* 分词结果。实现时不做检查,所以确保传入值不为null或空。
|
||||
* 分词结果。实现时不做检查,所以确保传入值不为null或空。
|
||||
* @param ret
|
||||
* key值定义见 {@link AddressAnalyseResultKeyEnum}<br/>
|
||||
* 解析时,map中传入原始输入地址,key为
|
||||
* key值定义见 {@link AddressAnalyseResultKeyEnum}<br/>
|
||||
* 解析时,map中传入原始输入地址,key为
|
||||
* {@link AddressAnalyseResultKeyEnum.orgAddress}
|
||||
*/
|
||||
public void doPick(List<Token> tokens, Map<String, Object> ret);
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import org.apache.commons.collections.CollectionUtils;
|
||||
import com.fangjia.service.cnAnalyzer.Token;
|
||||
|
||||
/**
|
||||
* 基于分词的模式化地址解析链条
|
||||
* 基于分词的模式化地址解析链条
|
||||
*
|
||||
* @author yk
|
||||
*
|
||||
|
||||
+4
-4
@@ -12,7 +12,7 @@ import com.fangjia.service.address.AddressAnalyseResultKeyEnum;
|
||||
import com.fangjia.service.cnAnalyzer.Token;
|
||||
|
||||
/**
|
||||
* 楼栋室号等的抽取器,只关注楼栋室号等信息
|
||||
* 楼栋室号等的抽取器,只关注楼栋室号等信息
|
||||
*
|
||||
* @author yk
|
||||
*
|
||||
@@ -23,7 +23,7 @@ public class DetailPicker extends AbstractAddressPicker {
|
||||
public void doPick(List<Token> tokens, Map<String, Object> ret) {
|
||||
Iterator<Token> it = tokens.iterator();
|
||||
|
||||
// #|支?弄|号楼?|[甲乙丙丁]?室|幢|橦|栋|座|口|楼|房|单元|区|层|组
|
||||
// #|支?弄|号楼?|[甲乙丙丁]?室|幢|橦|栋|座|口|楼|房|单元|区|层|组
|
||||
boolean lastRoomNum = false;
|
||||
while (it.hasNext()) {
|
||||
Token tk = it.next();
|
||||
@@ -73,7 +73,7 @@ public class DetailPicker extends AbstractAddressPicker {
|
||||
continue;
|
||||
}
|
||||
|
||||
Pattern p = Pattern.compile("[东南西北]楼");
|
||||
Pattern p = Pattern.compile("[东南西北]楼");
|
||||
Matcher m = p.matcher(value);
|
||||
if (m.find()) {
|
||||
ret.put(AddressAnalyseResultKeyEnum.houseNum.name(), value);
|
||||
@@ -93,7 +93,7 @@ public class DetailPicker extends AbstractAddressPicker {
|
||||
}
|
||||
}
|
||||
|
||||
// 上海市宝山行知路572-61-302
|
||||
// 上海市宝山行知路572-61-302
|
||||
String roomNum = (String) ret.get(AddressAnalyseResultKeyEnum.roomNum.name());
|
||||
if (StringUtils.isNotBlank(roomNum)) {
|
||||
String[] arr = roomNum.split("-");
|
||||
|
||||
+4
-4
@@ -10,7 +10,7 @@ import com.fangjia.service.address.AddressAnalyseResultKeyEnum;
|
||||
import com.fangjia.service.cnAnalyzer.Token;
|
||||
|
||||
/**
|
||||
* 原始名抽取器,只关注地址中包含的小区名
|
||||
* 原始名抽取器,只关注地址中包含的小区名
|
||||
*
|
||||
* @author yk
|
||||
*
|
||||
@@ -37,7 +37,7 @@ public class NamePicker extends AbstractAddressPicker {
|
||||
String name = value;
|
||||
|
||||
if (it.hasNext()) {
|
||||
// 小区名后紧跟X(区|期|块),认为是小区名的一部分
|
||||
// 小区名后紧跟X(区|期|块),认为是小区名的一部分
|
||||
tk = it.next();
|
||||
type = tk.getKeywordTypes();
|
||||
value = tk.getName();
|
||||
@@ -55,8 +55,8 @@ public class NamePicker extends AbstractAddressPicker {
|
||||
}
|
||||
|
||||
if (named) {
|
||||
// 在前一个roadpicker中,只提取了路名后的一个alpha元素,如果在小区名前还有alpha元素,认为它是地址的一部分
|
||||
// 如:上海市青浦清湖路789弄33号运杰花园302室,roadpicker抽取的地址是“清湖路789弄”,在这里抽取到了小区名“运杰花园”,所以“33号”应该也是地址的一部分
|
||||
// 在前一个roadpicker中,只提取了路名后的一个alpha元素,如果在小区名前还有alpha元素,认为它是地址的一部分
|
||||
// 如:上海市青浦清湖路789弄33号运杰花园302室,roadpicker抽取的地址是“清湖路789弄”,在这里抽取到了小区名“运杰花园”,所以“33号”应该也是地址的一部分
|
||||
it = tokens.iterator();
|
||||
currentIndex = 0;
|
||||
while (it.hasNext()) {
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ import com.fangjia.service.address.AddressAnalyseResultKeyEnum;
|
||||
import com.fangjia.service.cnAnalyzer.Token;
|
||||
|
||||
/**
|
||||
* 地址抽取器,只关注地址,如XXX路XX(号|弄)
|
||||
* 地址抽取器,只关注地址,如XXX路XX(号|弄)
|
||||
*
|
||||
* @author yk
|
||||
*
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Test {
|
||||
pickerChain.addPicker(new DetailPicker());
|
||||
|
||||
|
||||
String s = "上海市徐汇零陵路241号4幢303室";
|
||||
String s = "上海市徐汇零陵路241号4幢303室";
|
||||
List<Token> tokens = CnAddressTokenizer.tokenizer(s);
|
||||
System.out.println(tokens);
|
||||
|
||||
@@ -45,16 +45,16 @@ public class Test {
|
||||
System.out.println(ret);
|
||||
System.out.println(tokens);
|
||||
|
||||
/*File file = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\上海-0730.txt");
|
||||
File file2 = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\上海-0730_picker.txt");
|
||||
/*File file = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\上海-0730.txt");
|
||||
File file2 = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\上海-0730_picker.txt");
|
||||
if (file2.exists()) {
|
||||
file2.delete();
|
||||
}
|
||||
BufferedWriter fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file2, true), "GBK")); // 指定编码格式,以免读取时中文字符异常
|
||||
BufferedWriter fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file2, true), "GBK")); // 指定编码格式,以免读取时中文字符异常
|
||||
|
||||
// 全部写入缓存中的内容
|
||||
// 全部写入缓存中的内容
|
||||
|
||||
InputStreamReader read = new InputStreamReader(new FileInputStream(file), "utf-8");// 考虑到编码格式
|
||||
InputStreamReader read = new InputStreamReader(new FileInputStream(file), "utf-8");// 考虑到编码格式
|
||||
BufferedReader bufferedReader = new BufferedReader(read);
|
||||
String lineTxt = null;
|
||||
while ((lineTxt = bufferedReader.readLine()) != null) {
|
||||
@@ -65,7 +65,7 @@ public class Test {
|
||||
List<Token> tokens = CnAddressTokenizer.tokenizer(lineTxt);
|
||||
pickerChain.doPick(tokens, ret);
|
||||
|
||||
// parserChain.doParse("上海", lineTxt, ret);
|
||||
// parserChain.doParse("上海", lineTxt, ret);
|
||||
|
||||
ret.remove(AddressAnalyseResultKeyEnum.orgAddress.name());
|
||||
ret.remove(AddressAnalyseResultKeyEnum.shortAddress.name());
|
||||
|
||||
+26
-26
@@ -22,21 +22,21 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 地址解析器基类
|
||||
* 地址解析器基类
|
||||
*@author wenyan
|
||||
*/
|
||||
public abstract class AbstractAddressProcessor {
|
||||
|
||||
enum RepeatStatus {
|
||||
NEXT,/*继续处理*/
|
||||
REPEAT/*需要重复处理*/,
|
||||
DONE/*处理完成*/
|
||||
NEXT,/*继续处理*/
|
||||
REPEAT/*需要重复处理*/,
|
||||
DONE/*处理完成*/
|
||||
}
|
||||
|
||||
public abstract RepeatStatus process(Address address);
|
||||
|
||||
/**
|
||||
* 返回正则匹配结果
|
||||
* 返回正则匹配结果
|
||||
* @param pattern
|
||||
* @param str
|
||||
* @return
|
||||
@@ -60,11 +60,11 @@ public abstract class AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用一个正则表达式来匹配一个字符串
|
||||
* 使用一个正则表达式来匹配一个字符串
|
||||
* MatchResult.matchContent = str.substring(MatchResult.start,MatchResult.end)
|
||||
* @param pattern
|
||||
* @param str
|
||||
* @return 返回匹配到的第一个结果
|
||||
* @return 返回匹配到的第一个结果
|
||||
*/
|
||||
protected MatchResult matchFirst(Pattern pattern, String str){
|
||||
|
||||
@@ -86,7 +86,7 @@ public abstract class AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除字符串中 [start .. end) 部分
|
||||
* 移除字符串中 [start .. end) 部分
|
||||
* @param s
|
||||
* @param start
|
||||
* @param end
|
||||
@@ -101,7 +101,7 @@ public abstract class AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 从字符串中提取数字
|
||||
* 从字符串中提取数字
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
@@ -114,7 +114,7 @@ public abstract class AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取街道信息
|
||||
* 获取街道信息
|
||||
* @param address
|
||||
* @return
|
||||
*/
|
||||
@@ -128,7 +128,7 @@ public abstract class AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析出关键字中的小区名
|
||||
* 解析出关键字中的小区名
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
@@ -151,7 +151,7 @@ public abstract class AbstractAddressProcessor {
|
||||
|
||||
|
||||
/**
|
||||
* 解析出关键字中的小区名
|
||||
* 解析出关键字中的小区名
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
@@ -204,7 +204,7 @@ public abstract class AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 对行政区划信息(省份,城市,区域,乡镇)进行评分
|
||||
* 对行政区划信息(省份,城市,区域,乡镇)进行评分
|
||||
* @param region
|
||||
* @param street
|
||||
* @return
|
||||
@@ -215,7 +215,7 @@ public abstract class AbstractAddressProcessor {
|
||||
return 1;
|
||||
}
|
||||
region = escapeRegExpSpecialWord(region);
|
||||
if (match(street, "^" + region + "[东南西北中一二三四五六七八九十百千\\d]?(路|街|大道|支路|村)")) {
|
||||
if (match(street, "^" + region + "[东南西北中一二三四五六七八九十百千\\d]?(路|街|大道|支路|村)")) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ public abstract class AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否匹配给定的正则表达式
|
||||
* 判断字符串是否匹配给定的正则表达式
|
||||
* @param str
|
||||
* @param pattern
|
||||
* @return
|
||||
@@ -234,7 +234,7 @@ public abstract class AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否匹配给定的正则表达式
|
||||
* 判断字符串是否匹配给定的正则表达式
|
||||
* @param str
|
||||
* @param regex
|
||||
* @return
|
||||
@@ -243,7 +243,7 @@ public abstract class AbstractAddressProcessor {
|
||||
return match(str, Pattern.compile(regex));
|
||||
}
|
||||
/**
|
||||
* 转义正则特殊字符 ($()*+.[]?\^{},|)
|
||||
* 转义正则特殊字符 ($()*+.[]?\^{},|)
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
@@ -263,7 +263,7 @@ public abstract class AbstractAddressProcessor {
|
||||
|
||||
|
||||
/**
|
||||
* 判断集合元素是否唯一
|
||||
* 判断集合元素是否唯一
|
||||
* @param coll
|
||||
* @return
|
||||
*/
|
||||
@@ -272,7 +272,7 @@ public abstract class AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得List的第一个元素
|
||||
* 获得List的第一个元素
|
||||
* @param list
|
||||
* @param <T>
|
||||
* @return
|
||||
@@ -286,9 +286,9 @@ public abstract class AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 对参考城市进行筛选
|
||||
* @param referCities 地址参考城市列表
|
||||
* @param address 地址
|
||||
* 对参考城市进行筛选
|
||||
* @param referCities 地址参考城市列表
|
||||
* @param address 地址
|
||||
*/
|
||||
protected void voting(List<String> referCities, Address address){
|
||||
|
||||
@@ -302,7 +302,7 @@ public abstract class AbstractAddressProcessor {
|
||||
return;
|
||||
}
|
||||
List<String> candidateCities = address.getCandidateCities();
|
||||
//候选城市为空
|
||||
//候选城市为空
|
||||
if(candidateCities.isEmpty()){
|
||||
confirmCityByBrotherCities(referCities, address);
|
||||
}else{
|
||||
@@ -322,7 +322,7 @@ public abstract class AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过兄弟城市确认参数
|
||||
* 通过兄弟城市确认参数
|
||||
* @param referCities
|
||||
* @param address
|
||||
*/
|
||||
@@ -344,7 +344,7 @@ public abstract class AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找和city的兄弟城市相同的参考城市
|
||||
* 查找和city的兄弟城市相同的参考城市
|
||||
* @param city
|
||||
* @param referCities
|
||||
* @return
|
||||
@@ -355,7 +355,7 @@ public abstract class AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得兄弟:同省份
|
||||
* 获得兄弟:同省份
|
||||
* @param city
|
||||
* @return
|
||||
*/
|
||||
|
||||
+7
-7
@@ -8,7 +8,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 地址省市区移除处理
|
||||
* 地址省市区移除处理
|
||||
*/
|
||||
public class AddressDistrictProcessors {
|
||||
|
||||
@@ -25,14 +25,14 @@ public class AddressDistrictProcessors {
|
||||
}
|
||||
|
||||
/**
|
||||
* 标准化一个地址
|
||||
* 标准化一个地址
|
||||
* @param address
|
||||
* @return
|
||||
*/
|
||||
public static Address process(Address address){
|
||||
|
||||
if(StringUtils.isBlank(address.getAddress())){
|
||||
throw new IllegalArgumentException("地址不能为空");
|
||||
throw new IllegalArgumentException("地址不能为空");
|
||||
}
|
||||
long s = System.currentTimeMillis();
|
||||
AbstractAddressProcessor.RepeatStatus status = null;
|
||||
@@ -43,11 +43,11 @@ public class AddressDistrictProcessors {
|
||||
String org = address.getAddress();
|
||||
status = processor.process(address);
|
||||
String now = address.getAddress();
|
||||
if(!org.equals(now)){//区划信息有可能重复出现,如果有变化则重新处理
|
||||
if(!org.equals(now)){//区划信息有可能重复出现,如果有变化则重新处理
|
||||
i = 0;
|
||||
}
|
||||
}catch (Exception e){
|
||||
log("地址解析出错==>[city:" + address.getCity() + " address:" + address.getOrgAddress() + " 步骤:" + processor.getClass().getSimpleName() + "]" , e);
|
||||
log("地址解析出错==>[city:" + address.getCity() + " address:" + address.getOrgAddress() + " 步骤:" + processor.getClass().getSimpleName() + "]" , e);
|
||||
}
|
||||
if(AbstractAddressProcessor.RepeatStatus.REPEAT == status){
|
||||
i--;
|
||||
@@ -55,13 +55,13 @@ public class AddressDistrictProcessors {
|
||||
break;
|
||||
}
|
||||
if(totalProcessCount > 50){
|
||||
logger.warn("异常数据---> \tcity:" + address.getCity() + ",\taddress:" + address.getOrgAddress());
|
||||
logger.warn("异常数据---> \tcity:" + address.getCity() + ",\taddress:" + address.getOrgAddress());
|
||||
break;
|
||||
}
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
if(end - s > 20){
|
||||
logger.warn("拆次耗时{ city: \""+ address.getCity() + "\" , address : \"" + address.getOrgAddress() + " \", time:" + (end - s) + "}");
|
||||
logger.warn("拆次耗时{ city: \""+ address.getCity() + "\" , address : \"" + address.getOrgAddress() + " \", time:" + (end - s) + "}");
|
||||
}
|
||||
return address;
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import com.fangjia.service.address.mode.Address;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 地址格式化处理器
|
||||
* 地址格式化处理器
|
||||
*/
|
||||
public class AddressFormatProcessor extends AbstractAddressProcessor {
|
||||
|
||||
|
||||
+17
-17
@@ -8,8 +8,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 地址解析器
|
||||
* @author 王文艳
|
||||
* 地址解析器
|
||||
* @author 王文艳
|
||||
*/
|
||||
public class AddressProcessors{
|
||||
|
||||
@@ -19,7 +19,7 @@ public class AddressProcessors{
|
||||
private static final Logger logger = Logger.getLogger(AddressProcessors.class);
|
||||
|
||||
static {
|
||||
//修改顺序需要调整process i 的值
|
||||
//修改顺序需要调整process i 的值
|
||||
addressProcessors.add(new ProximalCharactersProcessor());
|
||||
addressProcessors.add(new PreNoiseProcessor());
|
||||
addressProcessors.add(new AddressFormatProcessor());
|
||||
@@ -47,14 +47,14 @@ public class AddressProcessors{
|
||||
|
||||
|
||||
/**
|
||||
* 标准化一个地址
|
||||
* 标准化一个地址
|
||||
* @param address
|
||||
* @return
|
||||
*/
|
||||
public static Address process(Address address){
|
||||
|
||||
if(StringUtils.isBlank(address.getAddress())){
|
||||
throw new IllegalArgumentException("地址不能为空");
|
||||
throw new IllegalArgumentException("地址不能为空");
|
||||
}
|
||||
|
||||
long s = System.currentTimeMillis();
|
||||
@@ -66,11 +66,11 @@ public class AddressProcessors{
|
||||
String org = address.getAddress();
|
||||
status = processor.process(address);
|
||||
String now = address.getAddress();
|
||||
if(!org.equals(now) && i >= 5 && i <= 9){//区划信息有可能重复出现,如果有变化则重新处理
|
||||
if(!org.equals(now) && i >= 5 && i <= 9){//区划信息有可能重复出现,如果有变化则重新处理
|
||||
i = 4;
|
||||
}
|
||||
}catch (Exception e){
|
||||
log("地址解析出错==>[city:" + address.getCity() + " address:" + address.getOrgAddress() + " 步骤:" + processor.getClass().getSimpleName() + "]" , e);
|
||||
log("地址解析出错==>[city:" + address.getCity() + " address:" + address.getOrgAddress() + " 步骤:" + processor.getClass().getSimpleName() + "]" , e);
|
||||
}
|
||||
if(AbstractAddressProcessor.RepeatStatus.REPEAT == status){
|
||||
i--;
|
||||
@@ -78,13 +78,13 @@ public class AddressProcessors{
|
||||
break;
|
||||
}
|
||||
if(totalProcessCount > 50){
|
||||
logger.warn("异常数据---> \tcity:" + address.getCity() + ",\taddress:" + address.getOrgAddress());
|
||||
logger.warn("异常数据---> \tcity:" + address.getCity() + ",\taddress:" + address.getOrgAddress());
|
||||
break;
|
||||
}
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
if(end - s > 20){
|
||||
logger.warn("拆次耗时{ city: \""+ address.getCity() + "\" , address : \"" + address.getOrgAddress() + " \", time:" + (end - s) + "}");
|
||||
logger.warn("拆次耗时{ city: \""+ address.getCity() + "\" , address : \"" + address.getOrgAddress() + " \", time:" + (end - s) + "}");
|
||||
}
|
||||
return address;
|
||||
}
|
||||
@@ -95,26 +95,26 @@ public class AddressProcessors{
|
||||
|
||||
public static void main(String[] args) {
|
||||
Address address = new Address();
|
||||
address.setCity("上海");
|
||||
address.setOrgAddress("长宁路396弄27号A栋304室");
|
||||
address.setCity("上海");
|
||||
address.setOrgAddress("长宁路396弄27号A栋304室");
|
||||
System.out.println(process(address));
|
||||
|
||||
address.setOrgAddress("长宁区长宁区长宁路396弄27号304室");
|
||||
address.setOrgAddress("长宁区长宁区长宁路396弄27号304室");
|
||||
System.out.println(process(address));
|
||||
|
||||
address.setOrgAddress("上海市长宁区长宁区长宁路396弄27号304室");
|
||||
address.setOrgAddress("上海市长宁区长宁区长宁路396弄27号304室");
|
||||
System.out.println(process(address));
|
||||
|
||||
address.setOrgAddress("上海市长宁区长宁区长宁路396弄27号304室(剑河小区)");
|
||||
address.setOrgAddress("上海市长宁区长宁区长宁路396弄27号304室(剑河小区)");
|
||||
System.out.println(process(address));
|
||||
|
||||
address.setOrgAddress("淮海西路442弄87号1504室");
|
||||
address.setOrgAddress("淮海西路442弄87号1504室");
|
||||
System.out.println(process(address));
|
||||
|
||||
address.setOrgAddress("殷行路881弄10号地下1层储藏");
|
||||
address.setOrgAddress("殷行路881弄10号地下1层储藏");
|
||||
System.out.println(process(address));
|
||||
|
||||
address.setOrgAddress("佳木斯路185弄15号306");
|
||||
address.setOrgAddress("佳木斯路185弄15号306");
|
||||
System.out.println(process(address));
|
||||
|
||||
address.setOrgAddress(null);
|
||||
|
||||
+68
-68
@@ -11,67 +11,67 @@ import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* case01:双星国际大厦南楼1105房
|
||||
* case02:青海省西宁市城东区南小街68号1号楼2单元2034
|
||||
* case03:重庆市巫山县巫峡镇巫峡路120号3幢4层3单元405室
|
||||
* case04:朝阳区首都机场路89号3-13幢,3-14幢
|
||||
* case05:朝阳区东坝中街12号院3号楼2层3单元202 //TODO
|
||||
* case06:合肥市华邦光明世家3#4#楼4-402号
|
||||
* case07:丰台区东铁匠营横七条44号院10号楼1107
|
||||
* case08:晋源区龙源小区2-1-502
|
||||
* case09:攸县联星街道永佳社区中心嘉园小区C1-2803号
|
||||
* 金牛区蜀汉路528号御都花园37-1C
|
||||
* 解析楼栋号
|
||||
* case01:双星国际大厦南楼1105房
|
||||
* case02:青海省西宁市城东区南小街68号1号楼2单元2034
|
||||
* case03:重庆市巫山县巫峡镇巫峡路120号3幢4层3单元405室
|
||||
* case04:朝阳区首都机场路89号3-13幢,3-14幢
|
||||
* case05:朝阳区东坝中街12号院3号楼2层3单元202 //TODO
|
||||
* case06:合肥市华邦光明世家3#4#楼4-402号
|
||||
* case07:丰台区东铁匠营横七条44号院10号楼1107
|
||||
* case08:晋源区龙源小区2-1-502
|
||||
* case09:攸县联星街道永佳社区中心嘉园小区C1-2803号
|
||||
* 金牛区蜀汉路528号御都花园37-1C
|
||||
* 解析楼栋号
|
||||
*/
|
||||
public class BuildingNumberProcessor extends AbstractAddressProcessor {
|
||||
|
||||
static final Pattern BUILDING_NUMBER_PATTERN = Pattern.compile("(第?(\\w+-)?[\\w一二三四五六七八九十零百千]+((号楼)|(#楼)|栋|幢|座|#|号(?!院)))([\\w东南西北中一二三四五六七八九十甲乙丙丁]{1,5}((单元)|号))*(\\d+(-\\d)?(室|户|$))?");
|
||||
static final Pattern BUILDING_NUMBER_PATTERN_01 = Pattern.compile("[\\w一二三四五|六七八九十零百千-]+(?:(?:号楼)|(?:#楼)|栋|幢|座|#|号(?!院))[\\w东南西北中一二三四五六七八九十甲乙丙丁]{1,5}单元");
|
||||
@Case(sample = "浙江省温州市乐清市柳市安居30幢A", model = "楼栋+单元号")
|
||||
static final Pattern BUILDING_NUMBER_PATTERN_02 = Pattern.compile("[\\w一二三四五|六七八九十零百千-]+((?:[号#]楼)|栋|幢|座|#)[A-Z甲乙丙丁戊戌]+$");
|
||||
static final Pattern BUILDING_NUMBER_PATTERN_03 = Pattern.compile("[\\w东南西北甲乙丙丁戊戌组单-]+[栋幢座](?:[\\w东南西北中一二三四五六七八九十甲乙丙丁]{1,5}单元)*");
|
||||
@Case(sample = "浙江省杭州市江干区江干区江锦路和谐家园南苑1单元7幢", model = "单元号楼栋号颠倒")
|
||||
static final Pattern BUILDING_NUMBER_PATTERN_04 = Pattern.compile("[\\w东南西北中一二三四五六七八九十甲乙丙丁]+单元.+[栋幢(号楼)]");
|
||||
static final Pattern BUILDING_NUMBER_PATTERN = Pattern.compile("(第?(\\w+-)?[\\w一二三四五六七八九十零百千]+((号楼)|(#楼)|栋|幢|座|#|号(?!院)))([\\w东南西北中一二三四五六七八九十甲乙丙丁]{1,5}((单元)|号))*(\\d+(-\\d)?(室|户|$))?");
|
||||
static final Pattern BUILDING_NUMBER_PATTERN_01 = Pattern.compile("[\\w一二三四五|六七八九十零百千-]+(?:(?:号楼)|(?:#楼)|栋|幢|座|#|号(?!院))[\\w东南西北中一二三四五六七八九十甲乙丙丁]{1,5}单元");
|
||||
@Case(sample = "浙江省温州市乐清市柳市安居30幢A", model = "楼栋+单元号")
|
||||
static final Pattern BUILDING_NUMBER_PATTERN_02 = Pattern.compile("[\\w一二三四五|六七八九十零百千-]+((?:[号#]楼)|栋|幢|座|#)[A-Z甲乙丙丁戊戌]+$");
|
||||
static final Pattern BUILDING_NUMBER_PATTERN_03 = Pattern.compile("[\\w东南西北甲乙丙丁戊戌组单-]+[栋幢座](?:[\\w东南西北中一二三四五六七八九十甲乙丙丁]{1,5}单元)*");
|
||||
@Case(sample = "浙江省杭州市江干区江干区江锦路和谐家园南苑1单元7幢", model = "单元号楼栋号颠倒")
|
||||
static final Pattern BUILDING_NUMBER_PATTERN_04 = Pattern.compile("[\\w东南西北中一二三四五六七八九十甲乙丙丁]+单元.+[栋幢(号楼)]");
|
||||
/**
|
||||
* http://www.gyfc.net.cn/pro_query/FloorList.aspx?yszh=2017033&qu=3
|
||||
*/
|
||||
@Case(sample = "沈北新区蒲昌路1-7号2-11-3", model = "单元号-楼层-室号")
|
||||
@Case(sample = "沈北新区蒲昌路1-7号2-11-3", model = "单元号-楼层-室号")
|
||||
static final Pattern BUILDING_NUMBER_PATTERN_05 = Pattern.compile("\\d{1,2}-\\d{1,2}-\\d$");
|
||||
/**
|
||||
* 重庆
|
||||
* 重庆
|
||||
* http://www.cq315house.com/315web/HtmlPage/ShowRoomsNew.aspx?block=9%u5E62&buildingid=11089137
|
||||
*/
|
||||
@Case(sample = "北部新区翠渝路9号4幢4-2", model = "楼栋号-楼层-室号")
|
||||
static final Pattern BUILDING_NUMBER_PATTERN_06 = Pattern.compile("\\d+(幢|栋|(号楼))\\d{1,2}-\\d$");
|
||||
@Case(sample = "北部新区翠渝路9号4幢4-2", model = "楼栋号-楼层-室号")
|
||||
static final Pattern BUILDING_NUMBER_PATTERN_06 = Pattern.compile("\\d+(幢|栋|(号楼))\\d{1,2}-\\d$");
|
||||
|
||||
@Case(sample = "北部新区金州大道23号21幢2-9-1", model = "楼栋号-单元号-楼层-室号")
|
||||
static final Pattern BUILDING_NUMBER_PATTERN_07 = Pattern.compile("\\d+(幢|栋|(号楼))\\w+-\\d{1,2}-\\d+$");
|
||||
@Case(sample = "北部新区金州大道23号21幢2-9-1", model = "楼栋号-单元号-楼层-室号")
|
||||
static final Pattern BUILDING_NUMBER_PATTERN_07 = Pattern.compile("\\d+(幢|栋|(号楼))\\w+-\\d{1,2}-\\d+$");
|
||||
|
||||
@Case(sample = "武科东一路16号7-1-10-1", model = "单元号(数字)室号(数字-数字-数字)")
|
||||
static final Pattern BUILDING_NUMBER_PATTERN_08 = Pattern.compile("\\d+-\\d+-\\d{1,2}-\\d+($|号|室)");
|
||||
@Case(sample = "武科东一路16号7-1-10-1", model = "单元号(数字)室号(数字-数字-数字)")
|
||||
static final Pattern BUILDING_NUMBER_PATTERN_08 = Pattern.compile("\\d+-\\d+-\\d{1,2}-\\d+($|号|室)");
|
||||
|
||||
@Case(sample = "山东省潍坊市奎文区院校街14号甲3单元", model = "只有单元号")
|
||||
static final Pattern UNIT_NUMBER_PATTERN_01 = Pattern.compile("[\\w东南西北中一二三四五六七八九十甲乙丙丁]+单元");
|
||||
static final Pattern UNIT_NUMBER_PATTERN_CASE01 = Pattern.compile("[\\w一二三四五六七八九十甲乙丙丁戊戌东南西北中]+单元");
|
||||
@Case(sample = "景天花园37、38、39、42、43、44、45、46、47、48、53栋")
|
||||
static final Pattern MULTI_BUILDING_NUMBER_PATTERN = Pattern.compile("(\\d+、)+\\d+栋");
|
||||
@Case(sample = "山东省潍坊市奎文区院校街14号甲3单元", model = "只有单元号")
|
||||
static final Pattern UNIT_NUMBER_PATTERN_01 = Pattern.compile("[\\w东南西北中一二三四五六七八九十甲乙丙丁]+单元");
|
||||
static final Pattern UNIT_NUMBER_PATTERN_CASE01 = Pattern.compile("[\\w一二三四五六七八九十甲乙丙丁戊戌东南西北中]+单元");
|
||||
@Case(sample = "景天花园37、38、39、42、43、44、45、46、47、48、53栋")
|
||||
static final Pattern MULTI_BUILDING_NUMBER_PATTERN = Pattern.compile("(\\d+、)+\\d+栋");
|
||||
|
||||
@Case(sample ="庐城镇文昌路196号世纪锦都37#202号房庐江世纪锦都")
|
||||
static final Pattern BUILDING_NUMBER_ROOM_NUMBER = Pattern.compile("第?[\\w东南西北中一二三四五六七八九十甲乙丙丁]+((号楼)|(#楼)|栋|幢|座|#|号(?!院))\\d+(($|号|室|房|户)+)");
|
||||
@Case(sample ="庐城镇文昌路196号世纪锦都37#202号房庐江世纪锦都")
|
||||
static final Pattern BUILDING_NUMBER_ROOM_NUMBER = Pattern.compile("第?[\\w东南西北中一二三四五六七八九十甲乙丙丁]+((号楼)|(#楼)|栋|幢|座|#|号(?!院))\\d+(($|号|室|房|户)+)");
|
||||
|
||||
@Case(sample = "北京市大兴区丰台区丰台镇新华街四里2楼7门302号", model = "楼栋号单元号室号")
|
||||
static final Pattern BUILDING_UNIT_ROOM_PATTERN = Pattern.compile("\\d+楼\\d+门\\d{3,4}室");
|
||||
static final Pattern BUILDING_UNIT_HOUSE_PATTERN = Pattern.compile("\\w+-\\w+-\\d{3,4}(号|室|户)?");
|
||||
static final Pattern BUILDING_HOUSE_PATTERN_01 = Pattern.compile("\\w+-\\d{3,4}(号|室|户)?");//室号:2002-2003室 栋号+室号:D南-103楼 青岛室惯称户
|
||||
static final Pattern BUILDING_HOUSE_PATTERN_02 = Pattern.compile("\\w+号\\d{3,4}(号|室|户)?");//硚口区武胜路荣华东村24号301室
|
||||
static final Pattern HOUSE_NUMBER01 = Pattern.compile("\\d+-\\d(室|户|号|房|$)+$");
|
||||
static final Pattern HOUSE_NUMBER02 = Pattern.compile("\\d{1,4}(室|户|号|房|$)+$");
|
||||
static final Pattern ONLY_BUILDING_NUMBER_PATTERN = Pattern.compile("第?(\\w+-)?[\\w一二三四五六七八九十零百-]+((?:号楼)|(#楼)|栋|幢|座|#|号(?!院))");
|
||||
@Case(sample = "北京市大兴区丰台区丰台镇新华街四里2楼7门302号", model = "楼栋号单元号室号")
|
||||
static final Pattern BUILDING_UNIT_ROOM_PATTERN = Pattern.compile("\\d+楼\\d+门\\d{3,4}室");
|
||||
static final Pattern BUILDING_UNIT_HOUSE_PATTERN = Pattern.compile("\\w+-\\w+-\\d{3,4}(号|室|户)?");
|
||||
static final Pattern BUILDING_HOUSE_PATTERN_01 = Pattern.compile("\\w+-\\d{3,4}(号|室|户)?");//室号:2002-2003室 栋号+室号:D南-103楼 青岛室惯称户
|
||||
static final Pattern BUILDING_HOUSE_PATTERN_02 = Pattern.compile("\\w+号\\d{3,4}(号|室|户)?");//硚口区武胜路荣华东村24号301室
|
||||
static final Pattern HOUSE_NUMBER01 = Pattern.compile("\\d+-\\d(室|户|号|房|$)+$");
|
||||
static final Pattern HOUSE_NUMBER02 = Pattern.compile("\\d{1,4}(室|户|号|房|$)+$");
|
||||
static final Pattern ONLY_BUILDING_NUMBER_PATTERN = Pattern.compile("第?(\\w+-)?[\\w一二三四五六七八九十零百-]+((?:号楼)|(#楼)|栋|幢|座|#|号(?!院))");
|
||||
|
||||
public static void main(String[] args) {
|
||||
BuildingNumberProcessor processor = new BuildingNumberProcessor();
|
||||
Address address = new Address();
|
||||
address.setAddress("杭州市萧山区城厢镇金马名仕园1幢");
|
||||
address.setAddress("杭州市萧山区城厢镇金马名仕园1幢");
|
||||
RepeatStatus rstatus = processor.process(address);
|
||||
System.out.println(address.getAddress());
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class BuildingNumberProcessor extends AbstractAddressProcessor {
|
||||
if(matchResult != null){
|
||||
orgAddress = removeSubstring(orgAddress, matchResult.start, matchResult.end);
|
||||
String buildingNumberStr = matchResult.matchContent;
|
||||
buildingNumberStr = buildingNumberStr.replaceAll("幢|栋|(号楼)", "-");
|
||||
buildingNumberStr = buildingNumberStr.replaceAll("幢|栋|(号楼)", "-");
|
||||
String[] buildingNumberStrs = buildingNumberStr.split("-");
|
||||
address.setOrgBuildingNumber(buildingNumberStrs[0]);
|
||||
address.setOrgUnitNumber(buildingNumberStrs[1]);
|
||||
@@ -109,7 +109,7 @@ public class BuildingNumberProcessor extends AbstractAddressProcessor {
|
||||
if(matchResult != null){
|
||||
orgAddress = removeSubstring(orgAddress, matchResult.start, matchResult.end);
|
||||
String buildingNumberStr = matchResult.matchContent;
|
||||
buildingNumberStr = buildingNumberStr.replaceAll("幢|栋|(号楼)", "-");
|
||||
buildingNumberStr = buildingNumberStr.replaceAll("幢|栋|(号楼)", "-");
|
||||
String[] buildingNumberStrs = buildingNumberStr.split("-");
|
||||
address.setOrgBuildingNumber(buildingNumberStrs[0]);
|
||||
address.setFloor(buildingNumberStrs[1]);
|
||||
@@ -135,8 +135,8 @@ public class BuildingNumberProcessor extends AbstractAddressProcessor {
|
||||
address.setOrgBuildingNumber(buildingNumberStr);
|
||||
buildingNumberStr = buildingNumberStr.substring(0, buildingNumberStr.length() - 1);
|
||||
List<String> buildingNumbers = new ArrayList<String>();
|
||||
for (String b : buildingNumberStr.split("、")) {
|
||||
buildingNumbers.add(b + "栋");
|
||||
for (String b : buildingNumberStr.split("、")) {
|
||||
buildingNumbers.add(b + "栋");
|
||||
}
|
||||
address.setBuildingNumbers(buildingNumbers);
|
||||
address.setOrgBuildingNumber(getFirst(buildingNumbers));
|
||||
@@ -180,14 +180,14 @@ public class BuildingNumberProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
/**
|
||||
* http://www.gyfc.net.cn/pro_query/FloorList.aspx?yszh=2017033&qu=3
|
||||
* 武科东一路16号7-1-10-1
|
||||
* 7-1-10-1 第一个数字(7)楼栋号 1-10-1室号 1-10-1 首字母单元号
|
||||
* 武科东一路16号7-1-10-1
|
||||
* 7-1-10-1 第一个数字(7)楼栋号 1-10-1室号 1-10-1 首字母单元号
|
||||
* */
|
||||
matchResult = matchFirst(BUILDING_NUMBER_PATTERN_08, orgAddress);
|
||||
if(matchResult != null){
|
||||
orgAddress = removeSubstring(orgAddress, matchResult.start, matchResult.end);
|
||||
String buildingNumberStr = matchResult.matchContent;
|
||||
buildingNumberStr = buildingNumberStr.replaceAll("号|室", "");
|
||||
buildingNumberStr = buildingNumberStr.replaceAll("号|室", "");
|
||||
int idx = buildingNumberStr.indexOf("-");
|
||||
address.setBuildingNumber(buildingNumberStr.substring(0, idx));
|
||||
String roomNumber = buildingNumberStr.substring(idx + 1);
|
||||
@@ -200,26 +200,26 @@ public class BuildingNumberProcessor extends AbstractAddressProcessor {
|
||||
matchResult = matchFirst(BUILDING_UNIT_HOUSE_PATTERN, orgAddress);
|
||||
if (matchResult != null) {
|
||||
String[] spilt = matchResult.matchContent.split("-");
|
||||
address.setOrgBuildingNumber(spilt[0] + "栋");
|
||||
address.setOrgUnitNumber(spilt[1] + "单元");
|
||||
address.setOrgBuildingNumber(spilt[0] + "栋");
|
||||
address.setOrgUnitNumber(spilt[1] + "单元");
|
||||
if (isContiansRoomNumberUnit(spilt[2])) {
|
||||
address.setOrgRoomNumber(spilt[2]);
|
||||
} else {
|
||||
address.setOrgRoomNumber(spilt[2] + "室");
|
||||
address.setOrgRoomNumber(spilt[2] + "室");
|
||||
}
|
||||
orgAddress = removeSubstring(orgAddress, matchResult.start, matchResult.end);
|
||||
}
|
||||
matchResult = matchFirst(BUILDING_HOUSE_PATTERN_01, orgAddress);
|
||||
if (matchResult != null) {
|
||||
String[] spilt = matchResult.matchContent.split("-");
|
||||
if (AddressParserUtils.isNumber(spilt[0]) && spilt[1].replaceAll("号|室", "").length() == spilt[0].length()) {//2002-2003室
|
||||
if (AddressParserUtils.isNumber(spilt[0]) && spilt[1].replaceAll("号|室", "").length() == spilt[0].length()) {//2002-2003室
|
||||
address.setOrgRoomNumber(matchResult.matchContent);
|
||||
} else {
|
||||
address.setOrgBuildingNumber(spilt[0] + "栋");
|
||||
address.setOrgBuildingNumber(spilt[0] + "栋");
|
||||
if (isContiansRoomNumberUnit(spilt[1])) {
|
||||
address.setOrgRoomNumber(spilt[1]);
|
||||
} else {
|
||||
address.setOrgRoomNumber(spilt[1] + "室");
|
||||
address.setOrgRoomNumber(spilt[1] + "室");
|
||||
}
|
||||
}
|
||||
orgAddress = removeSubstring(orgAddress, matchResult.start, matchResult.end);
|
||||
@@ -227,9 +227,9 @@ public class BuildingNumberProcessor extends AbstractAddressProcessor {
|
||||
|
||||
matchResult = matchFirst(BUILDING_HOUSE_PATTERN_02, orgAddress);
|
||||
if (matchResult != null) {
|
||||
int index = matchResult.matchContent.indexOf("号");
|
||||
address.setOrgRoomNumber(matchResult.matchContent.substring(index + 1) + "室");
|
||||
address.setOrgBuildingNumber(matchResult.matchContent.substring(0, index + 1) + "栋");
|
||||
int index = matchResult.matchContent.indexOf("号");
|
||||
address.setOrgRoomNumber(matchResult.matchContent.substring(index + 1) + "室");
|
||||
address.setOrgBuildingNumber(matchResult.matchContent.substring(0, index + 1) + "栋");
|
||||
orgAddress = removeSubstring(orgAddress, matchResult.start, matchResult.end);
|
||||
}
|
||||
matchResult = matchFirst(UNIT_NUMBER_PATTERN_01, orgAddress);
|
||||
@@ -240,16 +240,16 @@ public class BuildingNumberProcessor extends AbstractAddressProcessor {
|
||||
matchResult = matchFirst(BUILDING_UNIT_ROOM_PATTERN, orgAddress);
|
||||
if(matchResult != null){
|
||||
orgAddress = removeSubstring(orgAddress, matchResult.start, matchResult.end);
|
||||
int buildIndex = matchResult.matchContent.indexOf("楼");
|
||||
int buildIndex = matchResult.matchContent.indexOf("楼");
|
||||
address.setOrgBuildingNumber(matchResult.matchContent.substring(0, buildIndex + 1));
|
||||
int unitIndex = matchResult.matchContent.indexOf("门");
|
||||
int unitIndex = matchResult.matchContent.indexOf("门");
|
||||
address.setOrgRoomNumber(matchResult.matchContent.substring(buildIndex + 1, unitIndex + 1));
|
||||
address.setOrgRoomNumber(matchResult.matchContent.substring(unitIndex + 1));
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(address.getOrgBuildingNumber()) && "上海".equals(address.getCity())
|
||||
&& StringUtils.isNotBlank(address.getStreet()) && address.getStreet().endsWith("弄") && StringUtils.isNotBlank(address.getStreetNumber())) {
|
||||
address.setBuildingNumber(address.getStreetNumber().replace("号", ""));
|
||||
if (StringUtils.isBlank(address.getOrgBuildingNumber()) && "上海".equals(address.getCity())
|
||||
&& StringUtils.isNotBlank(address.getStreet()) && address.getStreet().endsWith("弄") && StringUtils.isNotBlank(address.getStreetNumber())) {
|
||||
address.setBuildingNumber(address.getStreetNumber().replace("号", ""));
|
||||
address.setOrgBuildingNumber(address.getStreetNumber());
|
||||
}
|
||||
|
||||
@@ -285,13 +285,13 @@ public class BuildingNumberProcessor extends AbstractAddressProcessor {
|
||||
|
||||
|
||||
/**
|
||||
* 是否包含室号描述信息
|
||||
* 是否包含室号描述信息
|
||||
*
|
||||
* @param roomNumber
|
||||
* @return
|
||||
*/
|
||||
private boolean isContiansRoomNumberUnit(String roomNumber) {
|
||||
String[] roomNumberUnits = new String[]{"室", "号", "户"};
|
||||
String[] roomNumberUnits = new String[]{"室", "号", "户"};
|
||||
for (String unit : roomNumberUnits) {
|
||||
if (roomNumber.endsWith(unit)) {
|
||||
return Boolean.TRUE;
|
||||
@@ -301,17 +301,17 @@ public class BuildingNumberProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 排除非法楼栋号
|
||||
* 排除非法楼栋号
|
||||
*
|
||||
* @param matchResult
|
||||
* @param orgAddress
|
||||
* @return
|
||||
*/
|
||||
@Case(sample = "莲花7号小区5幢102室 ", model = "\\d+号小区")
|
||||
@Case(sample = "莲花7号小区5幢102室 ", model = "\\d+号小区")
|
||||
boolean validateBuildingMatchResult(MatchResult matchResult, String orgAddress) {
|
||||
String remain = orgAddress.substring(matchResult.end);
|
||||
|
||||
if (remain.startsWith("小区") || remain.startsWith("院")) {
|
||||
if (remain.startsWith("小区") || remain.startsWith("院")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
+36
-36
@@ -10,21 +10,21 @@ import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
*
|
||||
* 地址城市部分处理器
|
||||
* 规则01: city + 市
|
||||
* 规则02: city + district
|
||||
* 规则03: city + 得分
|
||||
* 地址城市部分处理器
|
||||
* 规则01: city + 市
|
||||
* 规则02: city + district
|
||||
* 规则03: city + 得分
|
||||
*/
|
||||
public class CityProcessor extends AbstractAddressProcessor {
|
||||
|
||||
static final Pattern CITY_PATTERN = Pattern.compile("^.{2,6}?市");
|
||||
static final Pattern REGION_PATTERN = Pattern.compile("^.{2,6}?([区县])");
|
||||
/**一些泛指的区域正则列表,不能使用这些区域推断城市*/
|
||||
static final List<Pattern> GENERIC_REGION_PATTERNS = Collections.singletonList(Pattern.compile(".*((高新)|(市辖)|(开发)|(新城区)|(辖区)).*"));
|
||||
static final List<String> EXCEPTION_DISTRICT = Arrays.asList("济南市中区","青岛市北区","青岛市南区","乐山市中区","内江市中区","枣庄市中区");
|
||||
static final Pattern CITY_PATTERN = Pattern.compile("^.{2,6}?市");
|
||||
static final Pattern REGION_PATTERN = Pattern.compile("^.{2,6}?([区县])");
|
||||
/**一些泛指的区域正则列表,不能使用这些区域推断城市*/
|
||||
static final List<Pattern> GENERIC_REGION_PATTERNS = Collections.singletonList(Pattern.compile(".*((高新)|(市辖)|(开发)|(新城区)|(辖区)).*"));
|
||||
static final List<String> EXCEPTION_DISTRICT = Arrays.asList("济南市中区","青岛市北区","青岛市南区","乐山市中区","内江市中区","枣庄市中区");
|
||||
|
||||
|
||||
/**城市:区域*/
|
||||
/**城市:区域*/
|
||||
static Map<String, Set<String>> CITY_REGION_MAP = new HashMap<String, Set<String>>();
|
||||
final static Logger logger = Logger.getLogger(CityProcessor.class);
|
||||
public CityProcessor(){
|
||||
@@ -37,14 +37,14 @@ public class CityProcessor extends AbstractAddressProcessor {
|
||||
String city = address.getCity();
|
||||
String orgAddress = address.getAddress();
|
||||
if(orgAddress.startsWith("-")){
|
||||
//吉林-松原-宁江区-青松小区
|
||||
//吉林-松原-宁江区-青松小区
|
||||
orgAddress = orgAddress.substring(1, orgAddress.length() -1);
|
||||
}
|
||||
for(String exceptionDistrict : EXCEPTION_DISTRICT){
|
||||
if(orgAddress.startsWith(exceptionDistrict)){
|
||||
String[] items = exceptionDistrict.split("市");
|
||||
String[] items = exceptionDistrict.split("市");
|
||||
address.setCity(items[0]);
|
||||
address.setDistrict("市" + items[1].replace("区", ""));
|
||||
address.setDistrict("市" + items[1].replace("区", ""));
|
||||
orgAddress = orgAddress.replaceFirst(exceptionDistrict, "");
|
||||
address.setAddress(orgAddress);
|
||||
return RepeatStatus.NEXT;
|
||||
@@ -55,7 +55,7 @@ public class CityProcessor extends AbstractAddressProcessor {
|
||||
address.setCity(formatCity);
|
||||
String possibleCity = AddressParserGoal.Match.equals(address.getAddressParserGoal()) || address.getAddressParserGoal() == null ? parseCityFromAddress(orgAddress, address) : null;
|
||||
String confirmCity = AddressParserGoal.Match.equals(address.getAddressParserGoal()) || address.getAddressParserGoal() == null? null : formatCity;
|
||||
/**如果省份和城市信息相互矛盾 则用区域推断城市*/
|
||||
/**如果省份和城市信息相互矛盾 则用区域推断城市*/
|
||||
if(StringUtils.isNotBlank(address.getProvince()) && !ProvinceData.belongTo(formatCity, address.getProvince())){
|
||||
List<String> possibleCities = speculateCityNameByRegion(address, city);
|
||||
if(isUnique(possibleCities)){
|
||||
@@ -72,7 +72,7 @@ public class CityProcessor extends AbstractAddressProcessor {
|
||||
address.setCityStatus(CityStatus.SURE);
|
||||
}
|
||||
if(!isValidCity(city)){
|
||||
/**如果城市是XX区县,先通过区县来推测城市*/
|
||||
/**如果城市是XX区县,先通过区县来推测城市*/
|
||||
if(matchFirst(REGION_PATTERN, city) != null){
|
||||
List<String> possibleCities = speculateCityNameByRegion(address, city);
|
||||
if(isUnique(possibleCities)){
|
||||
@@ -104,16 +104,16 @@ public class CityProcessor extends AbstractAddressProcessor {
|
||||
address.setCity(city);
|
||||
}
|
||||
if(StringUtils.isNotBlank(city) && scoreRegion(city, orgAddress) > 0.4){
|
||||
orgAddress = orgAddress.replaceFirst(".*" + address.getCity() + "[市县区州巿]?(?!(路|街|大道|巷|道|段))" , "");
|
||||
orgAddress = orgAddress.replaceFirst(".*" + address.getCity() + "[市县区州巿]?(?!(路|街|大道|巷|道|段))" , "");
|
||||
address.setAddress(orgAddress);
|
||||
address.setCityStatus(CityStatus.SURE);
|
||||
return RepeatStatus.NEXT;
|
||||
}
|
||||
if(CityStatus.SURE != address.getCityStatus() && !isValidCity(city)){
|
||||
/**县级市推断 比如昆山市是苏州的区域,把城市推断成苏州**/
|
||||
/**县级市推断 比如昆山市是苏州的区域,把城市推断成苏州**/
|
||||
MatchResult matchResult = matchFirst(CITY_PATTERN, orgAddress);
|
||||
if(matchResult != null){
|
||||
city = matchResult.matchContent.replaceAll("市$", "");//去掉市关键词
|
||||
city = matchResult.matchContent.replaceAll("市$", "");//去掉市关键词
|
||||
confirmCityByRegion(address, city, matchResult);
|
||||
}
|
||||
matchResult = matchFirst(REGION_PATTERN, orgAddress);
|
||||
@@ -131,7 +131,7 @@ public class CityProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过匹配的区域确认正确的城市
|
||||
* 通过匹配的区域确认正确的城市
|
||||
* @param address
|
||||
* @param region
|
||||
* @param matchResult
|
||||
@@ -154,7 +154,7 @@ public class CityProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 从地址中解析城市
|
||||
* 从地址中解析城市
|
||||
* @param address
|
||||
* @return
|
||||
*/
|
||||
@@ -172,7 +172,7 @@ public class CityProcessor extends AbstractAddressProcessor {
|
||||
String street = getStreet(address);
|
||||
for(String city : allCity){
|
||||
if(street != null){
|
||||
MatchResult matchResult = matchFirst(Pattern.compile(city + "[东南西北中一二三四五六七八九十百千\\d]?(路|街|大道|大街|支路|村)"), street);
|
||||
MatchResult matchResult = matchFirst(Pattern.compile(city + "[东南西北中一二三四五六七八九十百千\\d]?(路|街|大道|大街|支路|村)"), street);
|
||||
if(matchResult !=null){
|
||||
address = address.replace(matchResult.matchContent, "");
|
||||
}
|
||||
@@ -183,10 +183,10 @@ public class CityProcessor extends AbstractAddressProcessor {
|
||||
weight = new FragmentWeight();
|
||||
weight.text = city;
|
||||
}
|
||||
if(address.contains(city + "市")){
|
||||
index = address.indexOf(city + "市");
|
||||
if(address.contains(city + "市")){
|
||||
index = address.indexOf(city + "市");
|
||||
weight.index = index;
|
||||
index += + (city + "市").length();
|
||||
index += + (city + "市").length();
|
||||
if(province != null && (orgAddress.contains(province + city) || orgAddress.contains(ProvinceData.getDisplay(province) + city))){
|
||||
weight.score += 3;
|
||||
}else{
|
||||
@@ -202,11 +202,11 @@ public class CityProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
Map<String, List<String>> regionMap = RegionData.getAllRegions(city);
|
||||
for(String region : regionMap.keySet()){
|
||||
MatchResult matchResult = matchFirst(Pattern.compile(region + "[东南西北中一二三四五六七八九十百千\\d]?(路|街|大道|大街|支路|村)"), street);
|
||||
MatchResult matchResult = matchFirst(Pattern.compile(region + "[东南西北中一二三四五六七八九十百千\\d]?(路|街|大道|大街|支路|村)"), street);
|
||||
if(matchResult !=null){
|
||||
address = address.replace(matchResult.matchContent, "");
|
||||
}
|
||||
if(address.indexOf(region + "区", index) > -1 || address.indexOf(region + "县", index) > -1){
|
||||
if(address.indexOf(region + "区", index) > -1 || address.indexOf(region + "县", index) > -1){
|
||||
if(province != null && (orgAddress.contains(province + region) || orgAddress.contains(ProvinceData.getDisplay(province) + region))){
|
||||
weight.score += 2;
|
||||
}else if(city.equals(addr.getCity())){
|
||||
@@ -222,7 +222,7 @@ public class CityProcessor extends AbstractAddressProcessor {
|
||||
if(alias != null){
|
||||
for(String alia : alias){
|
||||
if(StringUtils.isNotBlank(alia) && !alia.equals(region) && alia.length() > 2 && address.indexOf(alia, index) > -1
|
||||
&& (alia.endsWith("市")|(alia.endsWith("县")))){
|
||||
&& (alia.endsWith("市")|(alia.endsWith("县")))){
|
||||
if(city.equals(addr.getCity())){
|
||||
weight.score += 10;
|
||||
}else{
|
||||
@@ -251,7 +251,7 @@ public class CityProcessor extends AbstractAddressProcessor {
|
||||
|
||||
|
||||
/**
|
||||
* 判断是不是合法的城市
|
||||
* 判断是不是合法的城市
|
||||
* @param cityName
|
||||
* @return
|
||||
*/
|
||||
@@ -260,7 +260,7 @@ public class CityProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断region是否属于city
|
||||
* 判断region是否属于city
|
||||
* @param city
|
||||
* @param region
|
||||
* @return
|
||||
@@ -274,8 +274,8 @@ public class CityProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 推测真正的城市名
|
||||
* @param address 参考省份
|
||||
* 推测真正的城市名
|
||||
* @param address 参考省份
|
||||
* @param regionName
|
||||
*/
|
||||
List<String> speculateCityNameByRegion(Address address,String regionName){
|
||||
@@ -293,10 +293,10 @@ public class CityProcessor extends AbstractAddressProcessor {
|
||||
allCity = ProvinceData.getAllCity();
|
||||
}
|
||||
List<String> foundCityList = new ArrayList<String>();
|
||||
/**根据区域推测所在的城市*/
|
||||
/**根据区域推测所在的城市*/
|
||||
String temp;
|
||||
for(String city : allCity){
|
||||
temp = regionName.replaceFirst("^" + city, "");//排除无"市"标示的城市信息干扰 如:北京海定区
|
||||
temp = regionName.replaceFirst("^" + city, "");//排除无"市"标示的城市信息干扰 如:北京海定区
|
||||
if(CITY_REGION_MAP.get(city).contains(temp)){
|
||||
foundCityList.add(city);
|
||||
}
|
||||
@@ -305,7 +305,7 @@ public class CityProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据城市名推测正确的城市名
|
||||
* 根据城市名推测正确的城市名
|
||||
* @param orgName
|
||||
* @return
|
||||
*/
|
||||
@@ -325,7 +325,7 @@ public class CityProcessor extends AbstractAddressProcessor {
|
||||
if(!CITY_REGION_MAP.isEmpty()){
|
||||
return;
|
||||
}
|
||||
logger.info("开始加载区域信息!");
|
||||
logger.info("开始加载区域信息!");
|
||||
Map<String, Map<String, List<String>>> regionData = RegionData.getRegionDataMap();
|
||||
for(Map.Entry<String ,Map<String, List<String>>> entry : regionData.entrySet()){
|
||||
Map<String,List<String>> regionMap = entry.getValue();
|
||||
@@ -338,7 +338,7 @@ public class CityProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
CITY_REGION_MAP.put(entry.getKey(),regions);
|
||||
}
|
||||
logger.info("区域信息加载结束!");
|
||||
logger.info("区域信息加载结束!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-6
@@ -9,18 +9,18 @@ import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 方位解析器
|
||||
* 方位解析器
|
||||
* Created by wenyan on 2015/5/5.
|
||||
*/
|
||||
public class DirectionProcessor extends AbstractAddressProcessor {
|
||||
|
||||
private static final Pattern STREET_DIR_PATTERN = Pattern.compile("^.+(路|街道|街|弄|大道|巷|道|((一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)(线|环)))((以(东|南|西|北))|(附近)|(旁边)|((东|南|西|北|中)段)|(对面)|(交口)|(交叉口)|(交汇处)|((东|南|西|北)(角|侧)*))+");
|
||||
private static final Pattern DIR_PATTERN_PATTERN = Pattern.compile("(以(东|南|西|北))|(附近)|(旁边)|((东|南|西|北|中)段)|(对面)|(交口)|(交叉口)|(交汇处)|((东|南|西|北)侧)|((?<=(路|道|弄))(东|南|西|北))");
|
||||
private static final Pattern STREET_DIR_PATTERN = Pattern.compile("^.+(路|街道|街|弄|大道|巷|道|((一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)(线|环)))((以(东|南|西|北))|(附近)|(旁边)|((东|南|西|北|中)段)|(对面)|(交口)|(交叉口)|(交汇处)|((东|南|西|北)(角|侧)*))+");
|
||||
private static final Pattern DIR_PATTERN_PATTERN = Pattern.compile("(以(东|南|西|北))|(附近)|(旁边)|((东|南|西|北|中)段)|(对面)|(交口)|(交叉口)|(交汇处)|((东|南|西|北)侧)|((?<=(路|道|弄))(东|南|西|北))");
|
||||
|
||||
private static final Map<String,String> DIRS = new HashMap<String,String>(){{
|
||||
put("交叉口","交汇");
|
||||
put("交口","交汇");
|
||||
put("交汇处","交汇");
|
||||
put("交叉口","交汇");
|
||||
put("交口","交汇");
|
||||
put("交汇处","交汇");
|
||||
}};
|
||||
|
||||
@Override
|
||||
|
||||
+11
-11
@@ -15,19 +15,19 @@ import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 解析区域信息
|
||||
* case01:青海省互助土族自治县迎宾大道22号D3幢1-37号
|
||||
* 解析区域信息
|
||||
* case01:青海省互助土族自治县迎宾大道22号D3幢1-37号
|
||||
* @author wenyan
|
||||
*/
|
||||
public class DistrictProcessor extends AbstractAddressProcessor {
|
||||
|
||||
|
||||
static final String[] DISTRICT_NOISE = new String[]{"新城区","新区" , "城区", "市区" ,"辖区", "其他地区", "市辖区"};
|
||||
static final String[] SPECIAL_CITY_DISTRICT_NOISE = new String[]{"城南", "城北", "城西", "城东", "新城区","新区" , "城区", "市区" ,"辖区", "其他地区", "市辖区"};
|
||||
/**开发区列表*/
|
||||
static final String[] DEVELOPMENT_ZONE_LIST = new String[]{"高新技术开发区","经济开发区", "经济技术开发区", "经开区" , "高新区", "高新技术开发区", "开发区", "经济技术开发区", "工业园区"};
|
||||
/*区域特征正则*/
|
||||
static final String DISTRICT_SUFFIX_REGEX = "(县城|区|县|市|镇)";
|
||||
static final String[] DISTRICT_NOISE = new String[]{"新城区","新区" , "城区", "市区" ,"辖区", "其他地区", "市辖区"};
|
||||
static final String[] SPECIAL_CITY_DISTRICT_NOISE = new String[]{"城南", "城北", "城西", "城东", "新城区","新区" , "城区", "市区" ,"辖区", "其他地区", "市辖区"};
|
||||
/**开发区列表*/
|
||||
static final String[] DEVELOPMENT_ZONE_LIST = new String[]{"高新技术开发区","经济开发区", "经济技术开发区", "经开区" , "高新区", "高新技术开发区", "开发区", "经济技术开发区", "工业园区"};
|
||||
/*区域特征正则*/
|
||||
static final String DISTRICT_SUFFIX_REGEX = "(县城|区|县|市|镇)";
|
||||
|
||||
@Override
|
||||
public RepeatStatus process(Address address) {
|
||||
@@ -35,10 +35,10 @@ public class DistrictProcessor extends AbstractAddressProcessor {
|
||||
Map<String, List<String>> regions = RegionData.getAllRegions(address.getCity());
|
||||
String orgAddress = address.getAddress();
|
||||
if(orgAddress.startsWith("-")){
|
||||
//吉林-松原-宁江区-青松小区
|
||||
//吉林-松原-宁江区-青松小区
|
||||
orgAddress = orgAddress.replace("-", "");
|
||||
}
|
||||
List<String> ziZhiQu = Arrays.asList(new String[]{"自治区", "自治县", "自治州"});
|
||||
List<String> ziZhiQu = Arrays.asList(new String[]{"自治区", "自治县", "自治州"});
|
||||
for(String r:ziZhiQu){
|
||||
int index = orgAddress.indexOf(r);
|
||||
if(index > -1){
|
||||
@@ -52,7 +52,7 @@ public class DistrictProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
String street = getStreet(orgAddress);
|
||||
String[] districtNoise = DISTRICT_NOISE;
|
||||
if("重庆".equals(address.getCity()) || "成都".equals(address.getCity())){
|
||||
if("重庆".equals(address.getCity()) || "成都".equals(address.getCity())){
|
||||
districtNoise = SPECIAL_CITY_DISTRICT_NOISE;
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -7,13 +7,13 @@ import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
*
|
||||
* 楼层解析
|
||||
* 楼层解析
|
||||
* @author wenyan
|
||||
*/
|
||||
public class FloorProcessor extends AbstractAddressProcessor {
|
||||
|
||||
static final Pattern FLOOR_PATTERN = Pattern.compile("(第?(\\d|一|二|三|四|五|六|七|八|九|十|零|百|千)+层?(-|~|到|至))?第?(\\d|一|二|三|四|五|六|七|八|九|十|零|百|千)+(层|楼)");
|
||||
static final Pattern FLOOR_DESC_PATTERN = Pattern.compile("小?[高低中]层");
|
||||
static final Pattern FLOOR_PATTERN = Pattern.compile("(第?(\\d|一|二|三|四|五|六|七|八|九|十|零|百|千)+层?(-|~|到|至))?第?(\\d|一|二|三|四|五|六|七|八|九|十|零|百|千)+(层|楼)");
|
||||
static final Pattern FLOOR_DESC_PATTERN = Pattern.compile("小?[高低中]层");
|
||||
|
||||
@Override
|
||||
public RepeatStatus process(Address address) {
|
||||
@@ -22,10 +22,10 @@ public class FloorProcessor extends AbstractAddressProcessor {
|
||||
MatchResult matchResult = matchFirst(FLOOR_PATTERN, orgAddress);
|
||||
if(matchResult != null){
|
||||
String floorDesc = matchResult.matchContent;
|
||||
int louIndex = floorDesc.indexOf('楼');
|
||||
int floorIndex = floorDesc.indexOf('层');
|
||||
int louIndex = floorDesc.indexOf('楼');
|
||||
int floorIndex = floorDesc.indexOf('层');
|
||||
if (louIndex > 0 && floorIndex > 0 && louIndex < floorIndex) {
|
||||
String buildingNumber = floorDesc.substring(0, floorDesc.indexOf("楼") + 1);
|
||||
String buildingNumber = floorDesc.substring(0, floorDesc.indexOf("楼") + 1);
|
||||
String floor = floorDesc.replaceFirst(buildingNumber, "");
|
||||
address.setOrgBuildingNumber(buildingNumber);
|
||||
address.setFloor(floor);
|
||||
|
||||
+4
-4
@@ -13,12 +13,12 @@ import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author 王文艳
|
||||
* @author 王文艳
|
||||
* @create 2016-09-26
|
||||
**/
|
||||
public class FormatProcessor extends AbstractAddressProcessor {
|
||||
|
||||
private static final Pattern QUANTIFIER_PATTERN = Pattern.compile("[\\w\\d东西南北甲乙丙丁戊己庚东南西北一二三四五六七八九十-]+", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern QUANTIFIER_PATTERN = Pattern.compile("[\\w\\d东西南北甲乙丙丁戊己庚东南西北一二三四五六七八九十-]+", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
@Override
|
||||
public RepeatStatus process(Address address) {
|
||||
@@ -42,7 +42,7 @@ public class FormatProcessor extends AbstractAddressProcessor {
|
||||
if(StringUtils.isNotBlank(address.getFloor())){
|
||||
address.setFloor(removeUnit(address.getFloor()));
|
||||
}
|
||||
if(address.getStreetNumbers() != null || (address.getStreet() != null && address.getStreet().endsWith("弄"))){
|
||||
if(address.getStreetNumbers() != null || (address.getStreet() != null && address.getStreet().endsWith("弄"))){
|
||||
address.setStandardAddress(true);
|
||||
Map<String, String> standardAddressMap = new HashMap<String, String>();
|
||||
if(!CollectionUtils.isEmpty(address.getStreetNumbers())){
|
||||
@@ -52,7 +52,7 @@ public class FormatProcessor extends AbstractAddressProcessor {
|
||||
standardAddressMap.put(standardAddressPinYin, standardAddress);
|
||||
}
|
||||
}
|
||||
if(address.getStreet().endsWith("弄")){
|
||||
if(address.getStreet().endsWith("弄")){
|
||||
standardAddressMap.put(address.getStreetPinYin(), address.getStreet());
|
||||
}
|
||||
address.setStandardAddressMap(standardAddressMap);
|
||||
|
||||
+5
-5
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 地址经纬度处理器
|
||||
* 地址经纬度处理器
|
||||
*
|
||||
* @author wenyan
|
||||
*/
|
||||
@@ -21,7 +21,7 @@ public class GeoProcessor extends AbstractAddressProcessor {
|
||||
|
||||
private static final String KEY = "94d4f0e7d11745e84419a68104c06315";
|
||||
private static final Logger logger = Logger.getLogger(GeoProcessor.class);
|
||||
List<String> POI_LEVELS = Arrays.asList("村庄", "热点商圈", "兴趣点", "门牌号", "单元号", "道路交叉路口", "门牌号");
|
||||
List<String> POI_LEVELS = Arrays.asList("村庄", "热点商圈", "兴趣点", "门牌号", "单元号", "道路交叉路口", "门牌号");
|
||||
|
||||
@Override
|
||||
public RepeatStatus process(Address address) {
|
||||
@@ -40,7 +40,7 @@ public class GeoProcessor extends AbstractAddressProcessor {
|
||||
params.put("output", "json");
|
||||
try {
|
||||
JSONObject response = request.getJsonContent("https://restapi.amap.com/v3/geocode/geo", params, "UTF-8");
|
||||
logger.info("高德API:" + response.toString());
|
||||
logger.info("高德API:" + response.toString());
|
||||
if (response.getInt("status") == 1) {
|
||||
JSONArray geocodes = response.getJSONArray("geocodes");
|
||||
JSONObject json = null;
|
||||
@@ -63,8 +63,8 @@ public class GeoProcessor extends AbstractAddressProcessor {
|
||||
address.setGeoRegion(region);
|
||||
}
|
||||
if(POI_LEVELS.contains(json.getString("level"))){
|
||||
//对于门牌号级别的POI,formatted_address中包含|代表是推测出来的路号,重庆市巴南区凤林路|808号,|号楼
|
||||
if("门牌号".equals(json.getString("level"))){
|
||||
//对于门牌号级别的POI,formatted_address中包含|代表是推测出来的路号,重庆市巴南区凤林路|808号,|号楼
|
||||
if("门牌号".equals(json.getString("level"))){
|
||||
if(!(json.get("number") instanceof JSONArray) && json.getString("formatted_address").contains("|" + json.getString("number"))){
|
||||
return RepeatStatus.NEXT;
|
||||
}
|
||||
|
||||
+12
-12
@@ -11,19 +11,19 @@ import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 后置噪音处理器
|
||||
* 后置噪音处理器
|
||||
* case01:
|
||||
* Created by wenyan on 2015/5/6.
|
||||
*/
|
||||
public class KeywordProcessor extends AbstractAddressProcessor {
|
||||
|
||||
static final List<String> noises = Arrays.asList("\\\\", "、");
|
||||
static final List<String> KEYWORDS_SUFFIX = Arrays.asList("莊","村","小镇","阁","园","庭","邸","苑","城","楼","居","府","郡","胡同", "天下","期","湾","都","公寓","小区","社区", "商住楼", "商铺","宿舍","都市","写字楼","大厦","公司","广厦","商厦","别墅","岸","商业中心","广场","年华","小镇","半岛","公司","天地","名门","时代","生活区","公馆","国际","家属楼","庭院","号院","会所","台","里","市场","期","区","别墅","公司", "商业广场", "花园", "自然村", "生活区", "家属楼", "住宅楼","综合楼");
|
||||
static final List<Pattern> KEYWORDS_PATTERNS = Arrays.asList(Pattern.compile(".*[^一二三四五六七八九十\\d]{3,}号"));
|
||||
static final List<String> KEYWORDS = Arrays.asList("居委会", "辖区", "街道办", "街道", "办事处", "村委", "管理区");
|
||||
static final List<Pattern> NOISE_PATTERNS = Arrays.asList(Pattern.compile("^.*\\d+队"), Pattern.compile("^\\d+号院$"));
|
||||
static final List<Pattern> INVALID_KEYWORD_PATTERN = Arrays.asList(Pattern.compile("^[一二三四五六七八九十甲乙丙丁戊己庚辛A-Z\\d]+[区期]$"), Pattern.compile("碧桂园"), Pattern.compile("住宅楼"), Pattern.compile("家属[区院]"), Pattern.compile("宿舍"), Pattern.compile("生活区"), Pattern.compile("公寓"));
|
||||
static final Pattern INVALID_PATTERN = Pattern.compile("^([-\\\\、])+$");
|
||||
static final List<String> noises = Arrays.asList("\\\\", "、");
|
||||
static final List<String> KEYWORDS_SUFFIX = Arrays.asList("莊","村","小镇","阁","园","庭","邸","苑","城","楼","居","府","郡","胡同", "天下","期","湾","都","公寓","小区","社区", "商住楼", "商铺","宿舍","都市","写字楼","大厦","公司","广厦","商厦","别墅","岸","商业中心","广场","年华","小镇","半岛","公司","天地","名门","时代","生活区","公馆","国际","家属楼","庭院","号院","会所","台","里","市场","期","区","别墅","公司", "商业广场", "花园", "自然村", "生活区", "家属楼", "住宅楼","综合楼");
|
||||
static final List<Pattern> KEYWORDS_PATTERNS = Arrays.asList(Pattern.compile(".*[^一二三四五六七八九十\\d]{3,}号"));
|
||||
static final List<String> KEYWORDS = Arrays.asList("居委会", "辖区", "街道办", "街道", "办事处", "村委", "管理区");
|
||||
static final List<Pattern> NOISE_PATTERNS = Arrays.asList(Pattern.compile("^.*\\d+队"), Pattern.compile("^\\d+号院$"));
|
||||
static final List<Pattern> INVALID_KEYWORD_PATTERN = Arrays.asList(Pattern.compile("^[一二三四五六七八九十甲乙丙丁戊己庚辛A-Z\\d]+[区期]$"), Pattern.compile("碧桂园"), Pattern.compile("住宅楼"), Pattern.compile("家属[区院]"), Pattern.compile("宿舍"), Pattern.compile("生活区"), Pattern.compile("公寓"));
|
||||
static final Pattern INVALID_PATTERN = Pattern.compile("^([-\\\\、])+$");
|
||||
|
||||
|
||||
@Override
|
||||
@@ -35,7 +35,7 @@ public class KeywordProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
String keywords;
|
||||
if(address.hasTooltip()){//优先使用括号中的小区名
|
||||
if(address.hasTooltip()){//优先使用括号中的小区名
|
||||
keywords = fetchKeywords(address.getTooltip());
|
||||
if(keywords != null){
|
||||
address.setKeywords(keywords);
|
||||
@@ -158,7 +158,7 @@ public class KeywordProcessor extends AbstractAddressProcessor {
|
||||
int index = -1;
|
||||
int kl = 0;
|
||||
String keywords = null;
|
||||
for(String suffix : KEYWORDS_SUFFIX){//根据关键字后缀,查找最长的关键词
|
||||
for(String suffix : KEYWORDS_SUFFIX){//根据关键字后缀,查找最长的关键词
|
||||
if(str.lastIndexOf(suffix) > index){
|
||||
kl = suffix.length();
|
||||
index = str.lastIndexOf(suffix);
|
||||
@@ -166,7 +166,7 @@ public class KeywordProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
if(index > 1){
|
||||
keywords = str.substring(0 ,index + kl);
|
||||
if(keywords.endsWith("环城") || keywords.endsWith("公园")){
|
||||
if(keywords.endsWith("环城") || keywords.endsWith("公园")){
|
||||
return null;
|
||||
}
|
||||
}else{
|
||||
@@ -183,7 +183,7 @@ public class KeywordProcessor extends AbstractAddressProcessor {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if(keywords != null && !KEYWORDS_SUFFIX.contains(keywords)){//关键词不能和关键词一致
|
||||
if(keywords != null && !KEYWORDS_SUFFIX.contains(keywords)){//关键词不能和关键词一致
|
||||
return keywords;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class LoopLineProcessor extends AbstractAddressProcessor {
|
||||
|
||||
static final Pattern LOOP_LINE_PATTERN = Pattern.compile("([东南西北]?(一|二|三|四|五|六|七|八|九|十|外|中|内)环(以内|以外|外)*)+(((到|至)*[东南西北]?(一|二|三|四|五|六|七|八|九|十|外|中|内)环)*(之间)*)*");
|
||||
static final Pattern LOOP_LINE_PATTERN = Pattern.compile("([东南西北]?(一|二|三|四|五|六|七|八|九|十|外|中|内)环(以内|以外|外)*)+(((到|至)*[东南西北]?(一|二|三|四|五|六|七|八|九|十|外|中|内)环)*(之间)*)*");
|
||||
@Override
|
||||
public RepeatStatus process(Address address) {
|
||||
String orgAddr = address.getAddress();
|
||||
@@ -35,13 +35,13 @@ public class LoopLineProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 对环线数据打分
|
||||
* 对环线数据打分
|
||||
* @param loopLine
|
||||
* @param street
|
||||
* @return
|
||||
*/
|
||||
double scoreLoopLine(String loopLine, String street){
|
||||
if (match(street, "^" + loopLine + "[东南西北中]?(路|街|大道|镇|大街)")) {
|
||||
if (match(street, "^" + loopLine + "[东南西北中]?(路|街|大道|镇|大街)")) {
|
||||
return 0;
|
||||
}
|
||||
return 1 - loopLine.length() / Float.parseFloat(street.length() + "");
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import com.fangjia.service.address.mode.Address;
|
||||
/**
|
||||
*
|
||||
* @author wenyan
|
||||
* 中文数字转成阿拉伯数字
|
||||
* 中文数字转成阿拉伯数字
|
||||
*/
|
||||
public class NumericProcessor extends AbstractAddressProcessor {
|
||||
|
||||
|
||||
+2
-2
@@ -6,12 +6,12 @@ import java.util.regex.Pattern;
|
||||
|
||||
|
||||
/**
|
||||
* 位置偏移解析器
|
||||
* 位置偏移解析器
|
||||
* @author wenyan
|
||||
*/
|
||||
public class OffsetProcessor extends AbstractAddressProcessor {
|
||||
|
||||
private static final Pattern OFFSET_PATTERN_PATTERN = Pattern.compile("(向|往)?(东|南|西|北)*\\d+(\\.\\d)?(m|米)处?(路[东南西北])?");
|
||||
private static final Pattern OFFSET_PATTERN_PATTERN = Pattern.compile("(向|往)?(东|南|西|北)*\\d+(\\.\\d)?(m|米)处?(路[东南西北])?");
|
||||
|
||||
@Override
|
||||
public RepeatStatus process(Address address) {
|
||||
|
||||
+7
-7
@@ -9,26 +9,26 @@ import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 前置噪音处理器
|
||||
* 前置噪音处理器
|
||||
* @author wenyan
|
||||
*/
|
||||
public class PreNoiseProcessor extends AbstractAddressProcessor {
|
||||
|
||||
/**
|
||||
* "" + (char)160 特殊空白字符
|
||||
* "" + (char)8226 特殊?
|
||||
* "" + (char)160 特殊空白字符
|
||||
* "" + (char)8226 特殊?
|
||||
*/
|
||||
static final List<String> noises = Arrays.asList(".", "?","?", "·", "`",",", ",", "。","房产","土地","位于","其他", "座落于","商品房","售楼处","^","?", "" + (char)160, "" + (char)8226);
|
||||
static final Pattern DISTRICT_PATTERN = Pattern.compile("[\\u4e00-\\u9fa5]+(市|县|区)");
|
||||
static final List<String> noises = Arrays.asList(".", "?","?", "·", "`",",", ",", "。","房产","土地","位于","其他", "座落于","商品房","售楼处","^","?", "" + (char)160, "" + (char)8226);
|
||||
static final Pattern DISTRICT_PATTERN = Pattern.compile("[\\u4e00-\\u9fa5]+(市|县|区)");
|
||||
|
||||
@Override
|
||||
public RepeatStatus process(Address address) {
|
||||
String orgAddress = address.getAddress();
|
||||
orgAddress = DataUtil.toDBCcase(orgAddress).replaceAll("\\s+", "");
|
||||
orgAddress = orgAddress.replace("—","-");
|
||||
orgAddress = orgAddress.replace("—","-");
|
||||
orgAddress = orgAddress.replace("_", "-");
|
||||
orgAddress = orgAddress.replace("*", ".");
|
||||
orgAddress = orgAddress.replaceAll("(\\w+-)*\\w+号?地块", "");
|
||||
orgAddress = orgAddress.replaceAll("(\\w+-)*\\w+号?地块", "");
|
||||
MatchResult matchResult = matchFirst(DISTRICT_PATTERN, orgAddress);
|
||||
if(matchResult != null){
|
||||
String newPart = matchResult.matchContent.replace("-", "");
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import com.fangjia.service.address.mode.Address;
|
||||
import com.fangjia.service.address.mode.ProvinceData;
|
||||
|
||||
/**
|
||||
* 根据城市推断出地址所在的省份
|
||||
* 根据城市推断出地址所在的省份
|
||||
*
|
||||
* @author wenyan
|
||||
*/
|
||||
|
||||
+7
-7
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 省份信息解析器
|
||||
* 省份信息解析器
|
||||
*
|
||||
* @author wenyan
|
||||
*/
|
||||
@@ -30,19 +30,19 @@ public class ProvinceProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
if (null != provinceInfo) {
|
||||
String province = provinceInfo[NAME_IDX];
|
||||
if (provinceInfo[FULL_NAME_IDX] != null) {//全称匹配
|
||||
if (provinceInfo[FULL_NAME_IDX] != null) {//全称匹配
|
||||
int idx = orgAddress.indexOf(provinceInfo[FULL_NAME_IDX]);
|
||||
orgAddress = orgAddress.substring(idx + provinceInfo[FULL_NAME_IDX].length());
|
||||
address.setProvince(province);
|
||||
} else {//简称匹配
|
||||
} else {//简称匹配
|
||||
String street = getStreet(orgAddress);
|
||||
if(containsCityOfTheProvince(province, orgAddress) || containsCityOfTheProvince(province, address.getCity())){//如果地址中包含该省份的城市则认为省份正确
|
||||
if(containsCityOfTheProvince(province, orgAddress) || containsCityOfTheProvince(province, address.getCity())){//如果地址中包含该省份的城市则认为省份正确
|
||||
address.setProvince(provinceInfo[NAME_IDX]);
|
||||
int idx = orgAddress.indexOf(provinceInfo[NAME_IDX]);
|
||||
if(idx > -1){
|
||||
orgAddress = orgAddress.substring(idx + provinceInfo[NAME_IDX].length());
|
||||
}
|
||||
}else if (scoreRegion(provinceInfo[NAME_IDX], street == null ? orgAddress : street) > 0.4) {//如果省份占道路的比例少则认为省份正确
|
||||
}else if (scoreRegion(provinceInfo[NAME_IDX], street == null ? orgAddress : street) > 0.4) {//如果省份占道路的比例少则认为省份正确
|
||||
int idx = orgAddress.indexOf(provinceInfo[NAME_IDX]);
|
||||
orgAddress = orgAddress.substring(idx + provinceInfo[NAME_IDX].length());
|
||||
address.setProvince(provinceInfo[NAME_IDX]);
|
||||
@@ -100,7 +100,7 @@ public class ProvinceProcessor extends AbstractAddressProcessor {
|
||||
if (address.startsWith(name)) {
|
||||
result[0] = name;
|
||||
return result;
|
||||
}else if(address.startsWith("中国" + name)){
|
||||
}else if(address.startsWith("中国" + name)){
|
||||
result[0] = name;
|
||||
return result;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ public class ProvinceProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 省份简称
|
||||
* 省份简称
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
|
||||
+42
-42
@@ -8,48 +8,48 @@ import java.util.Map;
|
||||
public class ProximalCharactersProcessor extends AbstractAddressProcessor{
|
||||
|
||||
private static final Map<String, String> PROXIMAL_CHARACTERS = new HashMap<String, String>(){{
|
||||
put("青市岛", "青岛市");
|
||||
put("华节市", "毕节市");
|
||||
put("北京山区", "北京房山区");
|
||||
put("绵羊市", "绵阳市");
|
||||
put("彿山", "佛山");
|
||||
put("海定区", "海淀区");
|
||||
put("枣莊市", "枣庄市");
|
||||
put("武候区", "武侯区");
|
||||
put("闽行区", "闵行区");
|
||||
put("杨州市", "扬州市");
|
||||
put("湘谭市", "湘潭市");
|
||||
put("渖阳", "沈阳");
|
||||
put("广洲市", "广州市");
|
||||
put("福洲", "福州");
|
||||
put("杭洲", "杭州");
|
||||
put("滨洲", "滨州");
|
||||
put("鸟当区", "乌当区");
|
||||
put("土默特右旗", "土右旗");
|
||||
put("科尔沁左翼后旗", "科左后旗");
|
||||
put("下关区", "鼓楼区");
|
||||
put("广柬", "广东");
|
||||
put("南京市鼓区", "南京市鼓楼区");
|
||||
put("松红区", "松江区");
|
||||
put("建业区", "建邺区");
|
||||
put("石家莊", "石家庄");
|
||||
put("苏洲市", "苏州市");
|
||||
put("堔圳市", "深圳市");
|
||||
put("啓东市", "启东市");
|
||||
put("除州市", "滁州市");
|
||||
put("潁上县", "颍上县");
|
||||
put("开元市", "开原市");
|
||||
put("恵州市", "惠州市");
|
||||
put("四川重庆市", "重庆市");
|
||||
put("四川省重庆市", "重庆市");
|
||||
put("河北省北京市", "北京市");
|
||||
put("河北北京市", "北京市");
|
||||
put("河北省天津市", "天津市");
|
||||
put("河北天津市", "天津市");
|
||||
put("浙江上海市", "上海市");
|
||||
put("浙江省上海市", "上海市");
|
||||
put("江苏省上海市", "上海市");
|
||||
put("江苏上海市", "上海市");
|
||||
put("青市岛", "青岛市");
|
||||
put("华节市", "毕节市");
|
||||
put("北京山区", "北京房山区");
|
||||
put("绵羊市", "绵阳市");
|
||||
put("彿山", "佛山");
|
||||
put("海定区", "海淀区");
|
||||
put("枣莊市", "枣庄市");
|
||||
put("武候区", "武侯区");
|
||||
put("闽行区", "闵行区");
|
||||
put("杨州市", "扬州市");
|
||||
put("湘谭市", "湘潭市");
|
||||
put("渖阳", "沈阳");
|
||||
put("广洲市", "广州市");
|
||||
put("福洲", "福州");
|
||||
put("杭洲", "杭州");
|
||||
put("滨洲", "滨州");
|
||||
put("鸟当区", "乌当区");
|
||||
put("土默特右旗", "土右旗");
|
||||
put("科尔沁左翼后旗", "科左后旗");
|
||||
put("下关区", "鼓楼区");
|
||||
put("广柬", "广东");
|
||||
put("南京市鼓区", "南京市鼓楼区");
|
||||
put("松红区", "松江区");
|
||||
put("建业区", "建邺区");
|
||||
put("石家莊", "石家庄");
|
||||
put("苏洲市", "苏州市");
|
||||
put("堔圳市", "深圳市");
|
||||
put("啓东市", "启东市");
|
||||
put("除州市", "滁州市");
|
||||
put("潁上县", "颍上县");
|
||||
put("开元市", "开原市");
|
||||
put("恵州市", "惠州市");
|
||||
put("四川重庆市", "重庆市");
|
||||
put("四川省重庆市", "重庆市");
|
||||
put("河北省北京市", "北京市");
|
||||
put("河北北京市", "北京市");
|
||||
put("河北省天津市", "天津市");
|
||||
put("河北天津市", "天津市");
|
||||
put("浙江上海市", "上海市");
|
||||
put("浙江省上海市", "上海市");
|
||||
put("江苏省上海市", "上海市");
|
||||
put("江苏上海市", "上海市");
|
||||
|
||||
}};
|
||||
|
||||
|
||||
+10
-10
@@ -7,18 +7,18 @@ import org.apache.commons.lang.StringUtils;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 解析房间号
|
||||
* case01:东氿壹号133-405室
|
||||
* case02:青岛市市北区山东路111号1室
|
||||
* 解析房间号
|
||||
* case01:东氿壹号133-405室
|
||||
* case02:青岛市市北区山东路111号1室
|
||||
*/
|
||||
public class RoomNumberProcessor extends AbstractAddressProcessor {
|
||||
|
||||
static final Pattern HOUSE_PATTERN = Pattern.compile("(((((?<=\\D)\\w{3,4})$)|((?<=\\D)\\w{1,4}(?:[室房户]|(?:号房))))-)?((((?<=\\D)*\\w{3,4})$)|(\\w{1,4}(?:[室房户铺]|(?:号房))))", Pattern.CASE_INSENSITIVE);
|
||||
static final Pattern HOUSE_PATTERN_CASE01 = Pattern.compile("\\d{3,6}(室|房|号房|户|铺)$");
|
||||
static final Pattern HOUSE_PATTERN = Pattern.compile("(((((?<=\\D)\\w{3,4})$)|((?<=\\D)\\w{1,4}(?:[室房户]|(?:号房))))-)?((((?<=\\D)*\\w{3,4})$)|(\\w{1,4}(?:[室房户铺]|(?:号房))))", Pattern.CASE_INSENSITIVE);
|
||||
static final Pattern HOUSE_PATTERN_CASE01 = Pattern.compile("\\d{3,6}(室|房|号房|户|铺)$");
|
||||
static final Pattern NUMBER_END = Pattern.compile("(?<=\\D)\\d{3,4}$");
|
||||
static final Pattern HOUSE_NUMBER = Pattern.compile("\\d{3,4}");
|
||||
static final String HOUSE_UNITS_PATTERN = "(室|房|号房|号(?!院)|户|铺)+";
|
||||
static final Pattern HOUSE_PATTERN_CASE02 = Pattern.compile("(\\d+(室|房|号)?[、]?)+$");
|
||||
static final String HOUSE_UNITS_PATTERN = "(室|房|号房|号(?!院)|户|铺)+";
|
||||
static final Pattern HOUSE_PATTERN_CASE02 = Pattern.compile("(\\d+(室|房|号)?[、]?)+$");
|
||||
|
||||
@Override
|
||||
public RepeatStatus process(Address address) {
|
||||
@@ -45,7 +45,7 @@ public class RoomNumberProcessor extends AbstractAddressProcessor {
|
||||
if (matchFirst(NUMBER_END, matchResult.matchContent) == null) {
|
||||
address.setOrgRoomNumber(matchResult.matchContent);
|
||||
} else {
|
||||
address.setOrgRoomNumber(matchResult.matchContent + "室");
|
||||
address.setOrgRoomNumber(matchResult.matchContent + "室");
|
||||
}
|
||||
// analyFloorUseRoomNumber(address);
|
||||
address.setAddress(orgAddress);
|
||||
@@ -64,9 +64,9 @@ public class RoomNumberProcessor extends AbstractAddressProcessor {
|
||||
private void analyFloorUseRoomNumber(Address address) {
|
||||
MatchResult matchResult = matchFirst(HOUSE_NUMBER, address.getOrgRoomNumber());
|
||||
if (matchResult != null && matchResult.matchContent.length() == 3) {
|
||||
address.setFloor(matchResult.matchContent.charAt(0) + "楼");
|
||||
address.setFloor(matchResult.matchContent.charAt(0) + "楼");
|
||||
} else if (matchResult != null && matchResult.matchContent.length() == 4) {
|
||||
address.setFloor(matchResult.matchContent.substring(0, 2) + "楼");
|
||||
address.setFloor(matchResult.matchContent.substring(0, 2) + "楼");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -10,21 +10,21 @@ import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 特殊地址处理器
|
||||
* 特殊地址处理器
|
||||
* Created by wenyan on 2016/2/25.
|
||||
*/
|
||||
public class SpecifyRregularProcessor extends AbstractAddressProcessor {
|
||||
|
||||
@Case(sample = "上海市民星路568/2/402",model = "路+弄/号/室号")
|
||||
Pattern CASE01 = Pattern.compile("^.+(路|街道|街|弄|大道|巷|道|((一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)(线|环)))(交汇|.{1,3}段)?\\d+/\\d+/\\d{3,}$");
|
||||
@Case(sample = "上海市民星路568/2/402",model = "路+弄/号/室号")
|
||||
Pattern CASE01 = Pattern.compile("^.+(路|街道|街|弄|大道|巷|道|((一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)(线|环)))(交汇|.{1,3}段)?\\d+/\\d+/\\d{3,}$");
|
||||
Pattern CASE01_01 = Pattern.compile("\\d+/\\d+/\\d{3,}");
|
||||
|
||||
@Case(sample = "民权路61.63.65号",model = "路+路号路号")
|
||||
Pattern CASE02 = Pattern.compile("^.+(路|街道|街|弄|大道|巷|道|((一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)(线|环)))(\\d+\\.)+\\d+号");
|
||||
Pattern CASE02_01 = Pattern.compile("(\\d+\\.)+\\d+号");
|
||||
@Case(sample = "民权路61.63.65号",model = "路+路号路号")
|
||||
Pattern CASE02 = Pattern.compile("^.+(路|街道|街|弄|大道|巷|道|((一|二|三|四|五|六|七|八|九|十|东|南|西|北|复)(线|环)))(\\d+\\.)+\\d+号");
|
||||
Pattern CASE02_01 = Pattern.compile("(\\d+\\.)+\\d+号");
|
||||
|
||||
@Case(sample = "商铺000148号", model = "物业类型+室号")
|
||||
Pattern CASE03 = Pattern.compile("(?:((商铺)|(写字楼)))\\d+号");
|
||||
@Case(sample = "商铺000148号", model = "物业类型+室号")
|
||||
Pattern CASE03 = Pattern.compile("(?:((商铺)|(写字楼)))\\d+号");
|
||||
|
||||
|
||||
@Override
|
||||
@@ -35,8 +35,8 @@ public class SpecifyRregularProcessor extends AbstractAddressProcessor {
|
||||
MatchResult numbers = matchFirst(CASE01_01, result.matchContent);
|
||||
String road = result.matchContent.replaceAll(numbers.matchContent, "");
|
||||
String[] numbersArray = numbers.matchContent.split("/");
|
||||
address.setStreet(road + numbersArray[0] + "弄");
|
||||
address.setStreetNumber(numbersArray[1] + "号");
|
||||
address.setStreet(road + numbersArray[0] + "弄");
|
||||
address.setStreetNumber(numbersArray[1] + "号");
|
||||
address.setOrgRoomNumber(numbersArray[2]);
|
||||
orgAddress = removeSubstring(orgAddress, result.start, result.end);
|
||||
address.setAddress(orgAddress);
|
||||
@@ -51,12 +51,12 @@ public class SpecifyRregularProcessor extends AbstractAddressProcessor {
|
||||
address.setStreet(road);
|
||||
address.setStreetNumber(streetNumbers);
|
||||
orgAddress = removeSubstring(orgAddress, result.start, result.end);
|
||||
List<String> streetNumList = Arrays.asList(streetNumbers.replace("号", "").split("\\."));
|
||||
List<String> streetNumList = Arrays.asList(streetNumbers.replace("号", "").split("\\."));
|
||||
if(address.getStreetNumbers() == null){
|
||||
address.setStreetNumbers(new ArrayList<String>(streetNumList.size()));
|
||||
}
|
||||
for(String num : streetNumList){
|
||||
address.getStreetNumbers().add(num + "号");
|
||||
address.getStreetNumbers().add(num + "号");
|
||||
}
|
||||
address.setAddress(orgAddress);
|
||||
return RepeatStatus.NEXT;
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import com.fangjia.service.address.mode.Address;
|
||||
import com.fangjia.service.address.mode.MatchResult;
|
||||
|
||||
/**
|
||||
* 分期分区解析器
|
||||
* 分期分区解析器
|
||||
* Created by wenyan on 2015/10/13.
|
||||
*/
|
||||
public class StageAndPartitionProcessor extends AbstractAddressProcessor {
|
||||
|
||||
+21
-21
@@ -14,18 +14,18 @@ import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 解析地址街道信息
|
||||
* 解析地址街道信息
|
||||
* @author wenyan
|
||||
* case1:渝北区双凤桥街道翔宇路999号3幢整幢
|
||||
* case1:渝北区双凤桥街道翔宇路999号3幢整幢
|
||||
*/
|
||||
public class StreetProcessor extends AbstractAddressProcessor {
|
||||
|
||||
static final Pattern CONNECTOR_PATTERN = Pattern.compile("~|-|~|-");
|
||||
static final Pattern SEPARATOR_PATTERN = Pattern.compile("、|,");
|
||||
static final Pattern TOW_NONG_PATTERN = Pattern.compile(".*\\d+弄.+弄$");
|
||||
/**对于"23~56号"街道号解析出的最大街道号数量*/
|
||||
static final Pattern CONNECTOR_PATTERN = Pattern.compile("~|-|~|-");
|
||||
static final Pattern SEPARATOR_PATTERN = Pattern.compile("、|,");
|
||||
static final Pattern TOW_NONG_PATTERN = Pattern.compile(".*\\d+弄.+弄$");
|
||||
/**对于"23~56号"街道号解析出的最大街道号数量*/
|
||||
static final int MAX_STREET_NUMBERS_COUNT = 10;
|
||||
static final List<String> KEYWORDS = Arrays.asList("居委会", "街道办事处", "街道办", "辖区", "办事处");
|
||||
static final List<String> KEYWORDS = Arrays.asList("居委会", "街道办事处", "街道办", "辖区", "办事处");
|
||||
|
||||
|
||||
@Override
|
||||
@@ -48,9 +48,9 @@ public class StreetProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
if(matchResult != null){
|
||||
String fullAddress = matchResult.matchContent;//街道 + 街道号
|
||||
String fullAddress = matchResult.matchContent;//街道 + 街道号
|
||||
if("address".equals(addrFrom)){
|
||||
MatchResult mr = matchFirst(Pattern.compile(fullAddress + "(小区|院|大院|楼|街坊|住宅楼|院小区|住宅|商住楼|公寓|居民区|院落)"), orgAddress);
|
||||
MatchResult mr = matchFirst(Pattern.compile(fullAddress + "(小区|院|大院|楼|街坊|住宅楼|院小区|住宅|商住楼|公寓|居民区|院落)"), orgAddress);
|
||||
if(mr == null){
|
||||
orgAddress = removeSubstring(orgAddress, 0, matchResult.end);
|
||||
}else{
|
||||
@@ -77,11 +77,11 @@ public class StreetProcessor extends AbstractAddressProcessor {
|
||||
standardAddress += address.getStreetNumber();
|
||||
}
|
||||
address.getKeywordList().add(standardAddress);
|
||||
if(address.getStreet().endsWith("弄") && null != address.getStreetNumber()){
|
||||
if(address.getStreet().endsWith("弄") && null != address.getStreetNumber()){
|
||||
address.getKeywordList().add(address.getStreet());
|
||||
}
|
||||
if(match(address.getStreet(), TOW_NONG_PATTERN)){
|
||||
int laneIndex = address.getStreet().indexOf("弄");
|
||||
int laneIndex = address.getStreet().indexOf("弄");
|
||||
address.getKeywordList().add(address.getStreet().substring(0, laneIndex + 1));
|
||||
}
|
||||
}
|
||||
@@ -90,9 +90,9 @@ public class StreetProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 优化街道
|
||||
* case:龙江镇龙江居委会325国道龙江段102号
|
||||
* case:宝山区呼玛路
|
||||
* 优化街道
|
||||
* case:龙江镇龙江居委会325国道龙江段102号
|
||||
* case:宝山区呼玛路
|
||||
* @param address
|
||||
*/
|
||||
void optimizeStreet(Address address){
|
||||
@@ -107,7 +107,7 @@ public class StreetProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 分割地址的街道号
|
||||
* 分割地址的街道号
|
||||
* @param address
|
||||
*/
|
||||
private void fillStreetNumbers(Address address){
|
||||
@@ -125,9 +125,9 @@ public class StreetProcessor extends AbstractAddressProcessor {
|
||||
streetNumbers.add(streetNumberStr);
|
||||
}
|
||||
if(separatorResult != null && connResult != null){
|
||||
String[] str1 = removedUnitStr.split(",|、");
|
||||
String[] str1 = removedUnitStr.split(",|、");
|
||||
for(String s : str1){
|
||||
String[] str2 = s.split("~|-|~|-");
|
||||
String[] str2 = s.split("~|-|~|-");
|
||||
if(str2.length == 1){
|
||||
if(str2[0].endsWith(unit)){
|
||||
streetNumbers.add(str2[0]);
|
||||
@@ -141,7 +141,7 @@ public class StreetProcessor extends AbstractAddressProcessor {
|
||||
int start = Integer.valueOf(digital01);
|
||||
int end = Integer.valueOf(digital02);
|
||||
if(start < end){
|
||||
for(int i = start,count = 0;i <= end && count < MAX_STREET_NUMBERS_COUNT ; i++,count++){//最多只取10个街道号码
|
||||
for(int i = start,count = 0;i <= end && count < MAX_STREET_NUMBERS_COUNT ; i++,count++){//最多只取10个街道号码
|
||||
streetNumbers.add(i + unit);
|
||||
}
|
||||
}else{
|
||||
@@ -155,7 +155,7 @@ public class StreetProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
}
|
||||
}else if(separatorResult != null){
|
||||
String[] strings = removedUnitStr.split(",|、");
|
||||
String[] strings = removedUnitStr.split(",|、");
|
||||
for(String s:strings){
|
||||
if(s.endsWith(unit)){
|
||||
streetNumbers.add(s);
|
||||
@@ -164,14 +164,14 @@ public class StreetProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
}
|
||||
}else if(connResult != null){
|
||||
String[] strings = removedUnitStr.split("~|-|~");
|
||||
String[] strings = removedUnitStr.split("~|-|~");
|
||||
String digital01 = fetchDigital(strings[0]);
|
||||
String digital02 = fetchDigital(strings[1]);
|
||||
if(StringUtils.isNotBlank(digital01) && StringUtils.isNotBlank(digital02)){
|
||||
int start = Integer.valueOf(digital01);
|
||||
int end = Integer.valueOf(digital02);
|
||||
if(start < end){
|
||||
for(int i = start,count = 0;i <= end && count < MAX_STREET_NUMBERS_COUNT ; i++,count++){//最多只取10个街道号码
|
||||
for(int i = start,count = 0;i <= end && count < MAX_STREET_NUMBERS_COUNT ; i++,count++){//最多只取10个街道号码
|
||||
streetNumbers.add(i + unit);
|
||||
}
|
||||
}else {
|
||||
|
||||
+4
-4
@@ -11,15 +11,15 @@ import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 解析提示信息
|
||||
* 解析提示信息
|
||||
* @author wenyan
|
||||
*/
|
||||
public class TooltipProcessor extends AbstractAddressProcessor {
|
||||
|
||||
private static final Pattern BRACKET_PATTERN = Pattern.compile("(\\(|(|《|\"|“|【|〔).*?(\\)|》|)|\"|”|】|〕)");
|
||||
private static final Pattern HALF_BRACKET_PATTERN = Pattern.compile("(\\(|(|《|\"|“|【|〔).*(\\)|》|)|\"|”|】|〕)?");
|
||||
private static final Pattern BRACKET_PATTERN = Pattern.compile("(\\(|(|《|\"|“|【|〔).*?(\\)|》|)|\"|”|】|〕)");
|
||||
private static final Pattern HALF_BRACKET_PATTERN = Pattern.compile("(\\(|(|《|\"|“|【|〔).*(\\)|》|)|\"|”|】|〕)?");
|
||||
private static final List<Pattern> UN_AVAILABLE_PATTERN = new ArrayList<Pattern>(){{
|
||||
add(Pattern.compile("门$"));
|
||||
add(Pattern.compile("门$"));
|
||||
}};
|
||||
|
||||
|
||||
|
||||
+4
-4
@@ -9,7 +9,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 乡镇解析
|
||||
* 乡镇解析
|
||||
*/
|
||||
public class TownshipProcessor extends AbstractAddressProcessor {
|
||||
|
||||
@@ -76,7 +76,7 @@ public class TownshipProcessor extends AbstractAddressProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
* 到CPDB库中判断该乡镇是不是一个合法的乡镇
|
||||
* 到CPDB库中判断该乡镇是不是一个合法的乡镇
|
||||
* @param city
|
||||
* @param town
|
||||
* @return
|
||||
@@ -84,7 +84,7 @@ public class TownshipProcessor extends AbstractAddressProcessor {
|
||||
private BasicDBObject findTownInfoInDB(String city, String town,Address address){
|
||||
|
||||
DBCollection townColl = getDbCollection("town");
|
||||
DBCursor cursor = townColl.find(new BasicDBObject("short_name", town.replaceAll("(乡|镇|街道)$", ""))).batchSize(100);
|
||||
DBCursor cursor = townColl.find(new BasicDBObject("short_name", town.replaceAll("(乡|镇|街道)$", ""))).batchSize(100);
|
||||
List<BasicDBObject> towns = new ArrayList<BasicDBObject>();
|
||||
while(cursor.hasNext()){
|
||||
towns.add((BasicDBObject) cursor.next());
|
||||
@@ -116,7 +116,7 @@ public class TownshipProcessor extends AbstractAddressProcessor {
|
||||
return getFirst(provinceSameTown);
|
||||
}
|
||||
|
||||
if(!provinceSameCities.isEmpty()){//优先使用省份相同的城市
|
||||
if(!provinceSameCities.isEmpty()){//优先使用省份相同的城市
|
||||
address.setCandidateCities(provinceSameCities);
|
||||
}else{
|
||||
address.addCandidateCities(possibleCityList);
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 小区名解析器
|
||||
* 小区名解析器
|
||||
*/
|
||||
public class VillageNameProcessor extends AbstractAddressProcessor {
|
||||
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@ public abstract class AbstractHttpApiService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 对当前线程的数据库访问进行计数
|
||||
* 对当前线程的数据库访问进行计数
|
||||
*/
|
||||
protected final void increaseExecuteCounter(String query, long time, int responseSize) {
|
||||
ExecuteCounter.getThreadLocalInstance(ThreadLocalKey.DaoExecuteCounter).increase(this.getClass().getSimpleName(), query,
|
||||
|
||||
+17
-17
@@ -8,41 +8,41 @@ import com.fangjia.service.bo.CheckMatchDistrictCorrectParam;
|
||||
import com.fangjia.service.bo.MatchDistrictResult;
|
||||
|
||||
/**
|
||||
* 地址解析代理服务
|
||||
* 地址解析代理服务
|
||||
* @author wenyan
|
||||
*/
|
||||
public interface AddressMatchProxyService {
|
||||
|
||||
/**
|
||||
* 代理地址解析parser接口
|
||||
* 代理地址解析parser接口
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
String parser(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 代理地址解析parserAll接口
|
||||
* 代理地址解析parserAll接口
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
String parserAll(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 刷新服务器缓存
|
||||
* 刷新服务器缓存
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
String cacheFlush(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 代理地址拆分验证接口
|
||||
* 代理地址拆分验证接口
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
String standard(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 代理地址拆分验证接口
|
||||
* 代理地址拆分验证接口
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@@ -50,37 +50,37 @@ public interface AddressMatchProxyService {
|
||||
|
||||
|
||||
/**
|
||||
* 前海征信地址正式性认证接口
|
||||
* 前海征信地址正式性认证接口
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
String auth(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 格式化区域,有些区域合并了,或者某个字填错了
|
||||
* @param region 区域
|
||||
* 格式化区域,有些区域合并了,或者某个字填错了
|
||||
* @param region 区域
|
||||
* @return
|
||||
*/
|
||||
String formatRegion(String region);
|
||||
|
||||
/**
|
||||
* 根据城市和地址去高德地图搜索
|
||||
* @param city 城市
|
||||
* @param address 地址
|
||||
* 根据城市和地址去高德地图搜索
|
||||
* @param city 城市
|
||||
* @param address 地址
|
||||
* @return
|
||||
*/
|
||||
JSONObject searchByAmap(String city, String address);
|
||||
|
||||
/**
|
||||
* 根据城市和地址去百度地图搜索
|
||||
* @param city 城市
|
||||
* @param address 地址
|
||||
* 根据城市和地址去百度地图搜索
|
||||
* @param city 城市
|
||||
* @param address 地址
|
||||
* @return
|
||||
*/
|
||||
JSONObject searchByBaiDu(String city, String address);
|
||||
|
||||
/**
|
||||
* 检查匹配的小区是否正确
|
||||
* 检查匹配的小区是否正确
|
||||
* @return
|
||||
*/
|
||||
MatchDistrictResult checkMatchDistrictCorrect(CheckMatchDistrictCorrectParam param);
|
||||
@@ -91,7 +91,7 @@ public interface AddressMatchProxyService {
|
||||
|
||||
|
||||
/**
|
||||
* 最新的匹配算法(穆)
|
||||
* 最新的匹配算法(穆)
|
||||
* @param city
|
||||
* @param address
|
||||
* @param category
|
||||
|
||||
+69
-69
@@ -40,7 +40,7 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
|
||||
private String realMatch(Map<String, Object> paramsMap) {
|
||||
String address = paramsMap.get("address").toString();
|
||||
address = address.replaceAll("@@", "#");// 框架无法处理参数带有#的Buge 用@@代替
|
||||
address = address.replaceAll("@@", "#");// 框架无法处理参数带有#的Buge 用@@代替
|
||||
BuildingType buildingType = null;
|
||||
if (paramsMap.containsKey("category")) {
|
||||
if ("property".equals(paramsMap.get("category"))) {
|
||||
@@ -85,7 +85,7 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
Building building = addressParserService.parser(params);
|
||||
long end = System.currentTimeMillis();
|
||||
if (end - start > 200) {
|
||||
LOGGER.warn("匹配parser耗时:\t" + (end - start) + "ms");
|
||||
LOGGER.warn("匹配parser耗时:\t" + (end - start) + "ms");
|
||||
}
|
||||
if (paramsMap.containsKey("verify") && "true".equalsIgnoreCase(paramsMap.get("verify").toString())) {
|
||||
verify(building);
|
||||
@@ -111,7 +111,7 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
|
||||
public String realMatchAll(Map<String, Object> paramsMap) {
|
||||
String address = paramsMap.get("address").toString();;
|
||||
address = address.replaceAll("@@", "#");// 框架无法处理参数带有#的Buge 用@@代替
|
||||
address = address.replaceAll("@@", "#");// 框架无法处理参数带有#的Buge 用@@代替
|
||||
BuildingType buildingType = null;
|
||||
if (paramsMap.containsKey("category")) {
|
||||
if ("property".equals(paramsMap.get("category"))) {
|
||||
@@ -170,7 +170,7 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
if(end - start > MIN_TIMEOUT){
|
||||
LOGGER.warn("匹配超时:" + (end - start) + "ms");
|
||||
LOGGER.warn("匹配超时:" + (end - start) + "ms");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -197,7 +197,7 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
}.start();
|
||||
JSONObject baseModel = new JSONObject();
|
||||
baseModel.put("code", 200);
|
||||
baseModel.put("msg", "开始刷新缓存");
|
||||
baseModel.put("msg", "开始刷新缓存");
|
||||
return baseModel.toString();
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
JSONObject baseModel = new JSONObject();
|
||||
if (!paramsMap.containsKey("address") || paramsMap.get("address") == null || paramsMap.get("address").toString().trim().isEmpty()) {
|
||||
baseModel.put("code", 400);
|
||||
baseModel.put("msg", "地址不能为空");
|
||||
baseModel.put("msg", "地址不能为空");
|
||||
return baseModel.toString();
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
JSONObject baseModel = new JSONObject();
|
||||
if (!paramsMap.containsKey("address") || paramsMap.get("address") == null || paramsMap.get("address").toString().trim().isEmpty()) {
|
||||
baseModel.put("code", 400);
|
||||
baseModel.put("msg", "地址不能为空");
|
||||
baseModel.put("msg", "地址不能为空");
|
||||
return baseModel.toString();
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
JSONObject baseModel = new JSONObject();
|
||||
if (!paramsMap.containsKey("address") || paramsMap.get("address") == null || paramsMap.get("address").toString().trim().isEmpty()) {
|
||||
baseModel.put("code", 400);
|
||||
baseModel.put("msg", "地址不能为空");
|
||||
baseModel.put("msg", "地址不能为空");
|
||||
return baseModel.toString();
|
||||
}
|
||||
MatchParams matchParams = new MatchParams();
|
||||
@@ -431,39 +431,39 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
|
||||
@Override
|
||||
public String formatRegion(String region) {
|
||||
region = region.replace("闸北", "静安");
|
||||
region = region.replace("宣武", "西城");
|
||||
region = region.replace("福洲", "福州");
|
||||
region = region.replace("崇文", "东城");
|
||||
region = region.replace("下关", "鼓楼");
|
||||
region = region.replace("闸此", "静安");
|
||||
region = region.replace("赛军", "赛罕");
|
||||
region = region.replace("莊", "庄");
|
||||
region = region.replace("逄江", "蓬江");
|
||||
region = region.replace("巿", "市");
|
||||
region = region.replace("渖阳", "沈阳");
|
||||
region = region.replace("臺", "台");
|
||||
region = region.replace("盬", "盐");
|
||||
region = region.replace("深南新区", "浑南新区");
|
||||
region = region.replace("武候", "武侯");
|
||||
region = region.replace("闽行", "闵行");
|
||||
region = region.replace("杨州", "扬州");
|
||||
region = region.replace("湘谭", "湘潭");
|
||||
region = region.replace("广洲", "广州");
|
||||
region = region.replace("广柬", "广东");
|
||||
region = region.replace("鼓区", "鼓楼区");
|
||||
region = region.replace("松红", "松江");
|
||||
region = region.replace("建业", "建邺");
|
||||
region = region.replace("籣", "兰");
|
||||
region = region.replace("褔", "福");
|
||||
region = region.replace("华节", "毕节");
|
||||
region = region.replace("南汇", "浦东");
|
||||
region = region.replace("绵羊", "绵阳");
|
||||
region = region.replace("海定", "海淀");
|
||||
region = region.replace("卢湾", "黄浦");
|
||||
region = region.replace("徐江", "徐汇");
|
||||
region = region.replace("德宏傣族景颇族自治州", "德宏州");
|
||||
region = region.replace("彿山", "佛山");
|
||||
region = region.replace("闸北", "静安");
|
||||
region = region.replace("宣武", "西城");
|
||||
region = region.replace("福洲", "福州");
|
||||
region = region.replace("崇文", "东城");
|
||||
region = region.replace("下关", "鼓楼");
|
||||
region = region.replace("闸此", "静安");
|
||||
region = region.replace("赛军", "赛罕");
|
||||
region = region.replace("莊", "庄");
|
||||
region = region.replace("逄江", "蓬江");
|
||||
region = region.replace("巿", "市");
|
||||
region = region.replace("渖阳", "沈阳");
|
||||
region = region.replace("臺", "台");
|
||||
region = region.replace("盬", "盐");
|
||||
region = region.replace("深南新区", "浑南新区");
|
||||
region = region.replace("武候", "武侯");
|
||||
region = region.replace("闽行", "闵行");
|
||||
region = region.replace("杨州", "扬州");
|
||||
region = region.replace("湘谭", "湘潭");
|
||||
region = region.replace("广洲", "广州");
|
||||
region = region.replace("广柬", "广东");
|
||||
region = region.replace("鼓区", "鼓楼区");
|
||||
region = region.replace("松红", "松江");
|
||||
region = region.replace("建业", "建邺");
|
||||
region = region.replace("籣", "兰");
|
||||
region = region.replace("褔", "福");
|
||||
region = region.replace("华节", "毕节");
|
||||
region = region.replace("南汇", "浦东");
|
||||
region = region.replace("绵羊", "绵阳");
|
||||
region = region.replace("海定", "海淀");
|
||||
region = region.replace("卢湾", "黄浦");
|
||||
region = region.replace("徐江", "徐汇");
|
||||
region = region.replace("德宏傣族景颇族自治州", "德宏州");
|
||||
region = region.replace("彿山", "佛山");
|
||||
return region;
|
||||
}
|
||||
|
||||
@@ -474,16 +474,16 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
params.put("city", city);
|
||||
params.put("output", "json");
|
||||
params.put("keywords", address);
|
||||
// 此key单独用
|
||||
// 此key单独用
|
||||
params.put("key", "35925efd7333f1df52145e51b8e4e56a");
|
||||
try {
|
||||
JSONObject result = request.getJsonContent("http://restapi.amap.com/v3/place/text", params, "UTF-8");
|
||||
if (result != null && result.getInt("status") != 1) {
|
||||
LOGGER.warn("高德接口返回:{}", result.toString());
|
||||
LOGGER.warn("高德接口返回:{}", result.toString());
|
||||
}
|
||||
return result;
|
||||
} catch (HttpRequestException e) {
|
||||
LOGGER.error("高德地图调用失败", e);
|
||||
LOGGER.error("高德地图调用失败", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -500,11 +500,11 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
try {
|
||||
JSONObject result = request.getJsonContent("http://api.map.baidu.com/place/v2/search", params, "UTF-8");
|
||||
if (result != null && result.getInt("status") != 0) {
|
||||
LOGGER.warn("百度接口返回:{}", result.toString());
|
||||
LOGGER.warn("百度接口返回:{}", result.toString());
|
||||
}
|
||||
return result;
|
||||
} catch (HttpRequestException e) {
|
||||
LOGGER.error("高德地图调用失败", e);
|
||||
LOGGER.error("高德地图调用失败", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -518,15 +518,15 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
String name = param.getName();
|
||||
String address = param.getInputAddress();
|
||||
String formatAddress = this.formatRegion(region) + address;
|
||||
matchResult.addDebugLog("格式化地址:" + formatAddress);
|
||||
// 高德验证
|
||||
matchResult.addDebugLog("格式化地址:" + formatAddress);
|
||||
// 高德验证
|
||||
MatchAddressScore amapScore = this.getAmapMaxScoreInfo(city, region, name, formatAddress, matchResult);
|
||||
if (amapScore != null && amapScore.getScore() > 4) {
|
||||
matchResult.setMatch(true);
|
||||
matchResult.setScore(amapScore.getScore());
|
||||
return matchResult;
|
||||
}
|
||||
// 根据经纬度验证距离
|
||||
// 根据经纬度验证距离
|
||||
List<MatchAddressScore> scoreList = new ArrayList<MatchAddressScore>();
|
||||
amapScore = this.getAmapMaxScoreInfo(city, region, name, address, matchResult);
|
||||
if (amapScore != null) {
|
||||
@@ -540,7 +540,7 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
if (baiDuScore2 != null) {
|
||||
scoreList.add(baiDuScore2);
|
||||
}
|
||||
// 排序
|
||||
// 排序
|
||||
Collections.sort(scoreList, new Comparator<MatchAddressScore>() {
|
||||
@Override
|
||||
public int compare(MatchAddressScore o1, MatchAddressScore o2) {
|
||||
@@ -549,11 +549,11 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
});
|
||||
|
||||
if (scoreList.size() == 0) {
|
||||
matchResult.addDebugLog("两大地图相互比较无结果");
|
||||
matchResult.addDebugLog("两大地图相互比较无结果");
|
||||
return matchResult;
|
||||
}
|
||||
MatchAddressScore maxAddressScore = scoreList.get(0);
|
||||
matchResult.addDebugLog("地图比较最优的结果:" + JsonUtils.toJson(maxAddressScore));
|
||||
matchResult.addDebugLog("地图比较最优的结果:" + JsonUtils.toJson(maxAddressScore));
|
||||
String[] los = maxAddressScore.getLocation().split(",");
|
||||
double mlng = Double.parseDouble(los[0]);
|
||||
double mlat = Double.parseDouble(los[1]);
|
||||
@@ -606,13 +606,13 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
LOGGER.error("地址标准化失败", e);
|
||||
LOGGER.error("地址标准化失败", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取高德中分数最高的信息
|
||||
* 获取高德中分数最高的信息
|
||||
* @param city
|
||||
* @param region
|
||||
* @param name
|
||||
@@ -621,20 +621,20 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
*/
|
||||
private MatchAddressScore getAmapMaxScoreInfo(String city, String region, String name, String formatAddress, MatchDistrictResult matchResult) {
|
||||
JSONObject mapResult = this.searchByAmap(city, formatAddress);
|
||||
matchResult.addDebugLog("格式化地址调高德结果:" + (mapResult != null ? JsonUtils.toJson(mapResult) : ""));
|
||||
// 重试三次
|
||||
matchResult.addDebugLog("格式化地址调高德结果:" + (mapResult != null ? JsonUtils.toJson(mapResult) : ""));
|
||||
// 重试三次
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (mapResult == null) {
|
||||
matchResult.addDebugLog("格式化地址调高德重试开始");
|
||||
matchResult.addDebugLog("格式化地址调高德重试开始");
|
||||
mapResult = this.searchByAmap(city, formatAddress);
|
||||
matchResult.addDebugLog("格式化地址调高德结果:" + (mapResult != null ? JsonUtils.toJson(mapResult) : ""));
|
||||
matchResult.addDebugLog("格式化地址调高德结果:" + (mapResult != null ? JsonUtils.toJson(mapResult) : ""));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 搜索不到直接返回false
|
||||
// 搜索不到直接返回false
|
||||
if (mapResult == null) {
|
||||
LOGGER.warn("高德搜索无结果,城市:{},地址:{}", city, formatAddress);
|
||||
LOGGER.warn("高德搜索无结果,城市:{},地址:{}", city, formatAddress);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -677,7 +677,7 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取百度中分数最高的信息
|
||||
* 获取百度中分数最高的信息
|
||||
* @param city
|
||||
* @param region
|
||||
* @param name
|
||||
@@ -686,25 +686,25 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
*/
|
||||
private MatchAddressScore getBaiDuMapMaxScoreInfo(String city, String region, String name, String formatAddress, MatchDistrictResult matchResult) {
|
||||
JSONObject mapResult = this.searchByBaiDu(city, formatAddress);
|
||||
matchResult.addDebugLog("格式化地址调百度结果:" + (mapResult != null ? JsonUtils.toJson(mapResult) : ""));
|
||||
// 重试三次
|
||||
matchResult.addDebugLog("格式化地址调百度结果:" + (mapResult != null ? JsonUtils.toJson(mapResult) : ""));
|
||||
// 重试三次
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (mapResult == null) {
|
||||
matchResult.addDebugLog("格式化地址调百度重试开始");
|
||||
matchResult.addDebugLog("格式化地址调百度重试开始");
|
||||
mapResult = this.searchByBaiDu(city, formatAddress);
|
||||
|
||||
if(null != mapResult){
|
||||
matchResult.addDebugLog("格式化地址调百度结果:" + mapResult.toString());
|
||||
matchResult.addDebugLog("格式化地址调百度结果:" + mapResult.toString());
|
||||
}else{
|
||||
matchResult.addDebugLog("格式化地址调百度结果:");
|
||||
matchResult.addDebugLog("格式化地址调百度结果:");
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 搜索不到直接返回false
|
||||
// 搜索不到直接返回false
|
||||
if (mapResult == null) {
|
||||
LOGGER.warn("百度搜索无结果,城市:{},地址:{}", city, formatAddress);
|
||||
LOGGER.warn("百度搜索无结果,城市:{},地址:{}", city, formatAddress);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -805,7 +805,7 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
|
||||
Address address = building.getSearchAddress();
|
||||
if (StringUtils.isNotBlank(address.getKeywords()) && address.getKeywords().length() > 2) {
|
||||
keywords.add(address.getKeywords());
|
||||
} else if (address.getOrgAddress().length() > 2 && address.getOrgAddress().length() < 10) {// 一般小区名不会超过10个字
|
||||
} else if (address.getOrgAddress().length() > 2 && address.getOrgAddress().length() < 10) {// 一般小区名不会超过10个字
|
||||
keywords.add(address.getOrgAddress());
|
||||
}
|
||||
if (address.isStandardAddress()) {
|
||||
|
||||
+6
-6
@@ -50,7 +50,7 @@ public class AliyunServiceImpl implements AliyunService {
|
||||
wrapField(arry[0],arry[1], aliyunBo);
|
||||
}
|
||||
}catch(Exception e){
|
||||
LOGGER.error("调用阿里标准化接口失败:", e);
|
||||
LOGGER.error("调用阿里标准化接口失败:", e);
|
||||
}
|
||||
try{
|
||||
GetAddressDivisionCodeRequest divisionRequest = new GetAddressDivisionCodeRequest();
|
||||
@@ -75,7 +75,7 @@ public class AliyunServiceImpl implements AliyunService {
|
||||
aliyunBo.setDistrict(array[2]);
|
||||
aliyunBo.setTown(array[3]);
|
||||
}catch(Exception e){
|
||||
LOGGER.error("调用阿里行政区划识别接口失败", e);
|
||||
LOGGER.error("调用阿里行政区划识别接口失败", e);
|
||||
}
|
||||
return aliyunBo;
|
||||
}
|
||||
@@ -135,10 +135,10 @@ public class AliyunServiceImpl implements AliyunService {
|
||||
GetAddressDivisionCodeRequest request = new GetAddressDivisionCodeRequest();
|
||||
request.setServiceCode("addrp");
|
||||
request.setAppKey(APPKEY);
|
||||
request.setText("天青路260号");
|
||||
// request.setDefaultProvince("浙江省");
|
||||
// request.setDefaultCity("杭州市");
|
||||
// request.setDefaultDistrict("余杭区");
|
||||
request.setText("天青路260号");
|
||||
// request.setDefaultProvince("浙江省");
|
||||
// request.setDefaultCity("杭州市");
|
||||
// request.setDefaultDistrict("余杭区");
|
||||
// StructureAddressResponse response = client.getAcsResponse(request);
|
||||
GetAddressDivisionCodeResponse response = client.getAcsResponse(request);
|
||||
JSONObject responseJson = JSONObject.fromObject(response.getData());
|
||||
|
||||
+12
-12
@@ -10,7 +10,7 @@ import java.util.List;
|
||||
public interface AmapPoiService {
|
||||
|
||||
/**
|
||||
* 查找所给经纬度以及半径内的相应分类的点
|
||||
* 查找所给经纬度以及半径内的相应分类的点
|
||||
* @param types
|
||||
* @param lng
|
||||
* @param lat
|
||||
@@ -20,18 +20,18 @@ public interface AmapPoiService {
|
||||
List<AmapPoi> findPos(List<String> types, Double lng, Double lat, int radius);
|
||||
|
||||
/**
|
||||
* 选取反欺诈POI点
|
||||
* @param centPoint 中心点
|
||||
* @param actualPoiSelectRadius 真实点选取半径
|
||||
* @param fraudPoiSelectMinRadius 欺诈点选取最小半径
|
||||
* @param actualCount 真实点数量
|
||||
* @param fraudCount 欺诈点数量
|
||||
* 选取反欺诈POI点
|
||||
* @param centPoint 中心点
|
||||
* @param actualPoiSelectRadius 真实点选取半径
|
||||
* @param fraudPoiSelectMinRadius 欺诈点选取最小半径
|
||||
* @param actualCount 真实点数量
|
||||
* @param fraudCount 欺诈点数量
|
||||
* @return
|
||||
*/
|
||||
List<AmapPoi> findAntiFraudPoisAction(Point centPoint, Integer actualPoiSelectRadius, int fraudPoiSelectMinRadius, int actualCount, int fraudCount);
|
||||
|
||||
/**
|
||||
* 查找所给经纬度以及半径内的相应中级分类的点
|
||||
* 查找所给经纬度以及半径内的相应中级分类的点
|
||||
* @param types
|
||||
* @param lng
|
||||
* @param lat
|
||||
@@ -41,7 +41,7 @@ public interface AmapPoiService {
|
||||
List<AmapPoi> findPosByMidTypes(List<String> types, Double lng, Double lat, int radius);
|
||||
|
||||
/**
|
||||
* 地址转经纬度
|
||||
* 地址转经纬度
|
||||
* @param city
|
||||
* @param address
|
||||
* @return
|
||||
@@ -49,7 +49,7 @@ public interface AmapPoiService {
|
||||
Point geocode(String city, String address);
|
||||
|
||||
/**
|
||||
* 搜索提示接口
|
||||
* 搜索提示接口
|
||||
* @param city
|
||||
* @param region
|
||||
* @param keywords
|
||||
@@ -61,7 +61,7 @@ public interface AmapPoiService {
|
||||
|
||||
|
||||
/**
|
||||
* 通过高德API搜索POI信息
|
||||
* 通过高德API搜索POI信息
|
||||
* @param city
|
||||
* @param keywords
|
||||
* @param limit
|
||||
@@ -72,7 +72,7 @@ public interface AmapPoiService {
|
||||
|
||||
|
||||
/**
|
||||
* 招商银行POI搜索提示接口
|
||||
* 招商银行POI搜索提示接口
|
||||
* @param city
|
||||
* @param region
|
||||
* @param keywords
|
||||
|
||||
+14
-14
@@ -31,16 +31,16 @@ public class AmapPoiServiceImpl implements AmapPoiService {
|
||||
private ElasticAmapPoiDao elasticAmapPoiDao;
|
||||
private CbmAmapPoiDao cbmAmapPoiDao;
|
||||
/***
|
||||
* 反欺诈接口POI选取类型:中餐厅,标志性建筑物,交通地名,热点地名,商场,地铁站,公交站,住宅区,专科医院,综合医院
|
||||
* 反欺诈接口POI选取类型:中餐厅,标志性建筑物,交通地名,热点地名,商场,地铁站,公交站,住宅区,专科医院,综合医院
|
||||
*/
|
||||
private static List<String> FRAUD_POI_TYPES = Arrays.asList("50100", "190600", "190300", "190700", "060100", "150500", "150700", "120300", "090200", "090100");
|
||||
private static List<String> TOKENS = Arrays.asList("4ccfe3c898a9489884bd2bcb1ef6dcde,2a1fb75990f2b39f6221e50892dd3988,291073f17ee0b963ccb1927ed92bf265".split(","));
|
||||
|
||||
/**
|
||||
* http://lbs.amap.com/api/webservice/guide/api/georegeo
|
||||
* 有效的POI Level匹配级别
|
||||
* 有效的POI Level匹配级别
|
||||
*/
|
||||
private static List<String> DETAIL_LEVEL_LIST = Arrays.asList("村庄","热点商圈","兴趣点","门牌号","单元号","道路","道路交叉路口","公交站台、地铁站");
|
||||
private static List<String> DETAIL_LEVEL_LIST = Arrays.asList("村庄","热点商圈","兴趣点","门牌号","单元号","道路","道路交叉路口","公交站台、地铁站");
|
||||
|
||||
|
||||
public void setAmapPoiDao(AmapPoiDao amapPoiDao) {
|
||||
@@ -235,7 +235,7 @@ public class AmapPoiServiceImpl implements AmapPoiService {
|
||||
JSONObject poi = pois.getJSONObject(i);
|
||||
AmapPoi amapPoi = new AmapPoi();
|
||||
if(format){
|
||||
amapPoi.setName(poi.getString("name").replaceAll("(\\(|().*(\\)|))", ""));
|
||||
amapPoi.setName(poi.getString("name").replaceAll("(\\(|().*(\\)|))", ""));
|
||||
}else{
|
||||
amapPoi.setName(poi.getString("name"));
|
||||
}
|
||||
@@ -298,7 +298,7 @@ public class AmapPoiServiceImpl implements AmapPoiService {
|
||||
}
|
||||
String name = sugAddress.getString("name");
|
||||
String formatName = sugAddress.getString("name")
|
||||
.replaceAll("(\\(|().*(\\)|))", "")
|
||||
.replaceAll("(\\(|().*(\\)|))", "")
|
||||
.replace(pname, "")
|
||||
.replace(cityname, "")
|
||||
.replace("-", "")
|
||||
@@ -314,7 +314,7 @@ public class AmapPoiServiceImpl implements AmapPoiService {
|
||||
}
|
||||
if(sugAddress.containsKey("address") && sugAddress.get("address") instanceof String){
|
||||
String address = sugAddress.getString("address");
|
||||
address.replaceAll("(\\(|().*(\\)|))", "").replace(pname, "")
|
||||
address.replaceAll("(\\(|().*(\\)|))", "").replace(pname, "")
|
||||
.replace(cityname, "").replace(adname, "");
|
||||
amapPoi.setAddress(AddressParserUtil.optimizeAddress(address));
|
||||
}
|
||||
@@ -371,7 +371,7 @@ public class AmapPoiServiceImpl implements AmapPoiService {
|
||||
}
|
||||
String name = poi.getString("name");
|
||||
String formatName = poi.getString("name")
|
||||
.replaceAll("(\\(|().*(\\)|))", "")
|
||||
.replaceAll("(\\(|().*(\\)|))", "")
|
||||
.replace(pname, "")
|
||||
.replace(cityname, "")
|
||||
.replace("-", "")
|
||||
@@ -390,7 +390,7 @@ public class AmapPoiServiceImpl implements AmapPoiService {
|
||||
}
|
||||
if(poi.containsKey("address") && poi.get("address") instanceof String){
|
||||
String address = poi.getString("address");
|
||||
address.replaceAll("(\\(|().*(\\)|))", "").replace(pname, "")
|
||||
address.replaceAll("(\\(|().*(\\)|))", "").replace(pname, "")
|
||||
.replace(cityname, "").replace(adname, "");
|
||||
amapPoi.setAddress(AddressParserUtil.optimizeAddress(address));
|
||||
}
|
||||
@@ -422,7 +422,7 @@ public class AmapPoiServiceImpl implements AmapPoiService {
|
||||
if("120301&120302&120201&060101&190108&120000".contains(poi.getString("typecode"))){
|
||||
return true;
|
||||
}
|
||||
if(poi.getString("type").endsWith("住宅区")){
|
||||
if(poi.getString("type").endsWith("住宅区")){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -437,12 +437,12 @@ public class AmapPoiServiceImpl implements AmapPoiService {
|
||||
|
||||
if(StringUtils.isNotBlank(region)){
|
||||
JSONObject regionNav = new JSONObject();
|
||||
if("邯郸".equals(city) && ("邯郸县".equals(region) || "邯郸".equals(region))){
|
||||
regionNav.put("context", city + "_邯山");
|
||||
if("邯郸".equals(city) && ("邯郸县".equals(region) || "邯郸".equals(region))){
|
||||
regionNav.put("context", city + "_邯山");
|
||||
regionNav.put("boost", 8);
|
||||
navSuggests.add(regionNav);
|
||||
regionNav = new JSONObject();
|
||||
regionNav.put("context", city + "_丛台");
|
||||
regionNav.put("context", city + "_丛台");
|
||||
regionNav.put("boost", 8);
|
||||
navSuggests.add(regionNav);
|
||||
}else{
|
||||
@@ -457,7 +457,7 @@ public class AmapPoiServiceImpl implements AmapPoiService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是不是正确的POI
|
||||
* 判断是不是正确的POI
|
||||
* @param amapPoi
|
||||
* @return
|
||||
*/
|
||||
@@ -473,7 +473,7 @@ public class AmapPoiServiceImpl implements AmapPoiService {
|
||||
|
||||
|
||||
/**
|
||||
* 解析出关键字中的小区名
|
||||
* 解析出关键字中的小区名
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -6,24 +6,24 @@ import com.fangjia.dal.sql.model.ApiTestApply;
|
||||
|
||||
public interface ApiService {
|
||||
/**
|
||||
* 添加测试申请记录
|
||||
* 添加测试申请记录
|
||||
* @author yinjihuan
|
||||
* @date 2016年6月7日
|
||||
* @param userId 用户ID
|
||||
* @param name 姓名
|
||||
* @param company 公司
|
||||
* @param email 邮箱
|
||||
* @param industry 行业
|
||||
* @param test_fields 测试字段(多个,逗号隔开)
|
||||
* @date 2016年6月7日
|
||||
* @param userId 用户ID
|
||||
* @param name 姓名
|
||||
* @param company 公司
|
||||
* @param email 邮箱
|
||||
* @param industry 行业
|
||||
* @param test_fields 测试字段(多个,逗号隔开)
|
||||
* @throws Exception
|
||||
*/
|
||||
public void addTestApply(String userId, String name, String company, String email,
|
||||
String industry, String test_fields) throws Exception;
|
||||
|
||||
/**
|
||||
* 获取用户申请记录
|
||||
* 获取用户申请记录
|
||||
* @author yinjihuan
|
||||
* @date 2016年6月7日
|
||||
* @date 2016年6月7日
|
||||
* @param userId
|
||||
* @return
|
||||
* @throws Exception
|
||||
@@ -31,18 +31,18 @@ public interface ApiService {
|
||||
public ApiTestApply getTestApply(String userId) throws Exception;
|
||||
|
||||
/**
|
||||
* 查询所有申请记录
|
||||
* 查询所有申请记录
|
||||
* @author yinjihuan
|
||||
* @date 2016年6月7日
|
||||
* @date 2016年6月7日
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public List<ApiTestApply> queryTestApplyList() throws Exception;
|
||||
|
||||
/**
|
||||
* 批准申请
|
||||
* 批准申请
|
||||
* @author yinjihuan
|
||||
* @date 2016年6月8日
|
||||
* @date 2016年6月8日
|
||||
* @param userId
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -50,6 +50,6 @@ public interface ApiService {
|
||||
|
||||
public String getTabTitle(String userId) throws Exception;
|
||||
|
||||
//重新申请
|
||||
//重新申请
|
||||
public void removeApply(String userId) throws Exception;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ApiServiceImpl implements ApiService {
|
||||
apply.setEmail(email);
|
||||
apply.setIndustry(industry);
|
||||
apply.setTestFields(test_fields);
|
||||
apply.setAuditSchedule("审核中");
|
||||
apply.setAuditSchedule("审核中");
|
||||
apply.setApplyTime(new Date());
|
||||
apiTestApplyDao.save(apply);
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class ApiServiceImpl implements ApiService {
|
||||
@Override
|
||||
public void approvalApply(String userId) throws Exception {
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("auditSchedule", "审核通过");
|
||||
data.put("auditSchedule", "审核通过");
|
||||
data.put("auditTime", new Date());
|
||||
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
@@ -81,7 +81,7 @@ public class ApiServiceImpl implements ApiService {
|
||||
ApiTestApply apply = apiService.getTestApply(userId);
|
||||
boolean sch = false;
|
||||
if(apply != null) {
|
||||
if(apply.getAuditSchedule().equals("审核通过")){
|
||||
if(apply.getAuditSchedule().equals("审核通过")){
|
||||
sch = true;
|
||||
}
|
||||
}
|
||||
@@ -95,12 +95,12 @@ public class ApiServiceImpl implements ApiService {
|
||||
}
|
||||
}
|
||||
if(sch || pur){
|
||||
title = "我的调用记录";
|
||||
title = "我的调用记录";
|
||||
} else {
|
||||
title = "我的测试申请";
|
||||
title = "我的测试申请";
|
||||
}
|
||||
} else {
|
||||
title = "我的测试申请";
|
||||
title = "我的测试申请";
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package com.fangjia.service.api;
|
||||
import com.fangjia.dal.mongo.model.ApiUserCfg;
|
||||
|
||||
/**
|
||||
* @author 王文艳
|
||||
* @author 王文艳
|
||||
* @create 2016-11-17
|
||||
**/
|
||||
public interface ApiUserCfgService {
|
||||
|
||||
+3
-3
@@ -9,7 +9,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 王文艳
|
||||
* @author 王文艳
|
||||
* @create 2016-11-17
|
||||
**/
|
||||
public class ApiUserCfgServiceImpl implements ApiUserCfgService {
|
||||
@@ -19,7 +19,7 @@ public class ApiUserCfgServiceImpl implements ApiUserCfgService {
|
||||
|
||||
public void save(ApiUserCfg config, ApiUserCfg.ApiUserCfgKey apiUserCfgKey){
|
||||
if(apiUserCfgKey == null){
|
||||
throw new IllegalArgumentException("类型错误");
|
||||
throw new IllegalArgumentException("类型错误");
|
||||
}
|
||||
String key = generateCacheKey(config.getUserId(), apiUserCfgKey);
|
||||
CacheUtils.delete(ApiUserCfgServiceImpl.class, key);
|
||||
@@ -29,7 +29,7 @@ public class ApiUserCfgServiceImpl implements ApiUserCfgService {
|
||||
|
||||
public ApiUserCfg findByUserId(Long userId, ApiUserCfg.ApiUserCfgKey apiUserCfgKey){
|
||||
if(apiUserCfgKey == null){
|
||||
throw new IllegalArgumentException("类型错误");
|
||||
throw new IllegalArgumentException("类型错误");
|
||||
}
|
||||
String key = generateCacheKey(userId, apiUserCfgKey);
|
||||
ApiUserCfg cfg = (ApiUserCfg)CacheUtils.getValue(ApiUserCfgServiceImpl.class, key);
|
||||
|
||||
+14
-14
@@ -6,7 +6,7 @@ public interface AutoCompleteService {
|
||||
|
||||
/********************************************* new start *****************************************************/
|
||||
/**
|
||||
* 自动完成最新实现
|
||||
* 自动完成最新实现
|
||||
*
|
||||
* @param cat
|
||||
* @param type
|
||||
@@ -18,7 +18,7 @@ public interface AutoCompleteService {
|
||||
List<AutoCompleteBo> suggest(String cat, String type, String city, String keyword, int limit);
|
||||
|
||||
/**
|
||||
* 输入纠错最新实现
|
||||
* 输入纠错最新实现
|
||||
*
|
||||
* @param cat
|
||||
* @param type
|
||||
@@ -31,7 +31,7 @@ public interface AutoCompleteService {
|
||||
/********************************************* new end *****************************************************/
|
||||
|
||||
/**
|
||||
* 输入式自动完成,没有类型的限制
|
||||
* 输入式自动完成,没有类型的限制
|
||||
*
|
||||
* @deprecated
|
||||
* @param keyword
|
||||
@@ -42,18 +42,18 @@ public interface AutoCompleteService {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 输入错误纠正,最多只返回3条最可能的正确输入
|
||||
* 输入:浦江名,这里会返回出[浦江名邸,浦江茗园]
|
||||
* 输入错误纠正,最多只返回3条最可能的正确输入
|
||||
* 输入:浦江名,这里会返回出[浦江名邸,浦江茗园]
|
||||
* </pre>
|
||||
*
|
||||
* @param keyword
|
||||
* 关键词
|
||||
* 关键词
|
||||
* @param cat
|
||||
* 类别
|
||||
* 类别
|
||||
* @param city
|
||||
* 城市
|
||||
* 城市
|
||||
* @param count
|
||||
* 数量
|
||||
* 数量
|
||||
*
|
||||
* @deprecated
|
||||
* @return
|
||||
@@ -61,7 +61,7 @@ public interface AutoCompleteService {
|
||||
List<String> suggest(String keyword, String cat, String city, int count);
|
||||
|
||||
/**
|
||||
* 输入错误纠正,最多只返回3条最可能的正确输入 输入:浦江名,这里会返回出[浦江名邸,浦江茗园]
|
||||
* 输入错误纠正,最多只返回3条最可能的正确输入 输入:浦江名,这里会返回出[浦江名邸,浦江茗园]
|
||||
*
|
||||
* @deprecated
|
||||
* @param keyword
|
||||
@@ -71,7 +71,7 @@ public interface AutoCompleteService {
|
||||
List<String> suggestInputErrorDistrict(String keyword, String city);
|
||||
|
||||
/**
|
||||
* 小区名的自动完成
|
||||
* 小区名的自动完成
|
||||
*
|
||||
* @param keyword
|
||||
* @param city
|
||||
@@ -81,7 +81,7 @@ public interface AutoCompleteService {
|
||||
List<String> suggestDistrict(String keyword, String city, int count);
|
||||
|
||||
/**
|
||||
* 小区名的自动完成,带小区地址
|
||||
* 小区名的自动完成,带小区地址
|
||||
*
|
||||
* @deprecated
|
||||
* @param keyword
|
||||
@@ -92,7 +92,7 @@ public interface AutoCompleteService {
|
||||
List<AutoCompleteBo> suggestDistrictWithAddress(String keyword, String city, int count);
|
||||
|
||||
/**
|
||||
* 小区名的自动完成,带小区地址
|
||||
* 小区名的自动完成,带小区地址
|
||||
*
|
||||
* @deprecated
|
||||
* @param keyword
|
||||
@@ -104,7 +104,7 @@ public interface AutoCompleteService {
|
||||
List<AutoCompleteBo> suggestDistrictWithAddress(String keyword, String city, int count, boolean useOtherCity);
|
||||
|
||||
/**
|
||||
* 小区名的自动完成,带小区地址 新版
|
||||
* 小区名的自动完成,带小区地址 新版
|
||||
*
|
||||
* @deprecated
|
||||
* @param keyword
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@ public class AutoCompleteServiceImpl extends AbstractHttpApiService implements A
|
||||
}
|
||||
|
||||
/**
|
||||
* ス盪錥ェササ
|
||||
* 结果转换
|
||||
*
|
||||
* @param jsonResult
|
||||
* @return
|
||||
|
||||
+13
-13
@@ -20,19 +20,19 @@ public interface BaiduApiService {
|
||||
JSONObject geocoder(String city, String keyword, String ak);
|
||||
|
||||
/**
|
||||
* 百度米制经纬度坐标 -> 百度经纬度坐标<br>
|
||||
* 参考 http://developer.baidu.com/map/changeposition.htm
|
||||
* 百度米制经纬度坐标 -> 百度经纬度坐标<br>
|
||||
* 参考 http://developer.baidu.com/map/changeposition.htm
|
||||
*
|
||||
* @param coords
|
||||
* @param from
|
||||
* 取值为如下: 1:GPS设备获取的角度坐标; 2:GPS获取的米制坐标、sogou地图所用坐标;
|
||||
* 3:google地图、soso地图、aliyun地图、mapabc地图和amap地图所用坐标
|
||||
* 4:3中列表地图坐标对应的米制坐标 5:百度地图采用的经纬度坐标 6:百度地图采用的米制坐标 7:mapbar地图坐标;
|
||||
* 8:51地图坐标
|
||||
* 取值为如下: 1:GPS设备获取的角度坐标; 2:GPS获取的米制坐标、sogou地图所用坐标;
|
||||
* 3:google地图、soso地图、aliyun地图、mapabc地图和amap地图所用坐标
|
||||
* 4:3中列表地图坐标对应的米制坐标 5:百度地图采用的经纬度坐标 6:百度地图采用的米制坐标 7:mapbar地图坐标;
|
||||
* 8:51地图坐标
|
||||
* @param to
|
||||
* 有两种可供选择:5、6。 5:bd09ll(百度经纬度坐标), 6:bd09mc(百度米制经纬度坐标);
|
||||
* 有两种可供选择:5、6。 5:bd09ll(百度经纬度坐标), 6:bd09mc(百度米制经纬度坐标);
|
||||
* @param ak
|
||||
* 密钥
|
||||
* 密钥
|
||||
* @return
|
||||
*/
|
||||
JSONObject geoconv(String coords, int from, int to, String ak);
|
||||
@@ -40,11 +40,11 @@ public interface BaiduApiService {
|
||||
Map<String, Object> mapSearchSimple(String city, String keyword, String ak);
|
||||
|
||||
/**
|
||||
* 旅行范围规划
|
||||
* @param centre 中心点
|
||||
* @param travelMode 旅行方式 "driving", "riding", "walking"
|
||||
* @param travelTime 旅行时间:分钟
|
||||
* @param boundarySize 规划边界的点数,点越多越精确,越慢
|
||||
* 旅行范围规划
|
||||
* @param centre 中心点
|
||||
* @param travelMode 旅行方式 "driving", "riding", "walking"
|
||||
* @param travelTime 旅行时间:分钟
|
||||
* @param boundarySize 规划边界的点数,点越多越精确,越慢
|
||||
* @return
|
||||
*/
|
||||
List<Point> locationBoundary(Point centre, String travelMode, int travelTime, Integer boundarySize);
|
||||
|
||||
+2
-2
@@ -79,8 +79,8 @@ public class BaiduApiServiceImpl extends AbstractHttpApiService implements Baidu
|
||||
if(poi.getLng() == null || poi.getLat() == null ){
|
||||
continue;
|
||||
}
|
||||
double distance = GeoUtils.calculateDistance(lng, lat, poi.getLng(), poi.getLat());//算两点的直线距离
|
||||
if(distance > radius){//大于半径的过滤
|
||||
double distance = GeoUtils.calculateDistance(lng, lat, poi.getLng(), poi.getLat());//算两点的直线距离
|
||||
if(distance > radius){//大于半径的过滤
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
+39
-39
@@ -1,127 +1,127 @@
|
||||
package com.fangjia.service.api;
|
||||
|
||||
/**
|
||||
* 频道(二手房、租房、估价、小区)和类别(知识库中的所有类别)的对应关系
|
||||
* 频道(二手房、租房、估价、小区)和类别(知识库中的所有类别)的对应关系
|
||||
*
|
||||
* @author liupei
|
||||
*/
|
||||
public enum CategoryChannelCorrespondenceEnum {
|
||||
/**
|
||||
* 总价
|
||||
* 总价
|
||||
*/
|
||||
TOTAL_PRICE(new CategoryEnum[] { CategoryEnum.sell }, CategoryEnum.sell, "total_price"),
|
||||
/**
|
||||
* 租价
|
||||
* 租价
|
||||
*/
|
||||
RENT_PRICE(new CategoryEnum[] { CategoryEnum.rent }, CategoryEnum.sell, "rent_price"),
|
||||
/**
|
||||
* 均价
|
||||
* 均价
|
||||
*/
|
||||
PRICE(new CategoryEnum[] { CategoryEnum.district }, CategoryEnum.sell, "price"),
|
||||
/**
|
||||
* 小区名
|
||||
* 小区名
|
||||
*/
|
||||
DISTRICT_NAME(new CategoryEnum[] { CategoryEnum.sell, CategoryEnum.evaluation, CategoryEnum.rent, CategoryEnum.district,
|
||||
CategoryEnum.new_district }, CategoryEnum.sell, "district_name"),
|
||||
/**
|
||||
* 室
|
||||
* 室
|
||||
*/
|
||||
ROOM(new CategoryEnum[] { CategoryEnum.sell, CategoryEnum.evaluation }, CategoryEnum.sell, "room"),
|
||||
/**
|
||||
* 厅
|
||||
* 厅
|
||||
*/
|
||||
HALL(new CategoryEnum[] { CategoryEnum.sell, CategoryEnum.evaluation }, CategoryEnum.sell, "hall"),
|
||||
/**
|
||||
* 卫
|
||||
* 卫
|
||||
*/
|
||||
TOILET(new CategoryEnum[] { CategoryEnum.sell, CategoryEnum.evaluation }, CategoryEnum.sell, "toilet"),
|
||||
/**
|
||||
* 面积
|
||||
* 面积
|
||||
*/
|
||||
AREA(new CategoryEnum[] { CategoryEnum.sell, CategoryEnum.evaluation }, CategoryEnum.sell, "area"),
|
||||
/**
|
||||
* 商圈
|
||||
* 商圈
|
||||
*/
|
||||
BUSINESS_QUARTER(new CategoryEnum[] { CategoryEnum.sell }, CategoryEnum.sell, "business_quarter"),
|
||||
/**
|
||||
* 物业类别
|
||||
* 物业类别
|
||||
*/
|
||||
BUILD_TYPE(new CategoryEnum[] { CategoryEnum.sell }, CategoryEnum.sell, "build_type"),
|
||||
/**
|
||||
* 建筑类型
|
||||
* 建筑类型
|
||||
*/
|
||||
ESTATE_TYPE(new CategoryEnum[] { CategoryEnum.sell }, CategoryEnum.sell, "estate_type"),
|
||||
/**
|
||||
* 物业类型
|
||||
* 物业类型
|
||||
*/
|
||||
KIND(new CategoryEnum[] { CategoryEnum.sell }, CategoryEnum.sell, "kind"),
|
||||
/**
|
||||
* 装修
|
||||
* 装修
|
||||
*/
|
||||
FITMENT(new CategoryEnum[] { CategoryEnum.sell }, CategoryEnum.sell, "fitment"),
|
||||
/**
|
||||
* 公司
|
||||
* 公司
|
||||
*/
|
||||
COMPANY(new CategoryEnum[] { CategoryEnum.sell }, CategoryEnum.sell, "company"),
|
||||
/**
|
||||
* 姓名
|
||||
* 姓名
|
||||
*/
|
||||
CONTACT_PEOPLE(new CategoryEnum[] { CategoryEnum.sell }, CategoryEnum.sell, "contact_people"),
|
||||
/**
|
||||
* 开发商
|
||||
* 开发商
|
||||
*/
|
||||
DEVELOPER(new CategoryEnum[] { CategoryEnum.new_district }, CategoryEnum.sell, "developer"),
|
||||
/**
|
||||
* 地址
|
||||
* 地址
|
||||
*/
|
||||
ADDRESS(new CategoryEnum[] { CategoryEnum.sell }, CategoryEnum.sell, "address"),
|
||||
/**
|
||||
* 房号
|
||||
* 房号
|
||||
*/
|
||||
HOUSE_NUM(new CategoryEnum[] { CategoryEnum.evaluation }, CategoryEnum.sell, "house_num"),
|
||||
/**
|
||||
* 室号
|
||||
* 室号
|
||||
*/
|
||||
ROOM_NUM(new CategoryEnum[] { CategoryEnum.evaluation }, CategoryEnum.sell, "room_num"),
|
||||
/**
|
||||
* 估价
|
||||
* 估价
|
||||
*/
|
||||
EVALUATION(new CategoryEnum[] { CategoryEnum.evaluation }, CategoryEnum.sell, new String[] { "估价", "评估", "房价评估", "房产评估",
|
||||
"房产估价", "多少钱一平米", "挂牌价", "多少钱" }),
|
||||
EVALUATION(new CategoryEnum[] { CategoryEnum.evaluation }, CategoryEnum.sell, new String[] { "估价", "评估", "房价评估", "房产评估",
|
||||
"房产估价", "多少钱一平米", "挂牌价", "多少钱" }),
|
||||
/**
|
||||
* 二手房
|
||||
* 二手房
|
||||
*/
|
||||
SELL(new CategoryEnum[] { CategoryEnum.sell }, CategoryEnum.sell, new String[] { "二手房", "房源", "出售房源", "房子", "在售房源", "挂牌房源" }),
|
||||
SELL(new CategoryEnum[] { CategoryEnum.sell }, CategoryEnum.sell, new String[] { "二手房", "房源", "出售房源", "房子", "在售房源", "挂牌房源" }),
|
||||
/**
|
||||
* 租房
|
||||
* 租房
|
||||
*/
|
||||
RENT(new CategoryEnum[] { CategoryEnum.rent }, CategoryEnum.sell, new String[] { "出租房", "租房", "出租房源" }),
|
||||
RENT(new CategoryEnum[] { CategoryEnum.rent }, CategoryEnum.sell, new String[] { "出租房", "租房", "出租房源" }),
|
||||
/**
|
||||
* 资讯
|
||||
* 资讯
|
||||
*/
|
||||
NEWS(new CategoryEnum[] { CategoryEnum.news }, CategoryEnum.news, new String[] { "资讯", "信息", "新闻" }),
|
||||
NEWS(new CategoryEnum[] { CategoryEnum.news }, CategoryEnum.news, new String[] { "资讯", "信息", "新闻" }),
|
||||
/**
|
||||
* 地图找房
|
||||
* 地图找房
|
||||
*/
|
||||
MAP(new CategoryEnum[] { CategoryEnum.map }, CategoryEnum.map, new String[] { "地图", "地址", "地图找房" }),
|
||||
MAP(new CategoryEnum[] { CategoryEnum.map }, CategoryEnum.map, new String[] { "地图", "地址", "地图找房" }),
|
||||
/**
|
||||
* 新盘
|
||||
* 新盘
|
||||
*/
|
||||
NEW_DISTRICT(new CategoryEnum[] { CategoryEnum.new_district }, CategoryEnum.new_district, new String[] { "新房", "新盘", "新楼开盘",
|
||||
"楼盘详情", "新开盘", "楼盘开盘", "房产开盘", "房子开盘", "期房" });
|
||||
NEW_DISTRICT(new CategoryEnum[] { CategoryEnum.new_district }, CategoryEnum.new_district, new String[] { "新房", "新盘", "新楼开盘",
|
||||
"楼盘详情", "新开盘", "楼盘开盘", "房产开盘", "房子开盘", "期房" });
|
||||
|
||||
/**
|
||||
* 知识库中的类别
|
||||
* 知识库中的类别
|
||||
*/
|
||||
private String[] categorys;
|
||||
|
||||
/**
|
||||
* 所属频道
|
||||
* 所属频道
|
||||
*/
|
||||
private CategoryEnum[] channels;
|
||||
|
||||
/**
|
||||
* 默认频道
|
||||
* 默认频道
|
||||
*/
|
||||
private CategoryEnum def;
|
||||
|
||||
@@ -138,12 +138,12 @@ public enum CategoryChannelCorrespondenceEnum {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取需拦截的对应关系
|
||||
* 获取需拦截的对应关系
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static CategoryChannelCorrespondenceEnum[] getInterceptCorrespondences() {
|
||||
// 规则:若同时存在:估价>二手房>租房>新盘>资讯
|
||||
// 规则:若同时存在:估价>二手房>租房>新盘>资讯
|
||||
return new CategoryChannelCorrespondenceEnum[] { CategoryChannelCorrespondenceEnum.EVALUATION,
|
||||
CategoryChannelCorrespondenceEnum.SELL, CategoryChannelCorrespondenceEnum.RENT,
|
||||
CategoryChannelCorrespondenceEnum.NEW_DISTRICT, CategoryChannelCorrespondenceEnum.NEWS,
|
||||
|
||||
@@ -5,31 +5,31 @@ import java.util.List;
|
||||
|
||||
public enum CategoryEnum {
|
||||
/**
|
||||
* 二手房
|
||||
* 二手房
|
||||
*/
|
||||
sell("ershoufang"),
|
||||
/**
|
||||
* 出租房
|
||||
* 出租房
|
||||
*/
|
||||
rent("zufang"),
|
||||
/**
|
||||
* 小区
|
||||
* 小区
|
||||
*/
|
||||
district,
|
||||
/**
|
||||
* 估价
|
||||
* 估价
|
||||
*/
|
||||
evaluation,
|
||||
/**
|
||||
* 资讯
|
||||
* 资讯
|
||||
*/
|
||||
news,
|
||||
/**
|
||||
* 地图
|
||||
* 地图
|
||||
*/
|
||||
map,
|
||||
/**
|
||||
* 新小区
|
||||
* 新小区
|
||||
*/
|
||||
new_district;
|
||||
|
||||
@@ -43,7 +43,7 @@ public enum CategoryEnum {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类别名称的字符串列表
|
||||
* 获取类别名称的字符串列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
+33
-33
@@ -11,7 +11,7 @@ import com.fangjia.service.bo.KnowbaseBo;
|
||||
public interface KnowbaseService {
|
||||
|
||||
/**
|
||||
* 小区匹配
|
||||
* 小区匹配
|
||||
*
|
||||
* @param keyword
|
||||
* @return
|
||||
@@ -19,17 +19,17 @@ public interface KnowbaseService {
|
||||
public Map<String, Object> parseWord(String keyword);
|
||||
|
||||
/**
|
||||
* 解析首页中全部搜索的关键词对应的频道
|
||||
* 解析首页中全部搜索的关键词对应的频道
|
||||
*
|
||||
* @param keyword
|
||||
* @param isSupportXinfang
|
||||
* 是否支持新房
|
||||
* 是否支持新房
|
||||
* @return
|
||||
*/
|
||||
public CategoryEnum parseKeyWord(String keyword, boolean isSupportXinfang);
|
||||
|
||||
/**
|
||||
* 解析首页中全部搜索的关键词对应的频道 不支持新房
|
||||
* 解析首页中全部搜索的关键词对应的频道 不支持新房
|
||||
*
|
||||
* @param keyword
|
||||
* @return
|
||||
@@ -37,7 +37,7 @@ public interface KnowbaseService {
|
||||
public CategoryEnum parseKeyWord(String keyword);
|
||||
|
||||
/**
|
||||
* 某城市中小区匹配 若该城市中不存在匹配的小区,返回其他城市匹配的小区
|
||||
* 某城市中小区匹配 若该城市中不存在匹配的小区,返回其他城市匹配的小区
|
||||
*
|
||||
* @param keyword
|
||||
* @param city
|
||||
@@ -46,7 +46,7 @@ public interface KnowbaseService {
|
||||
public Map<String, Object> parseWord(String keyword, String city);
|
||||
|
||||
/**
|
||||
* 知识库匹配小区名,批量
|
||||
* 知识库匹配小区名,批量
|
||||
*
|
||||
* @param keys
|
||||
* @return
|
||||
@@ -54,7 +54,7 @@ public interface KnowbaseService {
|
||||
Map<DistrictKey, KnowbaseBo> matchingDistrict(List<DistrictKey> keys);
|
||||
|
||||
/**
|
||||
* 知识库匹配商铺,批量
|
||||
* 知识库匹配商铺,批量
|
||||
*
|
||||
* @param keys
|
||||
* @return
|
||||
@@ -62,7 +62,7 @@ public interface KnowbaseService {
|
||||
Map<DistrictKey, KnowbaseBo> matchingShop(List<DistrictKey> keys);
|
||||
|
||||
/**
|
||||
* 知识库匹配写字楼,批量
|
||||
* 知识库匹配写字楼,批量
|
||||
*
|
||||
* @param keys
|
||||
* @return
|
||||
@@ -70,91 +70,91 @@ public interface KnowbaseService {
|
||||
Map<DistrictKey, KnowbaseBo> matchingOffice(List<DistrictKey> keys);
|
||||
|
||||
/**
|
||||
* 知识库匹配小区名
|
||||
* 知识库匹配小区名
|
||||
*
|
||||
* @param keys
|
||||
* @return 匹配后的DistrictKey,没有匹配结果则返回原值
|
||||
* @return 匹配后的DistrictKey,没有匹配结果则返回原值
|
||||
*/
|
||||
KnowbaseBo matchingDistrict(DistrictKey key);
|
||||
|
||||
/**
|
||||
* 知识库匹配区域名,批量
|
||||
* 知识库匹配区域名,批量
|
||||
*
|
||||
* @param regions
|
||||
* @param city
|
||||
* @return 原始区域名:匹配后的区域名
|
||||
* @return 原始区域名:匹配后的区域名
|
||||
*/
|
||||
Map<String, String> matchingRegion(List<String> regions, String city);
|
||||
|
||||
/**
|
||||
* 知识库匹配区域名
|
||||
* 知识库匹配区域名
|
||||
*
|
||||
* @param region
|
||||
* @param city
|
||||
* @return 匹配后的区域名,没有匹配结果则返回原值
|
||||
* @return 匹配后的区域名,没有匹配结果则返回原值
|
||||
*/
|
||||
String matchingRegion(String region, String city);
|
||||
|
||||
/**
|
||||
* 知识库匹配区域名
|
||||
* 知识库匹配区域名
|
||||
*
|
||||
* @param region
|
||||
* @param city
|
||||
* @return 匹配后的区域名,没有匹配结果则返回null
|
||||
* @return 匹配后的区域名,没有匹配结果则返回null
|
||||
*/
|
||||
String matchingRegionDefaultNull(String region, String city);
|
||||
|
||||
/**
|
||||
* 知识库匹配板块名
|
||||
* 知识库匹配板块名
|
||||
*
|
||||
* @param block
|
||||
* @param region
|
||||
* @param city
|
||||
* @return 匹配后的板块名,没有匹配结果则返回null
|
||||
* @return 匹配后的板块名,没有匹配结果则返回null
|
||||
*/
|
||||
String matchingBlockDefaultNull(String block, String region, String city);
|
||||
|
||||
/**
|
||||
* 知识库匹配区域名
|
||||
* 知识库匹配区域名
|
||||
*
|
||||
* @param lines
|
||||
* list的每一条记录是一个长度为2的String数组,索引0为老友记,索引1为原始区域名
|
||||
* @return 匹配后的区域名map,key为城市+区域,value为匹配后的区域名
|
||||
* list的每一条记录是一个长度为2的String数组,索引0为老友记,索引1为原始区域名
|
||||
* @return 匹配后的区域名map,key为城市+区域,value为匹配后的区域名
|
||||
*/
|
||||
Map<RegionKey, String> matchingRegion(List<RegionKey> regionKeys);
|
||||
|
||||
/**
|
||||
* 知识库匹配城市
|
||||
* 知识库匹配城市
|
||||
*
|
||||
* @param city
|
||||
* @return 匹配后的城市名,没有匹配结果则返回原值
|
||||
* @return 匹配后的城市名,没有匹配结果则返回原值
|
||||
*/
|
||||
public String matchingCity(String city);
|
||||
|
||||
/**
|
||||
* 知识库匹配城市
|
||||
* 知识库匹配城市
|
||||
*
|
||||
* @param city
|
||||
* @return 匹配后的城市名,没有匹配结果则返回null
|
||||
* @return 匹配后的城市名,没有匹配结果则返回null
|
||||
*/
|
||||
public String matchingCityDefaultNull(String city);
|
||||
|
||||
/**
|
||||
* 知识库匹配
|
||||
* 知识库匹配
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> parseKeyword(String keyword);
|
||||
|
||||
/**
|
||||
* 知识库匹配
|
||||
* 知识库匹配
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> parseKeywordDetail(String keyword);
|
||||
|
||||
/**
|
||||
* 取得全部学校
|
||||
* 取得全部学校
|
||||
*
|
||||
* @param city
|
||||
* @return
|
||||
@@ -162,7 +162,7 @@ public interface KnowbaseService {
|
||||
Map<String, Object> getAllSchool();
|
||||
|
||||
/**
|
||||
* 取得城市全部学校
|
||||
* 取得城市全部学校
|
||||
*
|
||||
* @param city
|
||||
* @return
|
||||
@@ -170,7 +170,7 @@ public interface KnowbaseService {
|
||||
Map<String, Object> getAllSchoolByCity(String city);
|
||||
|
||||
/**
|
||||
* 根据关键词解析小区的楼栋号室号小区名信息
|
||||
* 根据关键词解析小区的楼栋号室号小区名信息
|
||||
*
|
||||
* @param keywords
|
||||
* @return
|
||||
@@ -178,7 +178,7 @@ public interface KnowbaseService {
|
||||
public String[] parseKeywords(String keywords);
|
||||
|
||||
/**
|
||||
* 解析中介公司
|
||||
* 解析中介公司
|
||||
*
|
||||
* @param keyword
|
||||
* @return
|
||||
@@ -186,7 +186,7 @@ public interface KnowbaseService {
|
||||
public AgentMaster parseAgentMaster(String city, String keyword);
|
||||
|
||||
/**
|
||||
* 解析物业公司
|
||||
* 解析物业公司
|
||||
*
|
||||
* @param keyword
|
||||
* @return
|
||||
@@ -194,7 +194,7 @@ public interface KnowbaseService {
|
||||
public String parseManagement(String keyword);
|
||||
|
||||
/**
|
||||
* 解析开发商
|
||||
* 解析开发商
|
||||
*
|
||||
* @param keyword
|
||||
* @return
|
||||
|
||||
+55
-55
@@ -52,7 +52,7 @@ import com.poseidon.util.TypeConverter;
|
||||
public class KnowbaseServiceImpl extends AbstractHttpApiService implements KnowbaseService {
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(KnowbaseServiceImpl.class);
|
||||
private final static boolean DISABLE_KNOWBASE_CACHE = Boolean.getBoolean("fangjia.disableKnowBaseCache");
|
||||
// 知识库返回的各key
|
||||
// 知识库返回的各key
|
||||
private static final String FIELD_VALUE = "value";
|
||||
private static final String FIELD_EXTRA_DATA = "extra_data";
|
||||
private static final String FIELD_DISTRICT = "district_name";
|
||||
@@ -65,16 +65,16 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
private static final String FIELD_LAT = "lat";
|
||||
private static final String FIELD_LNG = "lng";
|
||||
|
||||
private static final Pattern RENT_PRICE_REG0 = Pattern.compile("\\d+[\\.\\d+]+([\\s]*?)元");
|
||||
private static final Pattern RENT_PRICE_REG1 = Pattern.compile("\\d+[\\.\\d+]+([\\s]*?)元月");
|
||||
private static final Pattern AVG_PRICE_REG0 = Pattern.compile("\\d+[\\.\\d+]+元平方米");
|
||||
private static final Pattern AVG_PRICE_REG1 = Pattern.compile("\\d+[\\.\\d+]+万元套");
|
||||
private static final Pattern AVG_PRICE_REG2 = Pattern.compile("\\d+[\\.\\d+]+元平米");
|
||||
private static final Pattern RENT_PRICE_REG0 = Pattern.compile("\\d+[\\.\\d+]+([\\s]*?)元");
|
||||
private static final Pattern RENT_PRICE_REG1 = Pattern.compile("\\d+[\\.\\d+]+([\\s]*?)元月");
|
||||
private static final Pattern AVG_PRICE_REG0 = Pattern.compile("\\d+[\\.\\d+]+元平方米");
|
||||
private static final Pattern AVG_PRICE_REG1 = Pattern.compile("\\d+[\\.\\d+]+万元套");
|
||||
private static final Pattern AVG_PRICE_REG2 = Pattern.compile("\\d+[\\.\\d+]+元平米");
|
||||
private static final String[] MINI_DISTRICT_MODE = new String[]{"city","region","name","lng","lat","block","alias"};
|
||||
private DistrictService districtService;
|
||||
|
||||
/**
|
||||
* 当缓存出问题后修改这个key的值,以生成新的缓存
|
||||
* 当缓存出问题后修改这个key的值,以生成新的缓存
|
||||
*/
|
||||
private static final String CACHE_KEY_VERSION = "2014-10-11";
|
||||
|
||||
@@ -146,7 +146,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
}
|
||||
|
||||
// ======== Parse Word ========
|
||||
// 可以匹配小区名、室厅卫数、面积、楼号门牌号、城市
|
||||
// 可以匹配小区名、室厅卫数、面积、楼号门牌号、城市
|
||||
@SuppressWarnings("unchecked")
|
||||
@Deprecated
|
||||
public Map<String, Object> parseWord(String keyword) {
|
||||
@@ -191,7 +191,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
// ======== Parse Word End ========
|
||||
|
||||
// ======== Parse Keyword ========
|
||||
// 匹配知识库支持的所有字段
|
||||
// 匹配知识库支持的所有字段
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> parseKeyword(String keyword) {
|
||||
return Collections.emptyMap();
|
||||
@@ -279,14 +279,14 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
|
||||
// ======== Get Channel ========
|
||||
/**
|
||||
* 解析首页中全部搜索的关键词对应的频道
|
||||
* 解析首页中全部搜索的关键词对应的频道
|
||||
*
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
public CategoryEnum parseKeyWord(String keyword, boolean isSupportXinfang) {
|
||||
if (StringUtils.isNotEmpty(keyword)) {
|
||||
// 根据页面预定义关键字判断
|
||||
// 根据页面预定义关键字判断
|
||||
CategoryEnum channel = getChannel(keyword, isSupportXinfang);
|
||||
if (null != channel) {
|
||||
if (channel == CategoryEnum.map) {
|
||||
@@ -305,7 +305,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
return channel;
|
||||
}
|
||||
|
||||
// 知识库解析判断
|
||||
// 知识库解析判断
|
||||
Map<String, Object> map = parseKeyword(keyword);
|
||||
processSlash(keyword, map);
|
||||
if (MapUtils.isNotEmpty(map)) {
|
||||
@@ -353,13 +353,13 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理包含/的正则匹配
|
||||
* 处理包含/的正则匹配
|
||||
*
|
||||
* @param keyword
|
||||
* @param map
|
||||
*/
|
||||
private void processSlash(String keyword, Map<String, Object> map) {
|
||||
// 因为keyword中的‘/’被处理了,所以租金、均价的匹配正则与知识库略有差异,单独处理
|
||||
// 因为keyword中的‘/’被处理了,所以租金、均价的匹配正则与知识库略有差异,单独处理
|
||||
Matcher ma0 = AVG_PRICE_REG0.matcher(keyword);
|
||||
Matcher ma1 = AVG_PRICE_REG1.matcher(keyword);
|
||||
Matcher ma2 = AVG_PRICE_REG2.matcher(keyword);
|
||||
@@ -369,7 +369,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
}
|
||||
|
||||
if (!map.containsKey("price")) {
|
||||
// 知识库没有匹配出均价,用此处的正则匹配
|
||||
// 知识库没有匹配出均价,用此处的正则匹配
|
||||
if (ma0.find()) {
|
||||
String matchValue = ma0.group(0);
|
||||
map.put("price", TypeConverter.convertToDouble(matchValue));
|
||||
@@ -388,7 +388,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
Matcher mr0 = RENT_PRICE_REG0.matcher(keyword);
|
||||
Matcher mr1 = RENT_PRICE_REG1.matcher(keyword);
|
||||
if (!map.containsKey("rent_price")) {
|
||||
// 知识库没有匹配出租金,用此处的匹配
|
||||
// 知识库没有匹配出租金,用此处的匹配
|
||||
if (mr0.find()) {
|
||||
map.put("rent_price", TypeConverter.convertToDouble(mr0.group(0)));
|
||||
} else if (mr1.find()) {
|
||||
@@ -398,18 +398,18 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据判断关键字中是否存在预定义的字符,有则直接返回对应的频道
|
||||
* 根据判断关键字中是否存在预定义的字符,有则直接返回对应的频道
|
||||
*
|
||||
* 规则:若同时存在:估价>二手房>租房
|
||||
* 规则:若同时存在:估价>二手房>租房
|
||||
*
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
private CategoryEnum getChannel(String keyword, boolean isSupportXinfang) {
|
||||
for (CategoryChannelCorrespondenceEnum ccc : CategoryChannelCorrespondenceEnum.getInterceptCorrespondences()) {
|
||||
// 判断是否开通新房
|
||||
// 判断是否开通新房
|
||||
if (ccc.name().equals("NEW_DISTRICT") && !isSupportXinfang) {
|
||||
continue;// 不支持新房的,不匹配
|
||||
continue;// 不支持新房的,不匹配
|
||||
}
|
||||
for (String cat : ccc.getCategorys()) {
|
||||
if (keyword.contains(cat)) {
|
||||
@@ -421,23 +421,23 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据解析出的map中出现的key,解析出需要返回的频道类型
|
||||
* 根据解析出的map中出现的key,解析出需要返回的频道类型
|
||||
*
|
||||
* 规则:若权重相同:二手房>估价>租房
|
||||
* 规则:若权重相同:二手房>估价>租房
|
||||
*
|
||||
* @param keys
|
||||
* @return
|
||||
*/
|
||||
private CategoryEnum getChannel(Set<String> keys) {
|
||||
// 二手房权重
|
||||
// 二手房权重
|
||||
int sell = 0;
|
||||
// 租房权重
|
||||
// 租房权重
|
||||
int rent = 0;
|
||||
// 估价权重
|
||||
// 估价权重
|
||||
int evaluation = 0;
|
||||
// 小区权重
|
||||
// 小区权重
|
||||
int district = 0;
|
||||
// 新房权重
|
||||
// 新房权重
|
||||
int new_district = 0;
|
||||
|
||||
CategoryChannelCorrespondenceEnum[] cccs = CategoryChannelCorrespondenceEnum.values();
|
||||
@@ -447,7 +447,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
Collections.addAll(cats, ccc.getCategorys());
|
||||
if (cats.contains(key)) {
|
||||
for (CategoryEnum c : ccc.getChannels()) {
|
||||
if (c == CategoryEnum.new_district) {// 新房
|
||||
if (c == CategoryEnum.new_district) {// 新房
|
||||
new_district++;
|
||||
} else if (c == CategoryEnum.rent) {
|
||||
rent++;
|
||||
@@ -484,7 +484,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
|
||||
// ======== Match District ========
|
||||
/**
|
||||
* 某城市中小区匹配
|
||||
* 某城市中小区匹配
|
||||
*
|
||||
* @param keyword
|
||||
* @param city
|
||||
@@ -639,7 +639,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
// if (CollectionUtils.isEmpty(keys)) {
|
||||
// return Collections.emptyMap();
|
||||
// }
|
||||
// /*********************************屏蔽一部分对知识库的访问********************************/
|
||||
// /*********************************屏蔽一部分对知识库的访问********************************/
|
||||
// Set<DistrictKey> districtKeys = new HashSet<DistrictKey>();
|
||||
// for(DistrictKey key : keys){
|
||||
// if(StringUtils.isNotBlank(key.getName())){
|
||||
@@ -681,7 +681,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
// Set<String> regionSet = new HashSet<String>();
|
||||
// String city = "";
|
||||
// for (DistrictKey key : keys) {
|
||||
// // 原始小区名为空,则不处理
|
||||
// // 原始小区名为空,则不处理
|
||||
// if (StringUtils.isNotBlank(key.getName())) {
|
||||
// districtSet.add(key.getName());
|
||||
// }
|
||||
@@ -695,7 +695,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // districts全为空,直接返回
|
||||
// // districts全为空,直接返回
|
||||
// if (districtSet.size() == 0) {
|
||||
// return Collections.emptyMap();
|
||||
// }
|
||||
@@ -754,7 +754,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
}
|
||||
|
||||
private List<DistrictKey> processDistrict(String keyword, JSONObject parseJson) {
|
||||
boolean isEmptyDistrict = false; // 没有匹配到小区结果
|
||||
boolean isEmptyDistrict = false; // 没有匹配到小区结果
|
||||
if (parseJson.isNullObject()) {
|
||||
isEmptyDistrict = true;
|
||||
}
|
||||
@@ -762,7 +762,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
isEmptyDistrict = true;
|
||||
}
|
||||
|
||||
// 匹配到的所有结果
|
||||
// 匹配到的所有结果
|
||||
JSONObject allDistricts = isEmptyDistrict ? null : parseJson.getJSONObject("district_name");
|
||||
|
||||
if (StringUtils.isNotBlank(keyword) && !isEmptyDistrict && !allDistricts.isNullObject()
|
||||
@@ -785,8 +785,8 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<DistrictKey, KnowbaseBo> processDistrict(Collection<DistrictKey> keys, JSONObject parseJson, String type) {
|
||||
boolean isEmptyDistrict = false; // 没有匹配到小区结果
|
||||
boolean isEmptyRegion = false; // 没有匹配到区域结果
|
||||
boolean isEmptyDistrict = false; // 没有匹配到小区结果
|
||||
boolean isEmptyRegion = false; // 没有匹配到区域结果
|
||||
if (parseJson.isNullObject()) {
|
||||
isEmptyDistrict = true;
|
||||
isEmptyRegion = true;
|
||||
@@ -798,7 +798,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
isEmptyRegion = true;
|
||||
}
|
||||
|
||||
// 匹配到的所有结果
|
||||
// 匹配到的所有结果
|
||||
JSONObject allDistricts = isEmptyDistrict ? null : parseJson.getJSONObject(type);
|
||||
JSONObject allRegions = isEmptyRegion ? null : parseJson.getJSONObject(FIELD_REGION);
|
||||
|
||||
@@ -819,8 +819,8 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
JSONObject extraData = district.getJSONObject(FIELD_EXTRA_DATA);
|
||||
String parseRegion = null == extraData.get(FIELD_REGION) ? retRegion : extraData.getString(FIELD_REGION);
|
||||
if (StringUtils.equals(extraData.getString(FIELD_CITY), city)) {
|
||||
// 如果原始区域名为空,则返回第一条结果
|
||||
// 如果原始区域名不为空,则返回区域匹配的结果
|
||||
// 如果原始区域名为空,则返回第一条结果
|
||||
// 如果原始区域名不为空,则返回区域匹配的结果
|
||||
if (StringUtils.isBlank(retRegion) || retRegion.indexOf(parseRegion) >= 0) {
|
||||
retName = district.getString(FIELD_VALUE);
|
||||
retRegion = parseRegion;
|
||||
@@ -830,7 +830,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
|
||||
KnowbaseBo bo = new KnowbaseBo(key.getCity(), retRegion, retName, retBlock, true);
|
||||
|
||||
// 别名和经纬度,匹配上小区时,有此属性
|
||||
// 别名和经纬度,匹配上小区时,有此属性
|
||||
if (null != district.get(FIELD_ALIAS)) {
|
||||
bo.setAlias((List<String>) JSONArray.toCollection(district.getJSONArray(FIELD_ALIAS)));
|
||||
}
|
||||
@@ -903,7 +903,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
return block;
|
||||
}
|
||||
|
||||
block = block.replaceAll("(板块|版块)$", "");
|
||||
block = block.replaceAll("(板块|版块)$", "");
|
||||
if (StringUtils.isBlank(block)) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -973,13 +973,13 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
//
|
||||
// StringBuffer regionStr = new StringBuffer();
|
||||
// for (RegionKey key : regionKeys) {
|
||||
// // 原始区域名为空,不处理
|
||||
// // 原始区域名为空,不处理
|
||||
// if (StringUtils.isNotBlank(key.getRegion())) {
|
||||
// regionStr.append(key).append("|");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // regions全为空,直接返回
|
||||
// // regions全为空,直接返回
|
||||
// if (regionStr.length() == 0) {
|
||||
// return Collections.emptyMap();
|
||||
// }
|
||||
@@ -997,7 +997,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
}
|
||||
|
||||
private Map<RegionKey, String> processRegion(Collection<RegionKey> regionKeys, JSONObject parseJson) {
|
||||
// 没有匹配到结果
|
||||
// 没有匹配到结果
|
||||
if (parseJson.isNullObject() || null == parseJson.get(FIELD_REGION)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
@@ -1006,18 +1006,18 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
|
||||
Map<RegionKey, String> result = new HashMap<RegionKey, String>();
|
||||
for (RegionKey key : regionKeys) {
|
||||
// 原始区域名为空,不处理
|
||||
// 原始区域名为空,不处理
|
||||
if (StringUtils.isBlank(key.getRegion())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String retRegion = key.getRegion(); // 没有匹配结果则用原始值
|
||||
String retRegion = key.getRegion(); // 没有匹配结果则用原始值
|
||||
if (null != allRegions.get(key.toString())) {
|
||||
JSONArray matchedRegions = allRegions.getJSONArray(key.toString());
|
||||
for (int i = 0; i < matchedRegions.size(); i++) {
|
||||
JSONObject region = matchedRegions.getJSONObject(i);
|
||||
if (StringUtils.equals(key.getCity(), region.getJSONObject(FIELD_EXTRA_DATA).getString(FIELD_CITY))) {
|
||||
// 取对应城市中的第一个匹配值
|
||||
// 取对应城市中的第一个匹配值
|
||||
retRegion = region.getString(FIELD_VALUE);
|
||||
break;
|
||||
}
|
||||
@@ -1053,7 +1053,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
// ======== Match City End ========
|
||||
|
||||
/**
|
||||
* json对象转换成map
|
||||
* json对象转换成map
|
||||
*
|
||||
* @param json
|
||||
* @return
|
||||
@@ -1071,10 +1071,10 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
|
||||
Object value = json.get(key);
|
||||
if (value.getClass().equals(JSONObject.class)) {
|
||||
// 值是json对象,递归解析
|
||||
// 值是json对象,递归解析
|
||||
map.put(key, jsonToMap((JSONObject) value));
|
||||
} else if (value.getClass().equals(JSONArray.class)) {
|
||||
// 值是json array对象,遍历递归解析,最后组成list
|
||||
// 值是json array对象,遍历递归解析,最后组成list
|
||||
JSONArray array = (JSONArray) value;
|
||||
List list = new ArrayList(array.size());
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
@@ -1096,7 +1096,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
}
|
||||
|
||||
/**
|
||||
* 某城市中小区匹配
|
||||
* 某城市中小区匹配
|
||||
*
|
||||
* @param keyword
|
||||
* @param city
|
||||
@@ -1176,7 +1176,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是学区房
|
||||
* 是否是学区房
|
||||
*
|
||||
* @param lat
|
||||
* @param lng
|
||||
@@ -1194,7 +1194,7 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
Long schoolLat = Long.parseLong(slat);
|
||||
Long schoolLng = Long.parseLong(slng);
|
||||
if (DataUtil.verifyLatLng(schoolLat, schoolLng)) {
|
||||
int radius = 1000; // 周边1000米范围,为步行30分钟房源
|
||||
int radius = 1000; // 周边1000米范围,为步行30分钟房源
|
||||
long minLng = ((long) schoolLng - (radius * 100000));
|
||||
long maxLng = ((long) schoolLng + (radius * 100000));
|
||||
long minLat = ((long) schoolLat - (radius * 100000));
|
||||
@@ -1219,14 +1219,14 @@ public class KnowbaseServiceImpl extends AbstractHttpApiService implements Knowb
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据关键词解析小区的楼栋号室号小区名信息
|
||||
* 根据关键词解析小区的楼栋号室号小区名信息
|
||||
*
|
||||
* @param keywords
|
||||
* @return
|
||||
*/
|
||||
public String[] parseKeywords(String keywords) {
|
||||
String[] res = new String[3];
|
||||
Pattern pattern = Pattern.compile("(.*?)(\\d*)(号| | |hao|幢|栋|斋)(\\d*).*(\\d*)");
|
||||
Pattern pattern = Pattern.compile("(.*?)(\\d*)(号| | |hao|幢|栋|斋)(\\d*).*(\\d*)");
|
||||
Matcher matcher = pattern.matcher(keywords);
|
||||
int groupCount = matcher.groupCount();
|
||||
if (matcher.find()) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.fangjia.service.bo.MallBo;
|
||||
|
||||
public interface MallService {
|
||||
/**
|
||||
* 列表页置顶推广
|
||||
* 列表页置顶推广
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -15,7 +15,7 @@ public interface MallService {
|
||||
/**
|
||||
*
|
||||
* @param type
|
||||
* 1:菜单底部;2:新盘列表右侧;3:新盘详情右侧
|
||||
* 1:菜单底部;2:新盘列表右侧;3:新盘详情右侧
|
||||
* @return
|
||||
*/
|
||||
public List<MallBo> getMallBoList(int type);
|
||||
|
||||
+13
-13
@@ -23,19 +23,19 @@ import com.fangjia.service.bo.MallBo;
|
||||
public class MallServiceImpl extends AbstractHttpApiService implements MallService {
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(MallServiceImpl.class);
|
||||
/**
|
||||
* 单个信息 临时key
|
||||
* 单个信息 临时key
|
||||
*/
|
||||
private final static String GETMALLBO_TEMP_KEY = "getMallBo_temp";
|
||||
/**
|
||||
* 单个信息 长期key
|
||||
* 单个信息 长期key
|
||||
*/
|
||||
private final static String GETMALLBO_STATIC_KEY = "getMallBo_static";
|
||||
/**
|
||||
* 多个信息 临时key
|
||||
* 多个信息 临时key
|
||||
*/
|
||||
private final static String GETMALLBOLIST_TEMP_KEY = "getMallBoList_temp";
|
||||
/**
|
||||
* 多个信息 长期key
|
||||
* 多个信息 长期key
|
||||
*/
|
||||
private final static String GETMALLBOLIST_STATIC_KEY = "getMallBoList_static";
|
||||
|
||||
@@ -52,15 +52,15 @@ public class MallServiceImpl extends AbstractHttpApiService implements MallServi
|
||||
// if (StringUtils.isBlank(region)) {
|
||||
// return null;
|
||||
// }
|
||||
// // 先从临时缓存取数据
|
||||
// // 先从临时缓存取数据
|
||||
// String tempCacheKey = GETMALLBO_TEMP_KEY + "_" + region;
|
||||
// MallBo ret = (MallBo) CacheUtils.getValue(this.getClass().getName(), tempCacheKey);
|
||||
// if (null != ret) {
|
||||
// // 临时缓存有数据,返回结果
|
||||
// // 临时缓存有数据,返回结果
|
||||
// return ret;
|
||||
// }
|
||||
//
|
||||
// // 临时缓存无数据,调用接口
|
||||
// // 临时缓存无数据,调用接口
|
||||
// ret = dogetMallBo(region);
|
||||
// if (null != ret) {
|
||||
// CacheUtils.putValue(CachePolicyEnum.HOUR, this.getClass().getName(), tempCacheKey, ret);
|
||||
@@ -86,7 +86,7 @@ public class MallServiceImpl extends AbstractHttpApiService implements MallServi
|
||||
// return null;
|
||||
// }
|
||||
// BeanUtils.copyProperties(obj, bo);
|
||||
// // 成功请求API,并且放入长久缓存
|
||||
// // 成功请求API,并且放入长久缓存
|
||||
// CacheUtils.putValue(CachePolicyEnum.LONG, this.getClass().getName(), staticCacheKey, bo);
|
||||
// return bo;
|
||||
// } catch (Exception e) {
|
||||
@@ -110,17 +110,17 @@ public class MallServiceImpl extends AbstractHttpApiService implements MallServi
|
||||
// }
|
||||
//
|
||||
// String regionName = this.getClass().getName();
|
||||
// // 先从临时缓存取数据
|
||||
// // 先从临时缓存取数据
|
||||
// List<MallBo> ret = (List<MallBo>) CacheUtils.getValue(regionName, GETMALLBOLIST_TEMP_KEY + type);
|
||||
// if (null != ret) {
|
||||
// // 临时缓存有数据,返回结果
|
||||
// // 临时缓存有数据,返回结果
|
||||
// return ret;
|
||||
// }
|
||||
//
|
||||
// // 临时缓存无数据,调用接口
|
||||
// // 临时缓存无数据,调用接口
|
||||
// ret = doGetMallBoList(type);
|
||||
// if (null != ret) {
|
||||
// // 接口返回数据,存入临时缓存和长缓存,并返回结果
|
||||
// // 接口返回数据,存入临时缓存和长缓存,并返回结果
|
||||
// CacheUtils.putValue(CachePolicyEnum.HOUR, regionName, GETMALLBOLIST_TEMP_KEY + type, (ArrayList<MallBo>) ret);
|
||||
// return ret;
|
||||
// }
|
||||
@@ -170,7 +170,7 @@ public class MallServiceImpl extends AbstractHttpApiService implements MallServi
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 成功请求API,放入长缓存
|
||||
// // 成功请求API,放入长缓存
|
||||
// CacheUtils.putValue(CachePolicyEnum.LONG, this.getClass().getName(), cacheKey, (Serializable) list);
|
||||
// return list;
|
||||
// } catch (Exception e) {
|
||||
|
||||
+6
-6
@@ -3,13 +3,13 @@ package com.fangjia.service.auto;
|
||||
public interface AutoOperatorService {
|
||||
|
||||
/**
|
||||
* 保存或者追加 keyword, catCity参数必选 <br>
|
||||
* 保存或者追加 keyword, catCity参数必选 <br>
|
||||
*
|
||||
* <pre>
|
||||
* info(可选) json格式如:{ "district" : [{"region":"长宁", "address":"协和路787号", "block":"", "city":"上海"}]},"cat_city":["district_上海"]
|
||||
* info(可选) json格式如:{ "district" : [{"region":"长宁", "address":"协和路787号", "block":"", "city":"上海"}]},"cat_city":["district_上海"]
|
||||
* </pre>
|
||||
*
|
||||
* server(可选)
|
||||
* server(可选)
|
||||
*
|
||||
* @param model
|
||||
* @return
|
||||
@@ -18,13 +18,13 @@ public interface AutoOperatorService {
|
||||
public void saveOrAppend(String keyword, String catCity, String info);
|
||||
|
||||
/**
|
||||
* 保存或者更新 keyword, catCity参数必选 <br>
|
||||
* 保存或者更新 keyword, catCity参数必选 <br>
|
||||
*
|
||||
* <pre>
|
||||
* info(可选) json格式如:{ "district" : [{"region":"长宁", "address":"协和路787号", "block":"", "city":"上海"}]},"cat_city":["district_上海"]
|
||||
* info(可选) json格式如:{ "district" : [{"region":"长宁", "address":"协和路787号", "block":"", "city":"上海"}]},"cat_city":["district_上海"]
|
||||
* </pre>
|
||||
*
|
||||
* server(可选)
|
||||
* server(可选)
|
||||
*
|
||||
* @param model
|
||||
* @return
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.fangjia.dal.datastore.model.Auto;
|
||||
import com.fangjia.service.api.AutoCompleteBo;
|
||||
|
||||
/**
|
||||
* auto工程查询接口
|
||||
* auto工程查询接口
|
||||
*
|
||||
* @author dxy
|
||||
*
|
||||
@@ -20,28 +20,28 @@ import com.fangjia.service.api.AutoCompleteBo;
|
||||
*/
|
||||
public interface AutoService {
|
||||
/**
|
||||
* 按ID删除
|
||||
* 按ID删除
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void deleteById(String id);
|
||||
|
||||
/**
|
||||
* 按ID数组删除
|
||||
* 按ID数组删除
|
||||
*
|
||||
* @param idList
|
||||
*/
|
||||
public void deleteByIdList(List<String> idList);
|
||||
|
||||
/**
|
||||
* 保存
|
||||
* 保存
|
||||
*
|
||||
* @param auto
|
||||
*/
|
||||
public void save(Auto auto);
|
||||
|
||||
/**
|
||||
* 输入纠错
|
||||
* 输入纠错
|
||||
*
|
||||
* @param queryBean
|
||||
* @param limit
|
||||
@@ -50,7 +50,7 @@ public interface AutoService {
|
||||
public List<Map<String, String>> inputCorrection(AutoQueryBean queryBean, int limit);
|
||||
|
||||
/**
|
||||
* 输入纠错
|
||||
* 输入纠错
|
||||
*
|
||||
* @param keyword
|
||||
* @param limit
|
||||
@@ -59,7 +59,7 @@ public interface AutoService {
|
||||
public List<String> districtInputCorrection(String city, String keyword, int limit);
|
||||
|
||||
/**
|
||||
* 自动完成
|
||||
* 自动完成
|
||||
*
|
||||
* @param queryBean
|
||||
* @param limit
|
||||
@@ -68,7 +68,7 @@ public interface AutoService {
|
||||
public List<Map<String, Object>> suggest(AutoQueryBean queryBean, int limit);
|
||||
|
||||
/**
|
||||
* 自动完成
|
||||
* 自动完成
|
||||
*
|
||||
* @param keyword
|
||||
* @param cat
|
||||
@@ -81,7 +81,7 @@ public interface AutoService {
|
||||
public List<AutoCompleteBo> suggest(String keyword, String cat, String city, int limit, boolean useOtherCity);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* 分页查询
|
||||
*
|
||||
* @param pager
|
||||
* @return
|
||||
@@ -89,7 +89,7 @@ public interface AutoService {
|
||||
public FacetQueryResult<Auto> findAutoByPage(Pager pager);
|
||||
|
||||
/**
|
||||
* 按ID查询
|
||||
* 按ID查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
@@ -97,7 +97,7 @@ public interface AutoService {
|
||||
public Auto findAutoById(String id);
|
||||
|
||||
/**
|
||||
* 按关键词查询
|
||||
* 按关键词查询
|
||||
*
|
||||
* @param keyword
|
||||
* @return
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ public class AliasUpdateOperationServiceImpl implements AliasUpdateOperationServ
|
||||
opt.setName(name);
|
||||
opt.setCat(cat);
|
||||
opt.setAlia(alias);
|
||||
opt.setOpt("ɾ³ý");
|
||||
opt.setOpt("删除");
|
||||
opt.setCreateDate(new Date());
|
||||
opt.setIp(ip);
|
||||
opts.add(opt);
|
||||
@@ -52,7 +52,7 @@ public class AliasUpdateOperationServiceImpl implements AliasUpdateOperationServ
|
||||
opt.setName(name);
|
||||
opt.setCat(cat);
|
||||
opt.setAlia(alias);
|
||||
opt.setOpt("Ìí¼Ó");
|
||||
opt.setOpt("添加");
|
||||
opt.setCreateDate(new Date());
|
||||
opt.setIp(ip);
|
||||
opts.add(opt);
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import com.fangjia.dal.mongo.model.bkoff.ApiMonitorTask;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 王文艳
|
||||
* @author 王文艳
|
||||
* @create 2016-10-27
|
||||
**/
|
||||
public class ApiMonitorTaskServiceImpl implements ApiMonitorTaskService{
|
||||
|
||||
+12
-12
@@ -9,20 +9,20 @@ import com.fangjia.dal.mongo.model.bkoff.DiKuai;
|
||||
public interface DikuaiService {
|
||||
|
||||
/**
|
||||
* 查询地块数据
|
||||
* @param city 城市
|
||||
* @param status 交易状态
|
||||
* @param did 地块编号
|
||||
* @param name 地块名称
|
||||
* @param location 地块位置
|
||||
* @param controlNumber 电子监管号
|
||||
* @param pager 分页对象
|
||||
* 查询地块数据
|
||||
* @param city 城市
|
||||
* @param status 交易状态
|
||||
* @param did 地块编号
|
||||
* @param name 地块名称
|
||||
* @param location 地块位置
|
||||
* @param controlNumber 电子监管号
|
||||
* @param pager 分页对象
|
||||
* @return
|
||||
*/
|
||||
public List<DiKuai> queryDiKuais(String city, String status, String did, String name, String location, String controlNumber, Pager pager);
|
||||
|
||||
/**
|
||||
* 查询地块数据数量
|
||||
* 查询地块数据数量
|
||||
* @param city
|
||||
* @param status
|
||||
* @param did
|
||||
@@ -34,20 +34,20 @@ public interface DikuaiService {
|
||||
public Long queryDiKuaiCount(String city, String status, String did, String name, String location, String controlNumber);
|
||||
|
||||
/**
|
||||
* 删除地块数据
|
||||
* 删除地块数据
|
||||
* @param id
|
||||
*/
|
||||
public void remove(String id);
|
||||
|
||||
/**
|
||||
* 获取地块信息
|
||||
* 获取地块信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public DiKuai getDikuai(String id);
|
||||
|
||||
/**
|
||||
* 保存数据
|
||||
* 保存数据
|
||||
* @param diKuai
|
||||
*/
|
||||
public void save(DiKuai diKuai);
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ public class LosePropertyServiceImpl implements LosePropertyService {
|
||||
public List<LoseProperty> findAll(String city, String name, String website, Date startDate, Date endDate, Integer status, Pager pager, List<SortParam> sortParams) {
|
||||
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
if(StringUtils.isNotBlank(city) && !"全国".equals(city)){
|
||||
if(StringUtils.isNotBlank(city) && !"全国".equals(city)){
|
||||
params.add(new QueryParam("city", city));
|
||||
}
|
||||
if(StringUtils.isNotBlank(name)){
|
||||
@@ -47,7 +47,7 @@ public class LosePropertyServiceImpl implements LosePropertyService {
|
||||
@Override
|
||||
public int countAll(String city, String name, String website, Date startDate, Date endDate, Integer status) {
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
if(StringUtils.isNotBlank(city) && !"全国".equals(city)){
|
||||
if(StringUtils.isNotBlank(city) && !"全国".equals(city)){
|
||||
params.add(new QueryParam("city", city));
|
||||
}
|
||||
if(StringUtils.isNotBlank(name)){
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ import org.sothis.core.util.Pager;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 淘宝拍卖物数据查询服务
|
||||
* 淘宝拍卖物数据查询服务
|
||||
*/
|
||||
public interface TaoBaoAuctionService {
|
||||
/**
|
||||
@@ -37,14 +37,14 @@ public interface TaoBaoAuctionService {
|
||||
BidRecord findByBidId(String bidId);
|
||||
|
||||
/**
|
||||
* 统计竞拍记录
|
||||
* 统计竞拍记录
|
||||
* @param bidId
|
||||
* @return
|
||||
*/
|
||||
Integer countAuctionRecordByBidId(String bidId);
|
||||
|
||||
/**
|
||||
* 获取最新的竞拍记录
|
||||
* 获取最新的竞拍记录
|
||||
* @param bidId
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -13,18 +13,18 @@ public class AdSpaceBo implements Serializable {
|
||||
*/
|
||||
private static final long serialVersionUID = 5119629000342911785L;
|
||||
private String id;
|
||||
private String materialType; // 素材类型
|
||||
private String materialURL; // 素材路径
|
||||
private String materialURLSmall; // 素材路径,收缩形态时用
|
||||
private double width; // 广告位宽度
|
||||
private double height; // 广告位高度
|
||||
private String links; // 链接
|
||||
private String pageId; // 页面ID
|
||||
private String position; // 位置
|
||||
private double sequenceNumber; // 序号
|
||||
private String city; // 城市
|
||||
private String materialContent; // 素材内容
|
||||
private String remark; // 素材内容
|
||||
private String materialType; // 素材类型
|
||||
private String materialURL; // 素材路径
|
||||
private String materialURLSmall; // 素材路径,收缩形态时用
|
||||
private double width; // 广告位宽度
|
||||
private double height; // 广告位高度
|
||||
private String links; // 链接
|
||||
private String pageId; // 页面ID
|
||||
private String position; // 位置
|
||||
private double sequenceNumber; // 序号
|
||||
private String city; // 城市
|
||||
private String materialContent; // 素材内容
|
||||
private String remark; // 素材内容
|
||||
private Date creationDate;
|
||||
private Date modificationDate;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user