优化匹配BUG

This commit is contained in:
wangwenyan@fangjia.com
2022-04-04 14:46:55 +08:00
parent 14c58bdba9
commit 3a5e73267e
3 changed files with 11 additions and 4 deletions
@@ -397,6 +397,7 @@ public class Address {
}
public void setOrgAddress(String orgAddress) {
orgAddress = orgAddress.toUpperCase();
setAddress(orgAddress);
if(this.orgAddress != null){
throw new UnsupportedOperationException("原始地址不能被修改");
@@ -70,9 +70,9 @@ public class KeywordProcessor extends AbstractAddressProcessor {
if(StringUtils.isNotBlank(address.getAddress())){
if(address.getOrgAddress().indexOf(sb.toString()) >= address.getOrgAddress().indexOf(address.getAddress())){
sb.insert(0, address.getAddress());
}else{
sb.append(address.getAddress());
}else{
sb.insert(0, address.getAddress());
}
String kw = fetchKeywords(address.getAddress());
if(StringUtils.isNotBlank(kw)){
@@ -23,11 +23,17 @@ public class StageAndPartitionProcessor extends AbstractAddressProcessor {
addr = addr.replaceAll(matchResult.matchContent, formatStage);
address.setAddress(addr);
}
address.setStage(matchResult.matchContent);
address.setStage(formatStage);
}
matchResult = matchFirst(AddressParserPatterns.PARTITION_PATTERN, orgAddr);
if (matchResult != null) {
address.setPartition(matchResult.matchContent);
String formatPartition = CNNMFilter.convertArabicToCnNumeric(matchResult.matchContent);
if(!formatPartition.equals(matchResult.matchContent)){
String addr = address.getAddress();
addr = addr.replaceAll(matchResult.matchContent, formatPartition);
address.setAddress(addr);
}
address.setStage(formatPartition);
}
return RepeatStatus.NEXT;
}