@whiteslove/parsing-lexicon 0.5.13 → 0.5.14

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whiteslove/parsing-lexicon",
3
- "version": "0.5.13",
3
+ "version": "0.5.14",
4
4
  "description": "Shared deterministic multilingual parsing lexicon for WhitesLove housing and hiring services",
5
5
  "repository": {
6
6
  "type": "git",
@@ -220,4 +220,4 @@
220
220
  "geography"
221
221
  ],
222
222
  "license": "MIT"
223
- }
223
+ }
@@ -7,7 +7,7 @@ import { GENERIC_LANDMARK_TERMS } from './landmarks.js';
7
7
  import { LOCATION_RELATIONS, parseHousingContext } from './housing-context.js';
8
8
  import { resolveHousingIntent } from './housing-intent.js';
9
9
  import { countryCurrency, countryPhoneHint } from './country-context.js';
10
- import { findTelegramContacts, parsePhoneNumbers } from './contact.js';
10
+ import { findTelegramContacts, maskPhoneLikeSpans, parsePhoneNumbers } from './contact.js';
11
11
  import { parseHousingAddress } from './housing-address.js';
12
12
  import { parseHousingListingFields } from './housing-listing-fields.js';
13
13
  import { parseHousingPrice } from './housing-money.js';
@@ -167,8 +167,9 @@ export function parseHousingAreas(value) {
167
167
  }
168
168
 
169
169
  function amountAroundKeyword(text, keywordRe) {
170
- const after = text.match(new RegExp(`${keywordRe.source}[^\\d$€₴₸]{0,24}([$€₴₸])?\\s*(\\d{1,9}(?:[.,]\\d{1,2})?)\\s*([\\p{L}.'$€₴₸]{0,12})`, 'iu'));
171
- const before = text.match(new RegExp(`([$€₴₸])?\\s*(\\d{1,9}(?:[.,]\\d{1,2})?)\\s*([\\p{L}.']{0,12})[^\\d]{0,16}${keywordRe.source}`, 'iu'));
170
+ const value = maskPhoneLikeSpans(text);
171
+ const after = value.match(new RegExp(`${keywordRe.source}[^\\d$€₴₸\\r\\n]{0,24}([$€₴₸])?\\s*(\\d{1,3}(?:[ \\u00a0]\\d{3})+|\\d{1,9}(?:[.,]\\d{1,2})?)\\s*([\\p{L}.'$€₴₸]{0,12})`, 'iu'));
172
+ const before = value.match(new RegExp(`([$€₴₸])?\\s*(\\d{1,3}(?:[ \\u00a0]\\d{3})+|\\d{1,9}(?:[.,]\\d{1,2})?)\\s*([\\p{L}.']{0,12})[^\\d\\r\\n]{0,16}${keywordRe.source}`, 'iu'));
172
173
  const match = after || before;
173
174
  if (!match) return { amount: null, currency: null };
174
175
  const amount = toNumber(match[2]);