@whiteslove/parsing-lexicon 0.9.4 → 0.9.6

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.9.4",
3
+ "version": "0.9.6",
4
4
  "description": "Shared deterministic multilingual parsing lexicon for WhitesLove housing and hiring services",
5
5
  "repository": {
6
6
  "type": "git",
@@ -63,3 +63,22 @@ export function isDirectOwner(value) {
63
63
  export function hasZeroCommissionSignal(value) {
64
64
  return isDirectOwner(value) || (Boolean(value) && EXPLICIT_ZERO_COMMISSION_RE.test(String(value)));
65
65
  }
66
+
67
+ // A Telegram group's own "welcome"/intro post routinely names the group
68
+ // itself, and a real-estate group is typically named after what it rents
69
+ // out ("Оренда квартир Одеса"). That alone can satisfy HOUSING_RE-style
70
+ // content gates even though the message describes no property at all -- it
71
+ // is a greeting, not a listing. No genuine single-property ad opens with
72
+ // "welcome to the group", so this is safe to treat as a strong, low-noise
73
+ // signal on its own.
74
+ const GROUP_WELCOME_RE = /(?:добро\s+пожаловать\s+в\s+групп\p{L}*|ласкаво\s+просимо\s+(?:до|в)\s+груп\p{L}*|welcome\s+to\s+(?:the\s+|our\s+)?group|bine\s+a[țt]i\s+venit\s+[îi]n\s+grup|guruhga\s+xush\s+kelibsiz|топқа\s+қош\s+келдіңіз)/iu;
75
+
76
+ /**
77
+ * A group's channel welcome/intro post, or an off-topic channel
78
+ * cross-promotion riding on the group's housing-flavored name -- neither
79
+ * describes a specific property and both should be excluded from listing
80
+ * feeds even when they incidentally contain housing keywords.
81
+ */
82
+ export function looksLikeGroupWelcomeMessage(value) {
83
+ return Boolean(value) && GROUP_WELCOME_RE.test(String(value));
84
+ }
@@ -49,6 +49,18 @@ export function locationEntries(rows = []) {
49
49
  return Object.freeze(rows.map(([name, ...aliases]) => locationEntry(name, ...aliases)));
50
50
  }
51
51
 
52
+ // Copy an entry's data fields without touching its lazy `re` getter. Object
53
+ // spread invokes getters, which would compile every alias regex eagerly at
54
+ // merge time (tens of seconds at import) instead of on first match.
55
+ function entryData(entry) {
56
+ const data = {};
57
+ if (!entry) return data;
58
+ for (const key of Object.keys(entry)) {
59
+ if (key !== 're') data[key] = entry[key];
60
+ }
61
+ return data;
62
+ }
63
+
52
64
  function mergeEntry(existing, incoming) {
53
65
  const aliases = [...new Set([
54
66
  ...(existing?.aliases || []),
@@ -56,7 +68,7 @@ function mergeEntry(existing, incoming) {
56
68
  existing?.name,
57
69
  incoming?.name,
58
70
  ].filter(Boolean))];
59
- const base = { ...(existing || {}), ...(incoming || {}) };
71
+ const base = { ...entryData(existing), ...entryData(incoming) };
60
72
  // A map-data entry may enrich an existing reviewed owner with additional
61
73
  // aliases. It remains fallback-only only when every merged source is map
62
74
  // data; otherwise the reviewed owner must retain its matching precedence.