|
@@ -298,14 +298,21 @@ public class AddrSplitLmrMap {
|
|
|
Matcher nongTagMatcher = Pattern.compile("(\\d+(?:-+\\d)?号)").matcher(remaining);
|
|
|
if (nongTagMatcher.find()) {
|
|
|
// 存在\d+(?:-+\d)?号
|
|
|
- returnMap.put("路名", remaining.substring(0, nongTagMatcher.start()));
|
|
|
- String nonghao = nongTagMatcher.group(1);
|
|
|
- if (nonghao.contains("-")) {
|
|
|
- String[] nonghaoList = nonghao.split("-");
|
|
|
- returnMap.put("弄号", nonghaoList[0]);
|
|
|
- returnMap.put("楼栋号", nonghaoList[1]);
|
|
|
+ Matcher nongTagMatcher0 = Pattern.compile("(\\d+-\\d+号)").matcher(remaining);
|
|
|
+ if (nongTagMatcher0.find()) {
|
|
|
+ String nonghao = nongTagMatcher0.group(1);
|
|
|
+ returnMap.put("路名", remaining.substring(0, nongTagMatcher0.start()));
|
|
|
+ if (nonghao.contains("-")) {
|
|
|
+ String[] nonghaoList = nonghao.split("-");
|
|
|
+ returnMap.put("弄号", nonghaoList[0]);
|
|
|
+ returnMap.put("楼栋号", nonghaoList[1]);
|
|
|
+ } else {
|
|
|
+ returnMap.put("弄号", nonghao);
|
|
|
+ returnMap.put("楼栋号", null);
|
|
|
+ }
|
|
|
} else {
|
|
|
- returnMap.put("弄号", nonghao);
|
|
|
+ returnMap.put("路名", remaining.substring(0, nongTagMatcher.start()));
|
|
|
+ returnMap.put("弄号", nongTagMatcher.group(1));
|
|
|
returnMap.put("楼栋号", null);
|
|
|
}
|
|
|
} else {
|
|
@@ -353,7 +360,7 @@ public class AddrSplitLmrMap {
|
|
|
// String testAddress = "新松江路887弄1号611室";
|
|
|
// String testAddress = "方塔东三村6号506室";
|
|
|
// String testAddress = "中山西路 36弄 5号 202室";
|
|
|
- String testAddress = "陈春公路198弄70号-2号1201室";
|
|
|
+ String testAddress = "叶榭镇八字桥村镇南31-29号001室";
|
|
|
Map<String, String> res = parseAddress(testAddress);
|
|
|
System.out.println("测试地址:" + testAddress);
|
|
|
System.out.println("路名:" + res.get("路名"));
|