@whiteslove/parsing-lexicon 0.4.3 → 0.4.4
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.
- package/package.json +2 -2
- package/src/locations.js +13 -3
- package/src/uz-location-extensions.js +2 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whiteslove/parsing-lexicon",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "Shared deterministic multilingual parsing lexicon for
|
|
3
|
+
"version": "0.4.4",
|
|
4
|
+
"description": "Shared deterministic multilingual parsing lexicon for WhitesLove housing and hiring services",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/AmoneMisa/parsing-lexicon.git"
|
package/src/locations.js
CHANGED
|
@@ -172,11 +172,21 @@ export function matchDictionaryLocation(text, countryCode, city = null) {
|
|
|
172
172
|
const country = locationCities(countryCode);
|
|
173
173
|
const cities = city && country[city] ? [[city, country[city]]] : Object.entries(country);
|
|
174
174
|
const value = String(text || '');
|
|
175
|
+
let best = null;
|
|
175
176
|
for (const [cityName, data] of cities) {
|
|
176
177
|
for (const type of LOCATION_LIST_KEYS) {
|
|
177
|
-
const
|
|
178
|
-
|
|
178
|
+
for (const entry of data[type] || []) {
|
|
179
|
+
const match = entry?.re?.exec(value);
|
|
180
|
+
if (!match) continue;
|
|
181
|
+
const start = match.index;
|
|
182
|
+
const end = start + match[0].length;
|
|
183
|
+
const containsBest = best && start <= best.start && end >= best.end && end - start > best.end - best.start;
|
|
184
|
+
if (best && !containsBest) continue;
|
|
185
|
+
best = { city: cityName, type, name: entry.name, aliases: entry.aliases, start, end };
|
|
186
|
+
}
|
|
179
187
|
}
|
|
180
188
|
}
|
|
181
|
-
return null;
|
|
189
|
+
if (!best) return null;
|
|
190
|
+
const { start: _start, end: _end, ...result } = best;
|
|
191
|
+
return result;
|
|
182
192
|
}
|
|
@@ -210,6 +210,8 @@ export const UZ_LOCATION_EXTENSIONS = Object.freeze({
|
|
|
210
210
|
['Tashkent City', 'Ташкент Сити', 'Toshkent City', 'Tashkent City IBC'],
|
|
211
211
|
],
|
|
212
212
|
streets: [
|
|
213
|
+
{ name: 'Gulobod Street', aliases: ['Gulobod ko‘chasi', "Gulobod ko'chasi", 'улица Гулобод', 'ул. Гулобод'], parent: 'Shaykhantahur' },
|
|
214
|
+
{ name: 'Sebzor Street', aliases: ['Sebzor ko‘chasi', "Sebzor ko'chasi", 'улица Себзор', 'ул. Себзор'], parent: 'Almazar' },
|
|
213
215
|
{ name: 'Lolazor Street', aliases: ['Lolazor ko‘chasi', "Lolazor ko'chasi", 'улица Лолазор', 'ул. Лолазор'], parent: 'Uchtepa' },
|
|
214
216
|
{ name: 'Shohimardon Street', aliases: ['Shohimardon ko‘chasi', "Shohimardon ko'chasi", 'улица Шохимардон', 'ул. Шохимардон'], parent: 'Yashnobod' },
|
|
215
217
|
{ name: 'Shohimardon Passage 1', aliases: ['Shohimardon 1-tor ko‘chasi', "Shohimardon 1-tor ko'chasi", '1-й проезд Шохимардон', '1 проезд Шохимардон'], parent: 'Yashnobod' },
|