添加围栏,限制匹配小区区域
This commit is contained in:
+16
-12
@@ -759,6 +759,13 @@ public class AddressParserServiceImpl implements AddressParserService {
|
|||||||
double simScore;
|
double simScore;
|
||||||
boolean onSameRoad = false;
|
boolean onSameRoad = false;
|
||||||
boolean sameDistrict = isSameDistrict(address, metaData);
|
boolean sameDistrict = isSameDistrict(address, metaData);
|
||||||
|
if(PreciseLevel.STRICT == address.getPreciseLevel() && !sameDistrict){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
//当地图解析出来的区域和用户地址中的区域一致时,只匹配指定区域下面的小区
|
||||||
|
if(address.getGeoRegion() != null && address.getGeoRegion().equals(address.getDistrict()) && !sameDistrict){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Iterator<Map.Entry<String, MatchText>> addrEntrySet = metaData.getAddrePinYinMap().entrySet().iterator();
|
Iterator<Map.Entry<String, MatchText>> addrEntrySet = metaData.getAddrePinYinMap().entrySet().iterator();
|
||||||
Map.Entry<String, MatchText> addrEntry;
|
Map.Entry<String, MatchText> addrEntry;
|
||||||
while(addrEntrySet.hasNext()){
|
while(addrEntrySet.hasNext()){
|
||||||
@@ -808,7 +815,6 @@ public class AddressParserServiceImpl implements AddressParserService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String keywordPinYin = address.getKeywordsPinYin();
|
String keywordPinYin = address.getKeywordsPinYin();
|
||||||
String keywords = address.getKeywords();
|
String keywords = address.getKeywords();
|
||||||
String fuzzyKeywordsPinYin = address.getFuzzyKeywordsPinYin();
|
String fuzzyKeywordsPinYin = address.getFuzzyKeywordsPinYin();
|
||||||
@@ -904,23 +910,25 @@ public class AddressParserServiceImpl implements AddressParserService {
|
|||||||
|
|
||||||
double matchLevelScore = 0;
|
double matchLevelScore = 0;
|
||||||
double similarityScore = 0;
|
double similarityScore = 0;
|
||||||
if (standardAddressScore > 0 && keywordScore > 0) {
|
if(metaData.getId().equals(address.getPolygonSeaweedId())){
|
||||||
matchLevelScore = 0.9;
|
matchLevelScore = 0.9;
|
||||||
similarityScore = Math.max(standardAddressScore, keywordScore) * SIMILARITY_RATE;
|
similarityScore = 0.05;
|
||||||
} else if(keywordScore > 0 && streetScore > 0){
|
}else if (standardAddressScore > 0 && keywordScore > 0) {
|
||||||
matchLevelScore = 0.8;
|
matchLevelScore = 0.8;
|
||||||
similarityScore = Math.max(streetScore, keywordScore * 0.8) * SIMILARITY_RATE;
|
similarityScore = Math.max(standardAddressScore, keywordScore) * SIMILARITY_RATE;
|
||||||
} else if (standardAddressScore > 0) {
|
} else if (standardAddressScore > 0) {
|
||||||
matchLevelScore = 0.7;
|
matchLevelScore = 0.7;
|
||||||
similarityScore = standardAddressScore * SIMILARITY_RATE;
|
similarityScore = standardAddressScore * SIMILARITY_RATE;
|
||||||
|
} else if(keywordScore > 0 && streetScore > 0){
|
||||||
|
matchLevelScore = 0.6;
|
||||||
|
similarityScore = Math.max(streetScore, keywordScore * 0.8) * SIMILARITY_RATE;
|
||||||
} else if (keywordScore > 0) {
|
} else if (keywordScore > 0) {
|
||||||
matchLevelScore = 0.6;
|
matchLevelScore = 0.6;
|
||||||
similarityScore = keywordScore * SIMILARITY_RATE;
|
similarityScore = keywordScore * SIMILARITY_RATE;
|
||||||
} else if (fuzzyKeywordsScore > 0) {
|
} else if (fuzzyKeywordsScore > 0) {
|
||||||
matchLevelScore = 0.5;
|
matchLevelScore = 0.4;
|
||||||
similarityScore = fuzzyKeywordsScore * SIMILARITY_RATE;
|
similarityScore = fuzzyKeywordsScore * SIMILARITY_RATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (similarityScore > 0) {
|
if (similarityScore > 0) {
|
||||||
if(metaData.getBuildingType() != null){
|
if(metaData.getBuildingType() != null){
|
||||||
if ("shop".equals(metaData.getBuildingType().toString())) {
|
if ("shop".equals(metaData.getBuildingType().toString())) {
|
||||||
@@ -942,10 +950,6 @@ public class AddressParserServiceImpl implements AddressParserService {
|
|||||||
* similarityScore = 相似度部分(0.07) + 类型部分(0.01) < 0.1
|
* similarityScore = 相似度部分(0.07) + 类型部分(0.01) < 0.1
|
||||||
* */
|
* */
|
||||||
double score = matchLevelScore + similarityScore;
|
double score = matchLevelScore + similarityScore;
|
||||||
if(address.hasCoordinate() && metaData.hasCoordinate()
|
|
||||||
&& GeoUtils.calculateDistance(address.getLng(), address.getLat(), metaData.getLng(), metaData.getLat()) > 3 * 1000){
|
|
||||||
score = 0d;
|
|
||||||
}
|
|
||||||
return score;
|
return score;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -980,7 +984,7 @@ public class AddressParserServiceImpl implements AddressParserService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(StringUtils.isBlank(address.getDistrict()) && StringUtils.isBlank(address.getSuggestDistrict())){
|
if(StringUtils.isBlank(address.getDistrict()) && StringUtils.isBlank(address.getSuggestDistrict())){
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
String district = metaData.getDistrict();
|
String district = metaData.getDistrict();
|
||||||
return district.equals(address.getDistrict()) || district.equals(address.getSuggestDistrict());
|
return district.equals(address.getDistrict()) || district.equals(address.getSuggestDistrict());
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ public class Address {
|
|||||||
private String suggestDistrict;
|
private String suggestDistrict;
|
||||||
private String suggestName;
|
private String suggestName;
|
||||||
private String suggestNamePinYin;
|
private String suggestNamePinYin;
|
||||||
|
private String polygonSeaweedId;
|
||||||
|
private String geoRegion;
|
||||||
private List<String> buildingNumbers;
|
private List<String> buildingNumbers;
|
||||||
private PreciseLevel preciseLevel;
|
private PreciseLevel preciseLevel;
|
||||||
private boolean pinYin;
|
private boolean pinYin;
|
||||||
@@ -750,6 +752,14 @@ public class Address {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getGeoRegion() {
|
||||||
|
return geoRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGeoRegion(String geoRegion) {
|
||||||
|
this.geoRegion = geoRegion;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Address{" +
|
return "Address{" +
|
||||||
@@ -809,6 +819,14 @@ public class Address {
|
|||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPolygonSeaweedId() {
|
||||||
|
return polygonSeaweedId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPolygonSeaweedId(String polygonSeaweedId) {
|
||||||
|
this.polygonSeaweedId = polygonSeaweedId;
|
||||||
|
}
|
||||||
|
|
||||||
public String toMd5Hex(){
|
public String toMd5Hex(){
|
||||||
String keyProperties = "Address{" +
|
String keyProperties = "Address{" +
|
||||||
"city='" + city + '\'' +
|
"city='" + city + '\'' +
|
||||||
|
|||||||
+1
-3
@@ -20,11 +20,9 @@ public class AddressProcessors{
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
//修改顺序需要调整process i 的值
|
//修改顺序需要调整process i 的值
|
||||||
addressProcessors.add(new TokenProcessor());
|
|
||||||
addressProcessors.add(new ProximalCharactersProcessor());
|
addressProcessors.add(new ProximalCharactersProcessor());
|
||||||
addressProcessors.add(new PreNoiseProcessor());
|
addressProcessors.add(new PreNoiseProcessor());
|
||||||
addressProcessors.add(new AddressFormatProcessor());
|
addressProcessors.add(new AddressFormatProcessor());
|
||||||
addressProcessors.add(new TokenProcessor());
|
|
||||||
addressProcessors.add(new FloorProcessor());
|
addressProcessors.add(new FloorProcessor());
|
||||||
addressProcessors.add(new TooltipProcessor());
|
addressProcessors.add(new TooltipProcessor());
|
||||||
addressProcessors.add(new ProvinceProcessor());
|
addressProcessors.add(new ProvinceProcessor());
|
||||||
@@ -44,7 +42,7 @@ public class AddressProcessors{
|
|||||||
addressProcessors.add(new NumericProcessor());
|
addressProcessors.add(new NumericProcessor());
|
||||||
addressProcessors.add(new ProvinceAdjustProcessor());
|
addressProcessors.add(new ProvinceAdjustProcessor());
|
||||||
addressProcessors.add(new FormatProcessor());
|
addressProcessors.add(new FormatProcessor());
|
||||||
// addressProcessors.add(new GeoProcessor());
|
addressProcessors.add(new GeoProcessor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+9
-13
@@ -52,6 +52,7 @@ public class CityProcessor extends AbstractAddressProcessor {
|
|||||||
}
|
}
|
||||||
if(StringUtils.isNotBlank(city) && CityStatus.SURE != address.getCityStatus() ){
|
if(StringUtils.isNotBlank(city) && CityStatus.SURE != address.getCityStatus() ){
|
||||||
String formatCity = RegionData.formatCity(city);
|
String formatCity = RegionData.formatCity(city);
|
||||||
|
address.setCity(formatCity);
|
||||||
String possibleCity = AddressParserGoal.Match.equals(address.getAddressParserGoal()) || address.getAddressParserGoal() == null ? parseCityFromAddress(orgAddress, address) : null;
|
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;
|
String confirmCity = AddressParserGoal.Match.equals(address.getAddressParserGoal()) || address.getAddressParserGoal() == null? null : formatCity;
|
||||||
/**如果省份和城市信息相互矛盾 则用区域推断城市*/
|
/**如果省份和城市信息相互矛盾 则用区域推断城市*/
|
||||||
@@ -191,7 +192,6 @@ public class CityProcessor extends AbstractAddressProcessor {
|
|||||||
}else{
|
}else{
|
||||||
weight.score += 2;
|
weight.score += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
}else if(address.contains(city)){
|
}else if(address.contains(city)){
|
||||||
index = address.indexOf(city);
|
index = address.indexOf(city);
|
||||||
weight.index = index;
|
weight.index = index;
|
||||||
@@ -208,9 +208,11 @@ public class CityProcessor extends AbstractAddressProcessor {
|
|||||||
if(matchResult !=null){
|
if(matchResult !=null){
|
||||||
address = address.replace(matchResult.matchContent, "");
|
address = address.replace(matchResult.matchContent, "");
|
||||||
}
|
}
|
||||||
if(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))){
|
if(province != null && (orgAddress.contains(province + region) || orgAddress.contains(ProvinceData.getDisplay(province) + region))){
|
||||||
weight.score += 2;
|
weight.score += 2;
|
||||||
|
}else if(city.equals(addr.getCity())){
|
||||||
|
weight.score += 10;
|
||||||
}else{
|
}else{
|
||||||
weight.score += 1;
|
weight.score += 1;
|
||||||
}
|
}
|
||||||
@@ -223,7 +225,11 @@ public class CityProcessor extends AbstractAddressProcessor {
|
|||||||
for(String alia : alias){
|
for(String alia : alias){
|
||||||
if(StringUtils.isNotBlank(alia) && !alia.equals(region) && address.indexOf(alia, index) > -1
|
if(StringUtils.isNotBlank(alia) && !alia.equals(region) && address.indexOf(alia, index) > -1
|
||||||
&& (alia.endsWith("市")|(alia.endsWith("县")))){
|
&& (alia.endsWith("市")|(alia.endsWith("县")))){
|
||||||
weight.score += 1;
|
if(city.equals(addr.getCity())){
|
||||||
|
weight.score += 10;
|
||||||
|
}else{
|
||||||
|
weight.score += 1;
|
||||||
|
}
|
||||||
weight.index = address.indexOf(alia, index);
|
weight.index = address.indexOf(alia, index);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -237,16 +243,6 @@ public class CityProcessor extends AbstractAddressProcessor {
|
|||||||
}
|
}
|
||||||
List<FragmentWeight> weights = new ArrayList<FragmentWeight>(weightMap.values());
|
List<FragmentWeight> weights = new ArrayList<FragmentWeight>(weightMap.values());
|
||||||
if(weights.size() > 0){
|
if(weights.size() > 0){
|
||||||
/*String street = getStreet(address);
|
|
||||||
if(street != null){
|
|
||||||
Iterator<FragmentWeight> iterator = weights.iterator();
|
|
||||||
while(iterator.hasNext()){
|
|
||||||
FragmentWeight fragmentWeight = iterator.next();
|
|
||||||
if(match(street, ".*" + fragmentWeight.text + "[东南西北中一二三四五六七八九十百千\\d]?(路|街|大道|支路|村)")){
|
|
||||||
iterator.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
Collections.sort(weights);
|
Collections.sort(weights);
|
||||||
}
|
}
|
||||||
if(weights.size() > 0){
|
if(weights.size() > 0){
|
||||||
|
|||||||
+3
@@ -167,6 +167,9 @@ public class DistrictProcessor extends AbstractAddressProcessor {
|
|||||||
address.setDevelopmentZone(dz);
|
address.setDevelopmentZone(dz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(address.getSuggestDistrict() != null && address.getDistrict() == null){
|
||||||
|
address.setDistrict(address.getSuggestDistrict());
|
||||||
|
}
|
||||||
address.setAddress(orgAddress);
|
address.setAddress(orgAddress);
|
||||||
address.setEffectiveAddress(address.getAddress());
|
address.setEffectiveAddress(address.getAddress());
|
||||||
return RepeatStatus.NEXT;
|
return RepeatStatus.NEXT;
|
||||||
|
|||||||
+38
-49
@@ -5,8 +5,11 @@ import com.fangjia.core.util.HttpRequest;
|
|||||||
import com.fangjia.service.address.mode.Address;
|
import com.fangjia.service.address.mode.Address;
|
||||||
import net.sf.json.JSONArray;
|
import net.sf.json.JSONArray;
|
||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import java.util.*;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 地址经纬度处理器
|
* 地址经纬度处理器
|
||||||
@@ -18,7 +21,6 @@ public class GeoProcessor extends AbstractAddressProcessor {
|
|||||||
private static final String KEY = "4ccfe3c898a9489884bd2bcb1ef6dcde";
|
private static final String KEY = "4ccfe3c898a9489884bd2bcb1ef6dcde";
|
||||||
|
|
||||||
List<String> POI_LEVELS = Arrays.asList("村庄", "热点商圈", "兴趣点", "门牌号", "单元号", "道路交叉路口");
|
List<String> POI_LEVELS = Arrays.asList("村庄", "热点商圈", "兴趣点", "门牌号", "单元号", "道路交叉路口");
|
||||||
List<String> DISTRICT_LEVEL = Arrays.asList("区县", "开发区", "乡镇", "村庄", "热点商圈", "兴趣点", "门牌号", "单元号", "道路交叉路口");
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RepeatStatus process(Address address) {
|
public RepeatStatus process(Address address) {
|
||||||
@@ -26,68 +28,55 @@ public class GeoProcessor extends AbstractAddressProcessor {
|
|||||||
if (address.hasCoordinate()) {
|
if (address.hasCoordinate()) {
|
||||||
return RepeatStatus.NEXT;
|
return RepeatStatus.NEXT;
|
||||||
}
|
}
|
||||||
List<String> queryTypes = new ArrayList<String>();
|
|
||||||
List<String> addressList = new ArrayList<String>();
|
|
||||||
if (address.isStandardAddress()) {
|
|
||||||
addressList.add(address.getStandardAddress());
|
|
||||||
queryTypes.add("StandardAddress");
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotBlank(address.getOrgKeywords())) {
|
|
||||||
addressList.add(address.getOrgKeywords());
|
|
||||||
queryTypes.add("Keywords");
|
|
||||||
}
|
|
||||||
HttpRequest request = new HttpRequest();
|
HttpRequest request = new HttpRequest();
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
params.put("address", StringUtils.join(addressList, "|"));
|
params.put("address", address.getOrgAddress());
|
||||||
params.put("key", KEY);
|
params.put("key", KEY);
|
||||||
params.put("city", address.getCity());
|
params.put("city", address.getCity());
|
||||||
params.put("batch", "true");
|
|
||||||
params.put("output", "json");
|
params.put("output", "json");
|
||||||
try {
|
try {
|
||||||
JSONObject response = request.getJsonContent("https://restapi.amap.com/v3/geocode/geo", params, "UTF-8");
|
JSONObject response = request.getJsonContent("https://restapi.amap.com/v3/geocode/geo", params, "UTF-8");
|
||||||
if (response.getInt("status") == 1) {
|
if (response.getInt("status") == 1) {
|
||||||
JSONArray geocodes = response.getJSONArray("geocodes");
|
JSONArray geocodes = response.getJSONArray("geocodes");
|
||||||
if(queryTypes.contains("StandardAddress")){
|
if(geocodes.size() > 0){
|
||||||
JSONObject geocode = geocodes.getJSONObject(queryTypes.indexOf("StandardAddress"));
|
JSONObject json = geocodes.getJSONObject(0);
|
||||||
String level = geocode.getString("level");
|
if(json.get("district") instanceof String){
|
||||||
if(DISTRICT_LEVEL.contains(level)){
|
String city = address.getCity();
|
||||||
if(StringUtils.isBlank(address.getDistrict())){
|
if(city == null){
|
||||||
address.setDistrict(RegionData.formatRegion(address.getCity(), geocode.getString("district")));
|
city = RegionData.formatCity(json.getString("city"));
|
||||||
}
|
}
|
||||||
|
String region = RegionData.formatRegion(city, json.getString("district"));
|
||||||
|
address.setGeoRegion(region);
|
||||||
}
|
}
|
||||||
if(geocode.containsKey("street") && geocode.containsKey("number")){
|
if(POI_LEVELS.contains(json.getString("level"))){
|
||||||
String geocodeAddress = geocode.getString("street") + geocode.getString("number");
|
//对于门牌号级别的POI,formatted_address中包含|代表是推测出来的路号,重庆市巴南区凤林路|808号,|号楼
|
||||||
if(address.getStandardAddress().contains(geocodeAddress)){
|
if("门牌号".equals(json.getString("level"))){
|
||||||
String location = geocode.getString("location");
|
if(!(json.get("number") instanceof JSONArray) && json.getString("formatted_address").contains("|" + json.getString("number"))){
|
||||||
address.setLng(Double.parseDouble(location.split(",")[0]));
|
return RepeatStatus.NEXT;
|
||||||
address.setLat(Double.parseDouble(location.split(",")[1]));
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(queryTypes.contains("Keywords")){
|
|
||||||
JSONObject geocode = geocodes.getJSONObject(queryTypes.indexOf("Keywords"));
|
|
||||||
String level = geocode.getString("level");
|
|
||||||
if(DISTRICT_LEVEL.contains(level)){
|
|
||||||
if(StringUtils.isBlank(address.getDistrict())){
|
|
||||||
address.setDistrict(RegionData.formatRegion(address.getCity(), geocode.getString("district")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(POI_LEVELS.contains(level)){
|
|
||||||
String formattedAddress = geocode.getString("formatted_address");
|
|
||||||
formattedAddress = formattedAddress
|
|
||||||
.replaceFirst(geocode.getString("province"), "")
|
|
||||||
.replaceFirst(geocode.getString("city"), "")
|
|
||||||
.replaceFirst(geocode.getString("district"), "");
|
|
||||||
if(formattedAddress.equals(address.getOrgKeywords())){
|
|
||||||
String location = geocode.getString("location");
|
|
||||||
address.setLng(Double.parseDouble(location.split(",")[0]));
|
|
||||||
address.setLat(Double.parseDouble(location.split(",")[1]));
|
|
||||||
}
|
}
|
||||||
|
String location = json.getString("location");
|
||||||
|
address.setLng(Double.valueOf(location.split(",")[0]));
|
||||||
|
address.setLat(Double.valueOf(location.split(",")[1]));
|
||||||
|
String tmp = "{ \"_source\": [\"seaweed_id\"], \"query\": {\"geo_shape\": {\"shape\": {\"shape\": {\"type\": \"Point\",\"coordinates\":[location]},\"relation\": \"CONTAINS\"}}}}";
|
||||||
|
tmp = tmp.replace("location", location);
|
||||||
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
|
headers.put("Authorization","Basic ZGV2ZWxvcGVyOjVlOGVkZDg1MWQyZmRmYmQ3NDE1MjMyYzY3MzY3Y2Mz");
|
||||||
|
JSONObject resp = JSONObject.fromObject(request.postWithBody("http://192.168.0.206:9200/seaweed_polygon/_search", JSONObject.fromObject(tmp),headers,"UTF-8"));
|
||||||
|
if(resp.containsKey("hits") && resp.getJSONObject("hits").containsKey("hits")){
|
||||||
|
JSONArray hits = resp.getJSONObject("hits").getJSONArray("hits");
|
||||||
|
if(hits.size() > 0){
|
||||||
|
String seaweedId = hits.getJSONObject(0).getJSONObject("_source").getString("seaweed_id");
|
||||||
|
address.setPolygonSeaweedId(seaweedId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return RepeatStatus.NEXT;
|
return RepeatStatus.NEXT;
|
||||||
}
|
}
|
||||||
|
|||||||
-9
@@ -15,15 +15,6 @@ public class VillageNameProcessor extends AbstractAddressProcessor {
|
|||||||
@Override
|
@Override
|
||||||
public AbstractAddressProcessor.RepeatStatus process(Address address) {
|
public AbstractAddressProcessor.RepeatStatus process(Address address) {
|
||||||
String orgAddress = address.getAddress();
|
String orgAddress = address.getAddress();
|
||||||
if(address.getTokens()!=null){
|
|
||||||
for(Token token:address.getTokens()){
|
|
||||||
if("district".equals(token.getKeywordTypes())){
|
|
||||||
address.setKeywords(token.getName());
|
|
||||||
address.setAddress(orgAddress.replace(token.getName(),""));
|
|
||||||
return RepeatStatus.NEXT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<String> names = tokenDistrictNames(orgAddress);
|
List<String> names = tokenDistrictNames(orgAddress);
|
||||||
List<String> kws = new ArrayList<String>();
|
List<String> kws = new ArrayList<String>();
|
||||||
for(String name : names){
|
for(String name : names){
|
||||||
|
|||||||
+8
-16
@@ -1,24 +1,16 @@
|
|||||||
package com.fangjia.service.cnAnalyzer;
|
package com.fangjia.service.cnAnalyzer;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringReader;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.apache.solr.client.solrj.util.ClientUtils;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.fangjia.core.util.DataUtil;
|
import com.fangjia.core.util.DataUtil;
|
||||||
import com.goojia.solr.ganalytics.IKSegmentation;
|
import com.goojia.solr.ganalytics.IKSegmentation;
|
||||||
import com.goojia.solr.ganalytics.Lexeme;
|
import com.goojia.solr.ganalytics.Lexeme;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 房价网分词器
|
* 房价网分词器
|
||||||
|
|||||||
Reference in New Issue
Block a user