@bytenew/bn-applet-ui 1.1.40 → 1.1.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -21633,7 +21633,7 @@ var CITY_SUFFIX_KEYS = ['布依族苗族自治州', '苗族侗族自治州', '
|
|
|
21633
21633
|
var INVALID_AREA_NAMES = ['其他', '其它区', '其他区'];
|
|
21634
21634
|
|
|
21635
21635
|
/**
|
|
21636
|
-
*
|
|
21636
|
+
* 去掉地址片段开头的市/州等后缀(仅用于城市简称匹配后的剩余文本)
|
|
21637
21637
|
*/
|
|
21638
21638
|
function stripLeadingCitySuffix(text) {
|
|
21639
21639
|
var result = text;
|
|
@@ -21647,6 +21647,19 @@ function stripLeadingCitySuffix(text) {
|
|
|
21647
21647
|
return result;
|
|
21648
21648
|
}
|
|
21649
21649
|
|
|
21650
|
+
/**
|
|
21651
|
+
* 城市简称匹配后去掉后缀;「市中区」「市南区」等区名开头的「市」不能误删
|
|
21652
|
+
*/
|
|
21653
|
+
function stripLeadingCitySuffixAfterShortMatch(text) {
|
|
21654
|
+
if (!text || text.indexOf('市') !== 0) {
|
|
21655
|
+
return text;
|
|
21656
|
+
}
|
|
21657
|
+
if (/^市[中南东西]/.test(text)) {
|
|
21658
|
+
return text;
|
|
21659
|
+
}
|
|
21660
|
+
return stripLeadingCitySuffix(text);
|
|
21661
|
+
}
|
|
21662
|
+
|
|
21650
21663
|
/**
|
|
21651
21664
|
* 同名区对应多个城市时,根据地址中是否出现城市名进行消歧
|
|
21652
21665
|
*/
|
|
@@ -21690,41 +21703,59 @@ function pickCityByContext(address, areaName, areaData) {
|
|
|
21690
21703
|
|
|
21691
21704
|
/**
|
|
21692
21705
|
* 在文本中匹配城市,返回最早出现的城市
|
|
21706
|
+
* 优先匹配完整城市名(如「乐山市」),避免误删「市中区」等区名前缀
|
|
21693
21707
|
*/
|
|
21694
21708
|
function matchCityInText(text, cities) {
|
|
21695
|
-
var
|
|
21696
|
-
var matchIdx = -1;
|
|
21697
|
-
var matchedLength = 0;
|
|
21709
|
+
var best = null;
|
|
21698
21710
|
for (var i = 0; i < cities.length; i++) {
|
|
21699
21711
|
var city = cities[i];
|
|
21700
21712
|
var cityName = city.name;
|
|
21701
21713
|
var idx = text.indexOf(cityName);
|
|
21702
21714
|
if (idx > -1 && idx < 15) {
|
|
21703
|
-
if (
|
|
21704
|
-
|
|
21705
|
-
|
|
21706
|
-
|
|
21707
|
-
|
|
21708
|
-
|
|
21709
|
-
|
|
21710
|
-
if (cityShort !== cityName && cityShort.length >= 2) {
|
|
21711
|
-
var shortIdx = text.indexOf(cityShort);
|
|
21712
|
-
if (shortIdx > -1 && shortIdx < 15) {
|
|
21713
|
-
if (matchIdx === -1 || shortIdx < matchIdx || shortIdx === matchIdx && cityShort.length > matchedLength) {
|
|
21714
|
-
matchedCity = city;
|
|
21715
|
-
matchIdx = shortIdx;
|
|
21716
|
-
matchedLength = cityShort.length;
|
|
21717
|
-
}
|
|
21715
|
+
if (!best || idx < best.idx || idx === best.idx && cityName.length > best.token.length) {
|
|
21716
|
+
best = {
|
|
21717
|
+
city: city,
|
|
21718
|
+
idx: idx,
|
|
21719
|
+
token: cityName,
|
|
21720
|
+
type: 'full'
|
|
21721
|
+
};
|
|
21718
21722
|
}
|
|
21719
21723
|
}
|
|
21720
21724
|
}
|
|
21721
|
-
if (
|
|
21725
|
+
if (best && best.type === 'full') {
|
|
21726
|
+
return {
|
|
21727
|
+
city: best.city,
|
|
21728
|
+
afterCity: text.substring(best.idx + best.token.length)
|
|
21729
|
+
};
|
|
21730
|
+
}
|
|
21731
|
+
for (var _i = 0; _i < cities.length; _i++) {
|
|
21732
|
+
var _city = cities[_i];
|
|
21733
|
+
var _cityName = _city.name;
|
|
21734
|
+
var cityShort = _cityName.replace('市', '').replace('地区', '');
|
|
21735
|
+
if (cityShort === _cityName || cityShort.length < 2) {
|
|
21736
|
+
continue;
|
|
21737
|
+
}
|
|
21738
|
+
var _idx = text.indexOf(cityShort);
|
|
21739
|
+
if (_idx > -1 && _idx < 15) {
|
|
21740
|
+
if (!best || _idx < best.idx || _idx === best.idx && cityShort.length > best.token.length) {
|
|
21741
|
+
best = {
|
|
21742
|
+
city: _city,
|
|
21743
|
+
idx: _idx,
|
|
21744
|
+
token: cityShort,
|
|
21745
|
+
type: 'short'
|
|
21746
|
+
};
|
|
21747
|
+
}
|
|
21748
|
+
}
|
|
21749
|
+
}
|
|
21750
|
+
if (!best) {
|
|
21722
21751
|
return null;
|
|
21723
21752
|
}
|
|
21724
|
-
var afterCity = text.substring(
|
|
21725
|
-
|
|
21753
|
+
var afterCity = text.substring(best.idx + best.token.length);
|
|
21754
|
+
if (best.type === 'short') {
|
|
21755
|
+
afterCity = stripLeadingCitySuffixAfterShortMatch(afterCity);
|
|
21756
|
+
}
|
|
21726
21757
|
return {
|
|
21727
|
-
city:
|
|
21758
|
+
city: best.city,
|
|
21728
21759
|
afterCity: afterCity
|
|
21729
21760
|
};
|
|
21730
21761
|
}
|
|
@@ -22000,7 +22031,7 @@ function detail_parse_forward(address, sourceData) {
|
|
|
22000
22031
|
|
|
22001
22032
|
// 先尝试快速匹配
|
|
22002
22033
|
var _loop = function _loop() {
|
|
22003
|
-
var pattern = _provPatterns[
|
|
22034
|
+
var pattern = _provPatterns[_i2];
|
|
22004
22035
|
if (remaining.startsWith(pattern.pattern)) {
|
|
22005
22036
|
// 在 defaultData 中找到对应的省份数据
|
|
22006
22037
|
var found = defaultData.find(function (p) {
|
|
@@ -22018,7 +22049,7 @@ function detail_parse_forward(address, sourceData) {
|
|
|
22018
22049
|
}
|
|
22019
22050
|
}
|
|
22020
22051
|
};
|
|
22021
|
-
for (var
|
|
22052
|
+
for (var _i2 = 0, _provPatterns = provPatterns; _i2 < _provPatterns.length; _i2++) {
|
|
22022
22053
|
if (_loop()) break;
|
|
22023
22054
|
}
|
|
22024
22055
|
|
|
@@ -22095,19 +22126,19 @@ function detail_parse_forward(address, sourceData) {
|
|
|
22095
22126
|
|
|
22096
22127
|
// 收集所有 area,同名区优先选择地址中出现对应城市名的
|
|
22097
22128
|
var allAreas = [];
|
|
22098
|
-
for (var
|
|
22099
|
-
var city = matchedProvince.city[
|
|
22129
|
+
for (var _i3 = 0; _i3 < matchedProvince.city.length; _i3++) {
|
|
22130
|
+
var city = matchedProvince.city[_i3];
|
|
22100
22131
|
if (city.area && city.area.length > 0) {
|
|
22101
22132
|
for (var j = 0; j < city.area.length; j++) {
|
|
22102
22133
|
var areaName = city.area[j];
|
|
22103
22134
|
if (areaName && INVALID_AREA_NAMES.indexOf(areaName) === -1 && areaName.length >= 2) {
|
|
22104
|
-
var
|
|
22105
|
-
if (
|
|
22135
|
+
var _idx2 = remaining.indexOf(areaName);
|
|
22136
|
+
if (_idx2 > -1 && _idx2 < 15) {
|
|
22106
22137
|
allAreas.push({
|
|
22107
22138
|
areaName: areaName,
|
|
22108
22139
|
cityName: city.name,
|
|
22109
22140
|
cityData: city,
|
|
22110
|
-
index:
|
|
22141
|
+
index: _idx2
|
|
22111
22142
|
});
|
|
22112
22143
|
}
|
|
22113
22144
|
}
|
|
@@ -22152,8 +22183,8 @@ function detail_parse_forward(address, sourceData) {
|
|
|
22152
22183
|
}).sort(function (a, b) {
|
|
22153
22184
|
return b.length - a.length;
|
|
22154
22185
|
});
|
|
22155
|
-
for (var
|
|
22156
|
-
var streetName = sortedStreets[
|
|
22186
|
+
for (var _i4 = 0; _i4 < sortedStreets.length; _i4++) {
|
|
22187
|
+
var streetName = sortedStreets[_i4];
|
|
22157
22188
|
var streetIdx = _afterArea.indexOf(streetName);
|
|
22158
22189
|
if (streetIdx > -1 && streetIdx < 8) {
|
|
22159
22190
|
parse.street = streetName;
|