@vectoriox/iox-ui 5.204.0 → 5.206.0
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/data-core/index.d.ts +13 -4
- package/design-core/index.d.ts +277 -6
- package/fesm2022/vectoriox-iox-ui-data-core.mjs +23 -4
- package/fesm2022/vectoriox-iox-ui-data-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +3065 -2673
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +1313 -197
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +71 -19
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs +32 -4
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +145 -82
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +462 -41
- package/harness-core/index.d.ts +52 -12
- package/index.d.ts +44 -3
- package/package.json +1 -1
- package/scene-core/index.d.ts +16 -2
- package/src/data-core/placeholder-rows.ts +24 -3
- package/src/design-core/colour-eval.ts +22 -0
- package/src/design-core/contrast-audit.ts +96 -2
- package/src/design-core/design-token.model.ts +2 -0
- package/src/design-core/flavor-spec.generated.ts +184 -0
- package/src/design-core/font-metrics.ts +14 -1
- package/src/design-core/font-vertical.ts +80 -0
- package/src/design-core/node-links.ts +12 -0
- package/src/design-core/public-api.ts +1 -0
- package/src/design-core/style-presets.ts +20 -1
- package/src/design-core/token-css.ts +3 -1
- package/src/generation-core/ai-run.ts +31 -0
- package/src/generation-core/audit-site.ts +5 -3
- package/src/generation-core/compose-free.ts +1 -1
- package/src/generation-core/compose-layout.ts +172 -22
- package/src/generation-core/critic-calibration.ts +30 -10
- package/src/generation-core/critic-numbers.ts +259 -0
- package/src/generation-core/critic-prompt.ts +74 -6
- package/src/generation-core/critic-rubric.generated.ts +7 -7
- package/src/generation-core/critic-sheet.ts +184 -6
- package/src/generation-core/critic.ts +27 -13
- package/src/generation-core/designer-brief.ts +4 -3
- package/src/generation-core/designer-estimate.ts +3 -3
- package/src/generation-core/layout-render-check.ts +35 -2
- package/src/generation-core/nav-shape.ts +67 -8
- package/src/generation-core/opening-mix.ts +61 -17
- package/src/generation-core/public-api.ts +2 -0
- package/src/generation-core/social-links.ts +47 -8
- package/src/generation-core/stock-photos.ts +149 -14
- package/src/generation-core/stock-search.ts +108 -19
- package/src/generation-core/stock-subjects.ts +204 -0
- package/src/harness-core/business-types.ts +3 -0
- package/src/harness-core/harness-spec.generated.ts +54 -15
- package/src/harness-core/intake.ts +18 -5
- package/src/scene-core/scene.ts +34 -3
- package/styles/iox-design.css +41 -2
- package/styles/iox-forms.css +7 -6
|
@@ -4,6 +4,9 @@ import {
|
|
|
4
4
|
stockWord, stockWords,
|
|
5
5
|
} from './stock-match';
|
|
6
6
|
import type { StockTarget } from './stock-photos';
|
|
7
|
+
import {
|
|
8
|
+
STOCK_FACET_VOCABULARY, STOCK_GENERIC_WORDS, STOCK_UNRELATED_WORDS, stockFacetsOf, stockPlaceNamesIn, stockTagPhrases,
|
|
9
|
+
} from './stock-subjects';
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* What a build may ask a stock provider, and what it may take from the answer (AI plan §3g-live; iox-cms#123,
|
|
@@ -94,17 +97,17 @@ export const STOCK_TRADE_WORDS: Readonly<Record<string, ReadonlyArray<string>>>
|
|
|
94
97
|
vet: ['cat', 'puppy', 'kitten', 'veterinarian', 'paw', 'animal'],
|
|
95
98
|
restaurant: ['dining', 'dinner', 'dish', 'meal', 'plate', 'cuisine', 'cooking', 'gourmet', 'table'],
|
|
96
99
|
'cafe-bakery': ['espresso', 'cappuccino', 'latte', 'barista', 'croissant', 'pastry', 'cake', 'bread', 'muffin', 'dessert', 'breakfast', 'brunch', 'cookie'],
|
|
97
|
-
'bar-winery': ['beer', 'whiskey', 'whisky', 'vineyard', 'grape', 'barrel', 'pub', 'bartender', 'glass'],
|
|
100
|
+
'bar-winery': ['beer', 'whiskey', 'whisky', 'vineyard', 'grape', 'barrel', 'pub', 'bartender', 'glass', 'tap', 'draft'],
|
|
98
101
|
boutique: ['dress', 'apparel', 'garment', 'outfit', 'shoe', 'handbag', 'textile', 'wardrobe'],
|
|
99
102
|
florist: ['rose', 'tulip', 'blossom', 'floral', 'peony', 'orchid', 'succulent', 'greenery', 'vase'],
|
|
100
103
|
'home-goods': ['sofa', 'chair', 'table', 'lamp', 'interior', 'cushion', 'armchair', 'shelf', 'vase'],
|
|
101
|
-
consultant: ['meeting', 'business', 'planning', 'presentation', 'chart', 'office', 'desk', 'teamwork'],
|
|
102
|
-
coach: ['meeting', 'conversation', 'notebook', 'goal', 'growth', 'motivation'],
|
|
104
|
+
consultant: ['meeting', 'business', 'planning', 'presentation', 'chart', 'office', 'desk', 'teamwork', 'laptop', 'computer'],
|
|
105
|
+
coach: ['meeting', 'conversation', 'notebook', 'goal', 'growth', 'motivation', 'laptop'],
|
|
103
106
|
'law-accounting': ['justice', 'court', 'judge', 'gavel', 'contract', 'notary', 'tax', 'finance', 'paperwork', 'document', 'signature', 'desk', 'agreement'],
|
|
104
107
|
nonprofit: ['donation', 'solidarity', 'fundraising', 'charity'],
|
|
105
108
|
'venue-events': ['banquet', 'ballroom', 'celebration', 'reception', 'ceremony', 'catering', 'party'],
|
|
106
109
|
'hotel-bnb': ['bedroom', 'bed', 'suite', 'resort', 'hospitality', 'lobby', 'pillow', 'accommodation', 'villa', 'inn', 'hostel'],
|
|
107
|
-
classes: ['classroom', 'education', 'learning', 'student', 'study', 'piano', 'guitar', 'blackboard'],
|
|
110
|
+
classes: ['classroom', 'education', 'learning', 'student', 'study', 'piano', 'guitar', 'blackboard', 'laptop', 'computer'],
|
|
108
111
|
};
|
|
109
112
|
|
|
110
113
|
/**
|
|
@@ -194,20 +197,34 @@ export function stockSearchTerm(type: Pick<StockSearchType, 'label' | 'match'>):
|
|
|
194
197
|
const SUBJECT_VOCABULARY: ReadonlyMap<StockSubject, ReadonlyMap<string, string>> = new Map(
|
|
195
198
|
(Object.values(StockSubject) as StockSubject[]).map(subject => [subject, new Map(STOCK_SUBJECT_WORDS[subject].map(w => [stockWord(w), w]))]),
|
|
196
199
|
);
|
|
200
|
+
/** Every subject word, as compared → as asked. */
|
|
201
|
+
const ALL_SUBJECT_VOCABULARY: ReadonlyMap<string, string> = new Map([...SUBJECT_VOCABULARY.values()].flatMap(m => [...m]));
|
|
202
|
+
|
|
203
|
+
/** The words a place's OWN text says: a section's text beside the picture (`near`), an item's name (`near`, else `subject`). */
|
|
204
|
+
export function stockPlaceNear(slot: Pick<StockFitPlace, 'near' | 'subject'>): ReadonlyArray<string> {
|
|
205
|
+
return slot.near?.length ? slot.near : slot.subject ?? [];
|
|
206
|
+
}
|
|
197
207
|
|
|
198
208
|
/**
|
|
199
|
-
* The one subject word a place adds to its query:
|
|
200
|
-
*
|
|
201
|
-
*
|
|
209
|
+
* The one subject word a place adds to its query (iox-cms#130: the place's own subject, never scenery). First, the place's
|
|
210
|
+
* OWN words in the order written (the heading beside it, an item's name — "Breakfast on the roof, the bay below" asks
|
|
211
|
+
* `breakfast`): the first that is a closed subject word (`STOCK_SUBJECT_WORDS`, a part of a business `STOCK_FACETS`, the
|
|
212
|
+
* type's imagery). Else, among the words around the place and the type's imagery line, the first that names a subject its
|
|
213
|
+
* intent takes, its best subject first. Never a scenery word (`STOCK_GENERIC_WORDS` — "hotel view" is answered with resort
|
|
214
|
+
* towers), never another trade's place, never the type's own word. None: the base query.
|
|
202
215
|
*/
|
|
203
216
|
export function stockSearchFocus(slot: StockTarget, type: StockSearchType | Pick<StockSearchType, 'imagery'>, term: string): string | null {
|
|
204
217
|
// iox-ui#175: another trade's place word is never the subject ("Boutique law firm" → never "law boutique").
|
|
205
218
|
const vocabulary = 'label' in type ? stockFitFor(type).vocabulary : new Set<string>();
|
|
206
|
-
const words = [...(slot.kind === 'item' ? slot.subject ?? [] : []), ...slot.words, ...stockWords(type.imagery)].filter(w => !foreignTrade(w, vocabulary));
|
|
207
219
|
const asked = new Set(term.split(' ').map(stockWord));
|
|
220
|
+
const open = (w: string) => !asked.has(w) && !STOCK_GENERIC_WORDS.has(w) && !foreignTrade(w, vocabulary);
|
|
221
|
+
const imagery = stockWords(type.imagery).filter(w => !IMAGERY_NOISE.has(w));
|
|
222
|
+
const own = stockPlaceNear(slot).find(w => open(w) && (ALL_SUBJECT_VOCABULARY.has(w) || STOCK_FACET_VOCABULARY.has(w) || imagery.includes(w)));
|
|
223
|
+
if (own) return ALL_SUBJECT_VOCABULARY.get(own) ?? STOCK_FACET_VOCABULARY.get(own) ?? own;
|
|
224
|
+
const words = [...(slot.kind === 'item' ? slot.subject ?? [] : []), ...slot.words, ...stockWords(type.imagery)].filter(open);
|
|
208
225
|
for (const subject of STOCK_INTENT_SUBJECTS[slot.intent as StockIntent] ?? []) {
|
|
209
226
|
const vocabulary = SUBJECT_VOCABULARY.get(subject)!;
|
|
210
|
-
const hit = words.find(w => vocabulary.has(w)
|
|
227
|
+
const hit = words.find(w => vocabulary.has(w));
|
|
211
228
|
if (hit) return vocabulary.get(hit)!;
|
|
212
229
|
}
|
|
213
230
|
return null;
|
|
@@ -265,22 +282,94 @@ export interface StockFitPlace {
|
|
|
265
282
|
readonly intent: string;
|
|
266
283
|
/** A sample item's own name (`StockItemSlot.subject`): a photo that names it shows the item. */
|
|
267
284
|
readonly subject?: ReadonlyArray<string>;
|
|
285
|
+
/** iox-cms#130: every word around the place (`StockNeed.words`) — a word a photo carries that they name is never off-subject. */
|
|
286
|
+
readonly words?: ReadonlyArray<string>;
|
|
287
|
+
/** iox-cms#130: the place's OWN words (`stockNearWords`: the text beside it, an item's name) — the part of the business it shows. */
|
|
288
|
+
readonly near?: ReadonlyArray<string>;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** Why a photo may not stand in a place (`stockRelevance`). */
|
|
292
|
+
export enum StockOffSubject {
|
|
293
|
+
/** A never-word or phrase: crime, ruin, a joke, the trade's fears. */
|
|
294
|
+
Never = 'never',
|
|
295
|
+
/** It shows somewhere else on the map ("china, sanya" for a hotel in Haifa). */
|
|
296
|
+
Elsewhere = 'elsewhere',
|
|
297
|
+
/** It shows something no word of the place or the business names: a laptop, a cruise ship, a drain. */
|
|
298
|
+
Unrelated = 'unrelated',
|
|
299
|
+
/** It shows another part of the business than the place names: a manicure under "straightening". */
|
|
300
|
+
OtherPart = 'other-part',
|
|
301
|
+
/** It does not name the business (twice in an opening). */
|
|
302
|
+
NotTheBusiness = 'not-the-business',
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** A photo read against a place (`stockRelevance`). */
|
|
306
|
+
export interface StockRelevance {
|
|
307
|
+
/** Why it may not stand here, or null when it may. */
|
|
308
|
+
readonly off: `${StockOffSubject}` | null;
|
|
309
|
+
/** The photo's words (or place names) that said so. */
|
|
310
|
+
readonly offWords: ReadonlyArray<string>;
|
|
311
|
+
/** Distinct words of the photo that name the business (`StockFit.vocabulary`; outside an opening an item's name too). */
|
|
312
|
+
readonly business: number;
|
|
313
|
+
/** Distinct words of the photo the place's own words name (`near`) — how closely it shows THIS place. */
|
|
314
|
+
readonly near: number;
|
|
268
315
|
}
|
|
269
316
|
|
|
270
317
|
/**
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
318
|
+
* THE relevance of a stock photo to a place (iox-cms#130; iox-cms#123, iox-ui#175) — pure and deterministic, no model.
|
|
319
|
+
* In order, a photo is off-subject when:
|
|
320
|
+
* 1. any word is a never-word or phrase of the site (`fit.never`, `STOCK_NEVER_PHRASES`);
|
|
321
|
+
* 2. (unreviewed, type known) it names a place on the map (`STOCK_PLACE_NAMES`) and the place's words name none of them;
|
|
322
|
+
* 3. (unreviewed, type known) it carries a word that shows something else (`STOCK_UNRELATED_WORDS`) that neither the place's
|
|
323
|
+
* words nor the business's vocabulary name;
|
|
324
|
+
* 4. the place's own words name a part of the business (`STOCK_FACETS`: hair, nails, a meal, a bed…) and the photo names
|
|
325
|
+
* other parts but none of those — an approved library photo too: it was seen for its type, never for this place;
|
|
326
|
+
* 5. (unreviewed, type known) it does not name the business `STOCK_OPENING_TYPE_WORDS` times in an opening,
|
|
327
|
+
* `STOCK_PLACE_TYPE_WORDS` times elsewhere (iox-ui#175).
|
|
328
|
+
* No type known (`STOCK_FIT_ANY`): the never-words only. The counts are reported for reading a choice; the ranking among the
|
|
329
|
+
* photos that fit stays `scoreStockPhoto` (which already counts the place's words).
|
|
276
330
|
*/
|
|
277
|
-
export function
|
|
331
|
+
export function stockRelevance(photo: Pick<StockPhotoTraits, 'alt' | 'tags' | 'review'>, place: StockFitPlace, fit: StockFit = STOCK_FIT_ANY): StockRelevance {
|
|
278
332
|
const words = stockPhotoWords(photo);
|
|
279
|
-
|
|
333
|
+
const near = new Set(stockPlaceNear(place));
|
|
334
|
+
const counts = { business: businessWordsOf(words, place, fit), near: words.filter(w => near.has(w)).length };
|
|
335
|
+
const off = (why: StockOffSubject, offWords: ReadonlyArray<string>): StockRelevance => ({ off: why, offWords, ...counts });
|
|
336
|
+
const never = words.filter(w => fit.never.has(w));
|
|
337
|
+
if (never.length) return off(StockOffSubject.Never, never);
|
|
280
338
|
const phrases = photoPhrases(photo);
|
|
281
|
-
|
|
282
|
-
if (
|
|
283
|
-
|
|
339
|
+
const neverPhrases = STOCK_NEVER_PHRASES.filter(phrase => phrases.some(p => p.includes(` ${phrase} `)));
|
|
340
|
+
if (neverPhrases.length) return off(StockOffSubject.Never, neverPhrases);
|
|
341
|
+
if (!fit.vocabulary.size) return { off: null, offWords: [], ...counts };
|
|
342
|
+
const reviewed = photo.review?.verdict === StockReviewVerdict.Approved;
|
|
343
|
+
const said = new Set([...(place.words ?? []), ...near, ...(place.subject ?? [])]);
|
|
344
|
+
if (!reviewed) {
|
|
345
|
+
const places = stockPlaceNamesIn(stockTagPhrases(photo.tags?.length ? photo.tags : String(photo.alt ?? '').split(',')));
|
|
346
|
+
if (places.length && !places.some(name => namedBy(name, said))) return off(StockOffSubject.Elsewhere, places);
|
|
347
|
+
const unrelated = words.filter(w => STOCK_UNRELATED_WORDS.has(w) && !said.has(w) && !fit.vocabulary.has(w));
|
|
348
|
+
if (unrelated.length) return off(StockOffSubject.Unrelated, unrelated);
|
|
349
|
+
}
|
|
350
|
+
const parts = stockFacetsOf([...near]);
|
|
351
|
+
const shown = parts.length ? stockFacetsOf(words) : [];
|
|
352
|
+
if (shown.length && !shown.some(f => parts.includes(f))) return off(StockOffSubject.OtherPart, shown);
|
|
353
|
+
if (!reviewed && counts.business < (OPENING_INTENTS.has(place.intent) ? STOCK_OPENING_TYPE_WORDS : STOCK_PLACE_TYPE_WORDS)) {
|
|
354
|
+
return off(StockOffSubject.NotTheBusiness, []);
|
|
355
|
+
}
|
|
356
|
+
return { off: null, offWords: [], ...counts };
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Whether a photo may stand in a place on a site held to `fit` — `stockRelevance` finds nothing off-subject: no never-word
|
|
361
|
+
* or phrase; an unreviewed photo shows the business (its vocabulary twice in an opening, once elsewhere — an item's own
|
|
362
|
+
* name counts there, iox-ui#175), no other place on the map and nothing unrelated (iox-cms#130); and no photo shows another
|
|
363
|
+
* part of the business than the place names. No type known (`STOCK_FIT_ANY`): the never-words only.
|
|
364
|
+
*/
|
|
365
|
+
export function stockPhotoFits(photo: Pick<StockPhotoTraits, 'alt' | 'tags' | 'review'>, slot: StockFitPlace, fit: StockFit = STOCK_FIT_ANY): boolean {
|
|
366
|
+
return stockRelevance(photo, slot, fit).off === null;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/** A place on the map the place's words name (every word of it; a name too short to compare — `uk` — never). */
|
|
370
|
+
function namedBy(name: string, said: ReadonlySet<string>): boolean {
|
|
371
|
+
const words = stockWords(name);
|
|
372
|
+
return words.length > 0 && words.every(w => said.has(w));
|
|
284
373
|
}
|
|
285
374
|
|
|
286
375
|
/** How many distinct words of a photo name the business (the opening: its vocabulary; elsewhere an item's name too). */
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { stockWord, stockWords } from './stock-match';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What a stock photo is ABOUT, against what its place is about (iox-cms#130) — the closed tables the relevance check
|
|
5
|
+
* (`stockRelevance`, stock-search.ts) and the query (`stockSearchFocus`) read. Pure data and word helpers, English (the
|
|
6
|
+
* provider's tags) with a small Hebrew table for the place's own words (a Hebrew site's heading says "החלקה", the photo's
|
|
7
|
+
* tags say "manicure").
|
|
8
|
+
*
|
|
9
|
+
* - PARTS of a business (`STOCK_FACETS`): a salon does hair, nails, make-up; a hotel has rooms, a table, a pool. A place
|
|
10
|
+
* whose own words name a part takes a photo of THAT part — the "straightening" card never a manicure.
|
|
11
|
+
* - Words that say a photo is about SOMETHING ELSE (`STOCK_UNRELATED_WORDS`): a laptop on a café's table, a cruise ship in
|
|
12
|
+
* the bay, a drain in a basin. Off-subject unless the place or the business names it.
|
|
13
|
+
* - Places on the map (`STOCK_PLACE_NAMES`): a photo tagged "china, sanya" shows somewhere else. Off-subject unless the
|
|
14
|
+
* place's words name one of them (a Haifa hotel keeps a photo tagged "haifa").
|
|
15
|
+
* - Scenery words (`STOCK_GENERIC_WORDS`): "bay", "sea", "view" — never what a query asks alone (Pixabay answers "hotel
|
|
16
|
+
* view" with resort towers).
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** Words that only say where a photo looks — never a query's focus, never enough to tie a photo to a place. */
|
|
20
|
+
export const STOCK_GENERIC_WORDS: ReadonlySet<string> = new Set([
|
|
21
|
+
'view', 'landscape', 'scenery', 'scenic', 'panorama', 'horizon', 'beach', 'sea', 'ocean', 'bay', 'coast', 'coastline', 'shore',
|
|
22
|
+
'sky', 'sunset', 'sunrise', 'cloud', 'city', 'town', 'mountain', 'hill', 'forest', 'nature', 'water', 'lake', 'river', 'island',
|
|
23
|
+
'outdoor', 'outside', 'travel', 'holiday', 'vacation', 'tourism', 'summer', 'morning', 'evening', 'night', 'below', 'above',
|
|
24
|
+
].map(stockWord));
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The parts of a business a photo shows (English, compared as `stockWord`s). A word of five letters or more counts in its
|
|
28
|
+
* longer forms (`straighten` → `straightening`). Keys are stable ids, never shown.
|
|
29
|
+
*/
|
|
30
|
+
export const STOCK_FACETS: Readonly<Record<string, ReadonlyArray<string>>> = {
|
|
31
|
+
hair: [
|
|
32
|
+
'hair', 'haircut', 'hairdresser', 'hairdressing', 'hairstyle', 'hairstylist', 'straighten', 'straightening', 'straightener',
|
|
33
|
+
'keratin', 'blowout', 'blowdry', 'barber', 'barbershop', 'shampoo', 'comb', 'scissors', 'curl', 'curly', 'braid', 'highlights',
|
|
34
|
+
'balayage', 'clipper', 'beard',
|
|
35
|
+
],
|
|
36
|
+
nails: ['manicure', 'manicurist', 'pedicure', 'nail', 'fingernail', 'toenail'],
|
|
37
|
+
makeup: ['makeup', 'lipstick', 'mascara', 'eyeshadow', 'eyeliner', 'foundation', 'blush'],
|
|
38
|
+
brows: ['eyelash', 'lash', 'eyebrow', 'brow'],
|
|
39
|
+
skin: ['facial', 'skincare', 'peel', 'serum'],
|
|
40
|
+
massage: ['massage', 'masseur', 'masseuse'],
|
|
41
|
+
sleep: ['bedroom', 'bed', 'suite', 'pillow', 'bedding', 'duvet', 'headboard', 'mattress', 'linen'],
|
|
42
|
+
meal: ['breakfast', 'brunch', 'dinner', 'lunch', 'meal', 'dining', 'buffet'],
|
|
43
|
+
coffee: ['coffee', 'espresso', 'cappuccino', 'latte', 'barista'],
|
|
44
|
+
baking: ['bread', 'pastry', 'croissant', 'cake', 'cookie', 'muffin', 'baguette', 'dough', 'patisserie'],
|
|
45
|
+
pool: ['pool', 'swimming', 'jacuzzi'],
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Words that say a photo shows something no place of a small business asked for — a device on the table, a vehicle in the
|
|
50
|
+
* frame, plumbing, a skyline. Off-subject unless the place's words or the business's own vocabulary name it.
|
|
51
|
+
*/
|
|
52
|
+
export const STOCK_UNRELATED_WORDS: ReadonlySet<string> = new Set([
|
|
53
|
+
// devices
|
|
54
|
+
'laptop', 'computer', 'keyboard', 'smartphone', 'iphone', 'phone', 'mobile', 'tablet', 'ipad', 'monitor', 'screen', 'macbook',
|
|
55
|
+
// vehicles and their places
|
|
56
|
+
'cruise', 'cruiser', 'ship', 'cruiseship', 'ferry', 'tanker', 'airplane', 'aeroplane', 'aircraft', 'airport', 'plane', 'train',
|
|
57
|
+
'railway', 'truck', 'bus', 'car', 'vehicle', 'traffic', 'motorcycle', 'highway',
|
|
58
|
+
// plumbing
|
|
59
|
+
'sink', 'drain', 'faucet', 'tap', 'plughole', 'washbasin', 'basin', 'toilet', 'plumbing',
|
|
60
|
+
// a skyline, not a house
|
|
61
|
+
'skyscraper', 'highrise', 'skyline', 'cityscape', 'downtown', 'metropolis', 'tower',
|
|
62
|
+
].map(stockWord));
|
|
63
|
+
|
|
64
|
+
/** Places on the map a stock photo is tagged with (compared as plain phrases: `new york`, `tel aviv`). */
|
|
65
|
+
export const STOCK_PLACE_NAMES: ReadonlyArray<string> = [
|
|
66
|
+
// countries
|
|
67
|
+
'afghanistan', 'albania', 'algeria', 'argentina', 'armenia', 'australia', 'austria', 'azerbaijan', 'bahamas', 'bangladesh',
|
|
68
|
+
'belgium', 'bolivia', 'bosnia', 'brazil', 'bulgaria', 'cambodia', 'cameroon', 'canada', 'chile', 'china', 'colombia', 'costa rica',
|
|
69
|
+
'croatia', 'cuba', 'cyprus', 'czech', 'czechia', 'denmark', 'dominican republic', 'ecuador', 'egypt', 'england', 'estonia',
|
|
70
|
+
'ethiopia', 'fiji', 'finland', 'france', 'georgia', 'germany', 'ghana', 'greece', 'guatemala', 'hungary', 'iceland', 'india',
|
|
71
|
+
'indonesia', 'iran', 'iraq', 'ireland', 'israel', 'italy', 'jamaica', 'japan', 'jordan', 'kazakhstan', 'kenya', 'korea', 'laos',
|
|
72
|
+
'latvia', 'lebanon', 'lithuania', 'luxembourg', 'madagascar', 'malaysia', 'maldives', 'malta', 'mauritius', 'mexico', 'mongolia',
|
|
73
|
+
'montenegro', 'morocco', 'myanmar', 'namibia', 'nepal', 'netherlands', 'holland', 'new zealand', 'nigeria', 'norway', 'oman',
|
|
74
|
+
'pakistan', 'panama', 'peru', 'philippines', 'poland', 'portugal', 'qatar', 'romania', 'russia', 'saudi arabia', 'scotland',
|
|
75
|
+
'serbia', 'seychelles', 'singapore', 'slovakia', 'slovenia', 'south africa', 'spain', 'sri lanka', 'sweden', 'switzerland',
|
|
76
|
+
'syria', 'taiwan', 'tanzania', 'thailand', 'tunisia', 'ukraine', 'united arab emirates', 'uae', 'united kingdom', 'uk',
|
|
77
|
+
'united states', 'usa', 'america', 'uruguay', 'uzbekistan', 'venezuela', 'vietnam', 'wales', 'zambia', 'zimbabwe',
|
|
78
|
+
// regions and islands a photo is tagged by
|
|
79
|
+
'bali', 'hainan', 'hawaii', 'tuscany', 'provence', 'andalusia', 'sicily', 'sardinia', 'corsica', 'crete', 'santorini', 'mykonos',
|
|
80
|
+
'ibiza', 'mallorca', 'majorca', 'tenerife', 'canary islands', 'madeira', 'phuket', 'zanzibar', 'caribbean', 'patagonia', 'bavaria',
|
|
81
|
+
'alps', 'dolomites', 'amalfi', 'cinque terre', 'lake como', 'galilee', 'golan', 'negev', 'phoenix island',
|
|
82
|
+
// cities
|
|
83
|
+
'sanya', 'beijing', 'shanghai', 'hong kong', 'macau', 'tokyo', 'kyoto', 'osaka', 'seoul', 'bangkok', 'hanoi', 'saigon',
|
|
84
|
+
'ho chi minh', 'kuala lumpur', 'manila', 'jakarta', 'dubai', 'abu dhabi', 'doha', 'istanbul', 'athens', 'rome',
|
|
85
|
+
'venice', 'florence', 'milan', 'naples', 'paris', 'marseille', 'lyon', 'london', 'edinburgh', 'dublin', 'amsterdam',
|
|
86
|
+
'brussels', 'berlin', 'munich', 'hamburg', 'vienna', 'prague', 'budapest', 'warsaw', 'krakow', 'copenhagen', 'stockholm', 'oslo',
|
|
87
|
+
'helsinki', 'lisbon', 'porto', 'madrid', 'barcelona', 'seville', 'valencia', 'zurich', 'geneva', 'moscow', 'new york', 'manhattan',
|
|
88
|
+
'brooklyn', 'chicago', 'los angeles', 'san francisco', 'las vegas', 'miami', 'boston', 'seattle', 'toronto', 'vancouver',
|
|
89
|
+
'montreal', 'mexico city', 'cancun', 'havana', 'rio de janeiro', 'buenos aires', 'lima', 'cairo', 'marrakech', 'cape town',
|
|
90
|
+
'sydney', 'melbourne', 'auckland', 'mumbai', 'delhi', 'jerusalem', 'tel aviv', 'haifa', 'eilat', 'jaffa', 'nazareth',
|
|
91
|
+
'akko', 'tiberias', 'caesarea', 'netanya', 'herzliya', 'beersheba',
|
|
92
|
+
];
|
|
93
|
+
|
|
94
|
+
/** The same, as a set of plain phrases. */
|
|
95
|
+
const PLACE_NAMES: ReadonlySet<string> = new Set(STOCK_PLACE_NAMES);
|
|
96
|
+
/** The longest place name, in words. */
|
|
97
|
+
const PLACE_MAX_WORDS = Math.max(...STOCK_PLACE_NAMES.map(p => p.split(' ').length));
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* A Hebrew site's own words for the parts and subjects above, as the English word a provider's tags carry (a heading
|
|
101
|
+
* "החלקת קרטין" is about `hair`). Compared whole after a one- or two-letter prefix (ה, ו, ב, ל, מ, ש, כ) is taken off;
|
|
102
|
+
* a two-word phrase first ("ארוחת בוקר" is breakfast, "ארוחת ערב" dinner).
|
|
103
|
+
*/
|
|
104
|
+
export const STOCK_SUBJECTS_HE: Readonly<Record<string, string>> = {
|
|
105
|
+
'ארוחת בוקר': 'breakfast', 'ארוחות בוקר': 'breakfast', 'ארוחת ערב': 'dinner', 'ארוחת צהריים': 'lunch', 'חדר שינה': 'bedroom',
|
|
106
|
+
'שיער': 'hair', 'תספורת': 'haircut', 'תספורות': 'haircut', 'החלקה': 'straightening', 'החלקת': 'straightening', 'החלקות': 'straightening',
|
|
107
|
+
'קרטין': 'keratin', 'תסרוקת': 'hairstyle', 'תסרוקות': 'hairstyle', 'גוונים': 'highlights',
|
|
108
|
+
'מניקור': 'manicure', 'פדיקור': 'pedicure', 'ציפורניים': 'nail', 'ציפורן': 'nail', 'לק': 'manicure', 'איפור': 'makeup',
|
|
109
|
+
'ריסים': 'eyelash', 'גבות': 'eyebrow', 'עיסוי': 'massage', 'עיסויים': 'massage', 'טיפולי פנים': 'facial', 'טיפול פנים': 'facial',
|
|
110
|
+
'בראנץ': 'brunch', 'בראנץ׳': 'brunch', 'קפה': 'coffee', 'אספרסו': 'espresso', 'לחם': 'bread', 'מאפים': 'pastry', 'מאפה': 'pastry',
|
|
111
|
+
'עוגה': 'cake', 'עוגות': 'cake', 'קרואסון': 'croissant', 'סוויטה': 'suite', 'סוויטות': 'suite', 'מיטה': 'bed', 'בריכה': 'pool',
|
|
112
|
+
'ג׳קוזי': 'jacuzzi', "ג'קוזי": 'jacuzzi', 'גג': 'rooftop', 'מרפסת': 'terrace', 'גינה': 'garden', 'חצר': 'courtyard',
|
|
113
|
+
};
|
|
114
|
+
const HE_PREFIX = /^[הובלמשכ]/;
|
|
115
|
+
const HE_LETTERS = /[-]/;
|
|
116
|
+
const HTML_TAG = /<[^>]*>/g;
|
|
117
|
+
const TOKEN_SPLIT = /[^\p{L}\p{N}'׳]+/u;
|
|
118
|
+
/** A facet word this long counts in its longer forms. */
|
|
119
|
+
const FACET_STEM_MIN = 5;
|
|
120
|
+
|
|
121
|
+
/** A Hebrew word's English subject, trying it whole, then without one and two prefix letters. */
|
|
122
|
+
function hebrewSubject(word: string): string | undefined {
|
|
123
|
+
let w = word;
|
|
124
|
+
for (let i = 0; i < 3 && w.length >= 2; i++) {
|
|
125
|
+
const hit = STOCK_SUBJECTS_HE[w];
|
|
126
|
+
if (hit) return hit;
|
|
127
|
+
if (!HE_PREFIX.test(w)) return undefined;
|
|
128
|
+
w = w.slice(1);
|
|
129
|
+
}
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** The English subject words a Hebrew text names (phrases first), in order, as `stockWord`s. */
|
|
134
|
+
export function stockSubjectsHe(...texts: ReadonlyArray<unknown>): string[] {
|
|
135
|
+
const out: string[] = [];
|
|
136
|
+
for (const text of texts) {
|
|
137
|
+
if (typeof text !== 'string' || !HE_LETTERS.test(text)) continue;
|
|
138
|
+
const tokens = text.replace(HTML_TAG, ' ').split(TOKEN_SPLIT).filter(Boolean);
|
|
139
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
140
|
+
const pair = i + 1 < tokens.length ? hebrewSubject(`${tokens[i]} ${tokens[i + 1]}`) ?? phraseWithPrefix(tokens[i], tokens[i + 1]) : undefined;
|
|
141
|
+
if (pair) { out.push(stockWord(pair)); i++; continue; }
|
|
142
|
+
const one = hebrewSubject(tokens[i]);
|
|
143
|
+
if (one) out.push(stockWord(one));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return [...new Set(out)];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** A two-word phrase whose first word wears a prefix ("וארוחת בוקר"). */
|
|
150
|
+
function phraseWithPrefix(first: string, second: string): string | undefined {
|
|
151
|
+
let w = first;
|
|
152
|
+
for (let i = 0; i < 2 && HE_PREFIX.test(w); i++) {
|
|
153
|
+
w = w.slice(1);
|
|
154
|
+
const hit = STOCK_SUBJECTS_HE[`${w} ${second}`];
|
|
155
|
+
if (hit) return hit;
|
|
156
|
+
}
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The words a place's OWN text says (the heading beside a picture, a sample item's name): its meaningful words in order,
|
|
162
|
+
* then — a Hebrew text — the English subjects it names (`STOCK_SUBJECTS_HE`). What the place's part and query are read from.
|
|
163
|
+
*/
|
|
164
|
+
export function stockNearWords(...texts: ReadonlyArray<unknown>): string[] {
|
|
165
|
+
return [...new Set([...stockWords(...texts), ...stockSubjectsHe(...texts)])];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Per facet, its words as compared. */
|
|
169
|
+
const FACET_WORDS: ReadonlyArray<[string, ReadonlySet<string>]> = Object.entries(STOCK_FACETS).map(([id, words]) => [id, new Set(words.map(stockWord))]);
|
|
170
|
+
|
|
171
|
+
/** Does `word` name a word of `words` — whole, or a longer form of one of `FACET_STEM_MIN` letters or more? */
|
|
172
|
+
function namesFacetWord(word: string, words: ReadonlySet<string>): boolean {
|
|
173
|
+
if (words.has(word)) return true;
|
|
174
|
+
for (const w of words) if (w.length >= FACET_STEM_MIN && word.length > w.length && word.startsWith(w)) return true;
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** The parts of a business some words name (`STOCK_FACETS` ids), in the table's order. */
|
|
179
|
+
export function stockFacetsOf(words: ReadonlyArray<string>): string[] {
|
|
180
|
+
return FACET_WORDS.filter(([, set]) => words.some(w => namesFacetWord(w, set))).map(([id]) => id);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Every facet word (as asked: the table's spelling), by its compared form — a closed vocabulary a query may carry. */
|
|
184
|
+
export const STOCK_FACET_VOCABULARY: ReadonlyMap<string, string> = new Map(Object.values(STOCK_FACETS).flat().map(w => [stockWord(w), w]));
|
|
185
|
+
|
|
186
|
+
/** A photo's tags as plain phrases (accents gone, lower case, single spaces) — what a place name is looked for in. */
|
|
187
|
+
export function stockTagPhrases(tags: ReadonlyArray<string>): string[] {
|
|
188
|
+
return tags.map(t => String(t ?? '').normalize('NFD').replace(/\p{M}+/gu, '').toLowerCase().replace(/[^\p{L}\p{N}]+/gu, ' ').trim()).filter(Boolean);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** The places on the map some phrases name (each a `STOCK_PLACE_NAMES` entry), each once. */
|
|
192
|
+
export function stockPlaceNamesIn(phrases: ReadonlyArray<string>): string[] {
|
|
193
|
+
const out = new Set<string>();
|
|
194
|
+
for (const phrase of phrases) {
|
|
195
|
+
const words = phrase.split(' ');
|
|
196
|
+
for (let i = 0; i < words.length; i++) {
|
|
197
|
+
for (let n = Math.min(PLACE_MAX_WORDS, words.length - i); n >= 1; n--) {
|
|
198
|
+
const name = words.slice(i, i + n).join(' ');
|
|
199
|
+
if (PLACE_NAMES.has(name)) { out.add(name); i += n - 1; break; }
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return [...out];
|
|
204
|
+
}
|
|
@@ -181,6 +181,9 @@ export interface BusinessType {
|
|
|
181
181
|
readonly uupm: string;
|
|
182
182
|
/** Keywords (English + Hebrew): the eval's expected answer and the no-model fallback. */
|
|
183
183
|
readonly match: ReadonlyArray<string>;
|
|
184
|
+
/** iox-ui#213: those of `match` that also DESCRIBE other businesses ("a boutique hotel", "a coffee shop") — they name
|
|
185
|
+
* this type only when no other type's keyword is in the words (`matchBusinessTypes`). Empty for most types. */
|
|
186
|
+
readonly qualifiers: ReadonlyArray<string>;
|
|
184
187
|
/** The styles that suit it, best first, each with why. */
|
|
185
188
|
readonly good: ReadonlyArray<GoodFit>;
|
|
186
189
|
/** Colour v2 CV2: its mood and swatches, and (H1) the colour words its site NEVER wears (`<ingredient>.<word>`, harness
|