@aglyn/plugins-ai 1.2.0 → 1.3.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.
Files changed (53) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-site-import-job.component.js +2 -2
  3. package/src/lib/components/ai-site-import-job.component.js.map +1 -1
  4. package/src/lib/jobs/ai-job-import-step.d.ts +35 -2
  5. package/src/lib/jobs/ai-job-import-step.js +124 -12
  6. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  7. package/src/lib/jobs/ai-jobs.d.ts +6 -0
  8. package/src/lib/jobs/ai-jobs.js +43 -6
  9. package/src/lib/jobs/ai-jobs.js.map +1 -1
  10. package/src/lib/jobs/ai-layout-stock-photos.d.ts +13 -6
  11. package/src/lib/jobs/ai-layout-stock-photos.js +104 -32
  12. package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
  13. package/src/lib/jobs/ai-site-import-compile.js +110 -23
  14. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  15. package/src/lib/jobs/ai-site-import-document.d.ts +5 -0
  16. package/src/lib/jobs/ai-site-import-document.js.map +1 -1
  17. package/src/lib/jobs/ai-site-import-forms.d.ts +83 -0
  18. package/src/lib/jobs/ai-site-import-forms.js +376 -0
  19. package/src/lib/jobs/ai-site-import-forms.js.map +1 -0
  20. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.d.ts +21 -0
  21. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.js +77 -0
  22. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.js.map +1 -0
  23. package/src/lib/layout-language/ai-layout-compiler.d.ts +2 -0
  24. package/src/lib/layout-language/ai-layout-compiler.js +215 -30
  25. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  26. package/src/lib/layout-language/ai-layout-language.d.ts +12 -0
  27. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  28. package/src/lib/model/ai-credit-estimate.d.ts +25 -22
  29. package/src/lib/model/ai-credit-estimate.js +24 -22
  30. package/src/lib/model/ai-credit-estimate.js.map +1 -1
  31. package/src/lib/model/ai-site-import-fidelity.d.ts +2 -0
  32. package/src/lib/model/ai-site-import-fidelity.js +41 -5
  33. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  34. package/src/lib/model/ai-site-import-report.d.ts +60 -0
  35. package/src/lib/model/ai-site-import-report.js +116 -0
  36. package/src/lib/model/ai-site-import-report.js.map +1 -0
  37. package/src/lib/model/ai-site-import-view.d.ts +7 -1
  38. package/src/lib/model/ai-site-import-view.js +14 -2
  39. package/src/lib/model/ai-site-import-view.js.map +1 -1
  40. package/src/lib/model/ai-site-import.d.ts +49 -2
  41. package/src/lib/model/ai-site-import.js +81 -23
  42. package/src/lib/model/ai-site-import.js.map +1 -1
  43. package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +4 -0
  44. package/src/lib/site-import/fixtures/site-layout-recordings.js +9 -4
  45. package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
  46. package/src/lib/site-import/site-import-css.d.ts +10 -1
  47. package/src/lib/site-import/site-import-css.js +19 -12
  48. package/src/lib/site-import/site-import-css.js.map +1 -1
  49. package/src/lib/site-import/site-import-html.d.ts +17 -4
  50. package/src/lib/site-import/site-import-html.js +146 -17
  51. package/src/lib/site-import/site-import-html.js.map +1 -1
  52. package/src/lib/site-import/site-import-layout.js +194 -32
  53. package/src/lib/site-import/site-import-layout.js.map +1 -1
@@ -67,7 +67,7 @@ import type { AiBuildPlan } from '../model/ai-build-plan';
67
67
  * never fills anything. A picture of a thing takes only a hit naming its
68
68
  * OBJECT (the head noun, past "set", "gift", "kit": "bowl" in "nesting
69
69
  * bowl set", "candle" in "candle gift set") AND either the site's domain
70
- * or the subject's own two-word phrase ("bud vase"). A broad, hero or
70
+ * or the thing's own two-word name ("bud vase"). A broad, hero or
71
71
  * about search takes only a hit naming the domain. The accepted are
72
72
  * ranked: the object in the hit's first tags (what the photo is OF) over
73
73
  * a mention in its last, the subject's other words, the domain. Among
@@ -732,8 +732,9 @@ export declare function aiStockSensitive(photo: Pick<StockPhoto, 'tags' | 'alt'
732
732
  * How well a hit shows what a slot needs (AGL-3660), or 0 when it must not
733
733
  * fill it: a mockup or a blank never; a topic the site never named never
734
734
  * ({@link aiStockSensitive}); a picture of a thing only when the hit
735
- * names its object AND either the site's world or the subject's own
736
- * two-word phrase ("bud vase", "wick trimmer"); anything else only when it
735
+ * names its object AND either the site's world or, said whole, the thing's own
736
+ * two-word name ("bud vase", "wick trimmer", never "young rider",
737
+ * {@link aiStockPhraseNamesAThing}); anything else only when it
737
738
  * names the site's world (when the site names one). Among the accepted, the
738
739
  * object among the hit's first tags counts 4 (a mention among its last, 2),
739
740
  * the subject's two-word phrase 3, each of its other words 1, and the
@@ -797,9 +798,15 @@ export declare function aiStockForgetJobPhotos(): void;
797
798
  * - of two words for one thing the first tag's stays ("book" over
798
799
  * "bookwork", "camera" over "photo-camera"), unless the later phrase holds
799
800
  * it whole ("wedding dress" over "wedding");
800
- * - a second thing comes only from the first two tags and where no place is
801
- * said, what a person holds only from the first three, where it is set
802
- * from the first ten;
801
+ * - one thing is said, never a second beside it: two tags side by side make
802
+ * no sentence ("A motorcycle and a bike", "Tacos and a beef", AGL-4092); what
803
+ * a person holds comes only from the first three and takes an article or is
804
+ * many ("a woman with a book"), where it is set from the first ten;
805
+ * - an adjective is an adjective wherever it stands: a demonym is said only
806
+ * before its thing ("Mexican food"), and a city or a country, or a plural
807
+ * leading a tag ("tacos pastor"), is no thing at all;
808
+ * - a motor sport's name alone takes no article ("Motocross"), and stands for
809
+ * a word that says too little beside it ("bike", "race") (AGL-4092);
803
810
  * - no word is said twice: never "an elderly couple and an elderly";
804
811
  * - the sky, the clouds and the light are no thing anyone holds, and the
805
812
  * weather is said as where it is: "a couple in the fog at a wedding",
@@ -70,7 +70,7 @@ import { aiStockBusinessNoun } from "./ai-stock-business-nouns.js";
70
70
  * never fills anything. A picture of a thing takes only a hit naming its
71
71
  * OBJECT (the head noun, past "set", "gift", "kit": "bowl" in "nesting
72
72
  * bowl set", "candle" in "candle gift set") AND either the site's domain
73
- * or the subject's own two-word phrase ("bud vase"). A broad, hero or
73
+ * or the thing's own two-word name ("bud vase"). A broad, hero or
74
74
  * about search takes only a hit naming the domain. The accepted are
75
75
  * ranked: the object in the hit's first tags (what the photo is OF) over
76
76
  * a mention in its last, the subject's other words, the domain. Among
@@ -4252,11 +4252,20 @@ const clip = (query)=>query.replace(/\s+/g, ' ').trim().slice(0, STOCK_PHOTO_QUE
4252
4252
  (_photo_alt = photo.alt) != null ? _photo_alt : '',
4253
4253
  slug
4254
4254
  ]);
4255
- const phrases = [
4255
+ const said = [
4256
4256
  ...tags.map((tag)=>stemList(tag).join(' ')),
4257
- stemList((_photo_alt1 = photo.alt) != null ? _photo_alt1 : '').join(' '),
4257
+ stemList((_photo_alt1 = photo.alt) != null ? _photo_alt1 : '').join(' ')
4258
+ ];
4259
+ const phrases = [
4260
+ ...said,
4258
4261
  stemList(slug).join(' ')
4259
4262
  ];
4263
+ // The opening of its page address and no further: past that it runs its tags
4264
+ // together, and "kitesurfer-young-rider-kitesurfing" says no "young rider" (AGL-4092).
4265
+ const whole = [
4266
+ ...said,
4267
+ stemList(slug).slice(0, 2).join(' ')
4268
+ ];
4260
4269
  const leadPhrases = [
4261
4270
  ...tags.slice(0, 3).map((tag)=>stemList(tag).join(' ')),
4262
4271
  stemList(slug).join(' ')
@@ -4272,6 +4281,7 @@ const clip = (query)=>query.replace(/\s+/g, ' ').trim().slice(0, STOCK_PHOTO_QUE
4272
4281
  lead,
4273
4282
  all,
4274
4283
  phrases,
4284
+ whole,
4275
4285
  leadPhrases,
4276
4286
  firstPhrase,
4277
4287
  rejected,
@@ -4296,6 +4306,22 @@ const clip = (query)=>query.replace(/\s+/g, ' ').trim().slice(0, STOCK_PHOTO_QUE
4296
4306
  ].some((term)=>Boolean(term) && (world.has(term) || domain.has(term)));
4297
4307
  });
4298
4308
  }
4309
+ /**
4310
+ * People named by what they do in any world, which says nothing of which
4311
+ * (AGL-4092): a rider rides a dirt bike, a horse or a kite, and a driver a race
4312
+ * car or a bus.
4313
+ */ const ANY_WORLD_PEOPLE = words('rider racer driver player member competitor champion');
4314
+ /**
4315
+ * Whether a subject's last two words, as stems, are a thing's own name, which
4316
+ * says what a photo is OF in any world (AGL-3660): a potter's "bud vase",
4317
+ * "espresso cup". Never what someone or something is like, and never a person
4318
+ * (AGL-4092): a motocross team's "young rider" took a kitesurfer, and a
4319
+ * person's world is whatever they do there, which the two words do not say.
4320
+ */ function aiStockPhraseNamesAThing(pair) {
4321
+ const [kind = '', head = ''] = pair.split(' ');
4322
+ if (DESCRIBING.has(kind) || QUALITIES.has(kind)) return false;
4323
+ return !PEOPLE_NOUNS.has(head) && !ANY_WORLD_PEOPLE.has(head) && !ADULT_PEOPLE_STEMS.includes(head);
4324
+ }
4299
4325
  /**
4300
4326
  * What a picture of a business's world is never OF unless its words name it
4301
4327
  * (AGL-4092): an animal or a toy (as a portfolio's record never is,
@@ -4590,8 +4616,9 @@ const clip = (query)=>query.replace(/\s+/g, ' ').trim().slice(0, STOCK_PHOTO_QUE
4590
4616
  * How well a hit shows what a slot needs (AGL-3660), or 0 when it must not
4591
4617
  * fill it: a mockup or a blank never; a topic the site never named never
4592
4618
  * ({@link aiStockSensitive}); a picture of a thing only when the hit
4593
- * names its object AND either the site's world or the subject's own
4594
- * two-word phrase ("bud vase", "wick trimmer"); anything else only when it
4619
+ * names its object AND either the site's world or, said whole, the thing's own
4620
+ * two-word name ("bud vase", "wick trimmer", never "young rider",
4621
+ * {@link aiStockPhraseNamesAThing}); anything else only when it
4595
4622
  * names the site's world (when the site names one). Among the accepted, the
4596
4623
  * object among the hit's first tags counts 4 (a mention among its last, 2),
4597
4624
  * the subject's two-word phrase 3, each of its other words 1, and the
@@ -4718,6 +4745,8 @@ const clip = (query)=>query.replace(/\s+/g, ' ').trim().slice(0, STOCK_PHOTO_QUE
4718
4745
  ], phrase));
4719
4746
  const pair = subject.length >= 2 ? subject.slice(-2).join(' ') : '';
4720
4747
  const phrased = Boolean(pair) && among(hit.phrases, pair);
4748
+ // Its own name, which stands for the business's world where the hit names none of it.
4749
+ const itsOwnThing = phrased && among(hit.whole, pair) && aiStockPhraseNamesAThing(pair);
4721
4750
  let score = 0;
4722
4751
  if (judgement.strict && object) {
4723
4752
  // An object with kin is named only by them: "melt" alone is resin art.
@@ -4729,7 +4758,7 @@ const clip = (query)=>query.replace(/\s+/g, ' ').trim().slice(0, STOCK_PHOTO_QUE
4729
4758
  // The business's own world, never any word of its type (AGL-4092): a cat
4730
4759
  // tagged "hungry" named "breakfast", and a European alley "street", of
4731
4760
  // "Taco food trailer: street and breakfast tacos".
4732
- if (own.length && !ownWorld && !phrased) return 0;
4761
+ if (own.length && !ownWorld && !itsOwnThing) return 0;
4733
4762
  score += leading ? 4 : 2;
4734
4763
  if (kinNamed) score += 3;
4735
4764
  if (firstNamed(kin.length ? kin : [
@@ -4905,7 +4934,15 @@ function jobPhotos(key) {
4905
4934
  'silhouette silhouettes cutout perspective bokeh closeup ' + // A holiday names when, never a thing: "tet market" is a market.
4906
4935
  'tet christmas easter halloween diwali ramadan hanukkah thanksgiving ' + 'indian asian african american european caucasian vietnamese japanese chinese korean thai latino latina hispanic ' + 'japan vietnam viet nam thailand india china korea germany france italy spain england britain uk usa america ' + 'canada mexico brazil australia africa europe asia ' + // How a scene feels or looks, never a thing in it (AGL-3988): "mountain,
4907
4936
  // snow, winter, cold, couple, color, landscape" is a couple in the snow.
4908
- 'cold warm hot chilly freezing frozen icy color colors colour colours landscape landscapes ' + 'panorama panoramic vista scene scenes');
4937
+ 'cold warm hot chilly freezing frozen icy color colors colour colours landscape landscapes ' + 'panorama panoramic vista scene scenes ' + // What a thing is like, which a tag gives alone (AGL-4092): "A legal and a right", "An extreme and a motorcross".
4938
+ 'legal central extreme electric free open deep fast slow evil ill pregnant basic raw loose abstract dirty ' + 'attractive alternative gigantic spicy crispy crunchy salty savory delicious hungry');
4939
+ /**
4940
+ * A people's or a country's adjective (AGL-4092), an adjective like any other:
4941
+ * "Tacos and a mexican" read as a person. Never a thing alone; before a thing it
4942
+ * says what kind, with its capital ("Mexican food", "a German shepherd"), and
4943
+ * of a person it is left out, as {@link DESCRIBING}'s peoples are ("mexican man"
4944
+ * is a man). "Polish" is not one: "nail polish".
4945
+ */ const DEMONYMS = words('mexican italian french greek spanish portuguese german austrian swiss dutch belgian swedish norwegian danish finnish ' + 'icelandic irish scottish welsh english british russian ukrainian czech slovak hungarian romanian bulgarian serbian ' + 'croatian bosnian albanian turkish persian iranian iraqi syrian lebanese israeli palestinian arabian arabic egyptian ' + 'moroccan tunisian algerian ethiopian kenyan nigerian ghanaian pakistani bangladeshi nepalese tibetan burmese ' + 'cambodian laotian malaysian indonesian filipino taiwanese mongolian australian canadian brazilian argentinian ' + 'argentine chilean colombian peruvian venezuelan ecuadorian bolivian guatemalan salvadoran honduran nicaraguan cuban ' + 'dominican jamaican haitian hawaiian texan californian eurasian siberian tuscan sicilian venetian parisian cajun creole');
4909
4946
  /**
4910
4947
  * The sky and the light over a scene, never a thing in it (AGL-3988): "A
4911
4948
  * couple with a sky at sunset" and "A child with clouds by a lake" were a
@@ -4930,7 +4967,16 @@ function jobPhotos(key) {
4930
4967
  * rather than as a thing of its own (AGL-3856): "a confident lawyer", "an
4931
4968
  * elderly couple", "an analog camera", never "a lawyer, law and a confident".
4932
4969
  */ const QUALITIES = words('confident professional successful serious smart busy creative proud skilled experienced determined focused ' + 'senior junior expert friendly cheerful smiling elderly analog analogue digital mirrorless');
4933
- /** What a tag names that takes no article: "chalk" of "board, chalk". */ const MASS_NOUNS = words('food coffee tea bread wood water wax soap clay money fabric yarn wool furniture jewelry jewellery ' + 'pottery glass paper music art hair makeup chalk paint ink dust stone marble concrete steel metal ' + 'skincare equipment decor wildlife weather traffic wine beer chocolate rice sugar flour milk ' + 'cheese honey oil ice fire light sunlight dough sourdough pastry dessert people foliage greenery faculty staff ' + 'clothing bedding frosting icing flooring');
4970
+ /** What a tag names that takes no article: "chalk" of "board, chalk". */ const MASS_NOUNS = words('food coffee tea bread wood water wax soap clay money fabric yarn wool furniture jewelry jewellery ' + 'pottery glass paper music art hair makeup chalk paint ink dust stone marble concrete steel metal ' + 'skincare equipment decor wildlife weather traffic wine beer chocolate rice sugar flour milk ' + 'cheese honey oil ice fire light sunlight dough sourdough pastry dessert people foliage greenery faculty staff ' + 'clothing bedding frosting icing flooring ' + // Said with an article, these read as a slip (AGL-4092): "A tofu", "A salsa", "A yoga".
4971
+ 'tofu salsa guacamole beef pork meat bacon ham pasta butter cream yogurt yoghurt oatmeal popcorn seafood sushi ' + 'cinnamon basil lavender wheat sand mud dirt gravel moss smog leather plastic porcelain cargo cutlery tableware ' + 'apparel sportswear workwear signage infrastructure agriculture medicine homework math shampoo gastronomy ' + 'physiotherapy podiatry yoga pilates zumba karate judo golf chess poker ballet');
4972
+ /**
4973
+ * A motor sport's name (AGL-4092): alone, said with no article ("Motocross"),
4974
+ * and never a thing anyone holds. Said after a place as it is, as a meet: "A
4975
+ * motocross at dawn".
4976
+ */ const SPORT_NAMES = words('motocross supercross enduro motorsport bmx fmx');
4977
+ /** Words too general to say what a photo shows where a tag names its sport: "A bike", "A race" (AGL-4092). */ const GENERAL_THINGS = words('bike race ride');
4978
+ /** Plurals a thing is named by: "a sports car", "a farmers market". Any other leading a tag is no one thing: "tacos pastor". */ const NAMING_PLURALS = words('sports arts crafts goods sales news clothes farmers');
4979
+ /** Things {@link NAMED_PLACES} spells as a place: "a turkey" of "turkey, roast". */ const THINGS_NAMED_AS_PLACES = words('turkey cologne');
4934
4980
  /** Nouns plural without an "-s": said without an article, "women in a classroom". */ const PLURAL_NOUNS = words('men women people children feet teeth mice geese sheep fish');
4935
4981
  /**
4936
4982
  * What a tag names that no photo shows as a thing of its own (AGL-3856): an
@@ -4939,7 +4985,8 @@ function jobPhotos(key) {
4939
4985
  * ("photo", "spot"). Left out, never said with an article: "A bookwork and a
4940
4986
  * read", "A kettlebell and fitness", "A board and training" said nothing.
4941
4987
  */ const ABSTRACT_NOUNS = words('law justice advocacy business feedback review news return communication communicate discussion dialog conversation ' + 'success career work job satisfaction quality concept idea strategy marketing education technology health support ' + 'confirmation opinion rating evaluation planning project presentation optimization information internet finance ' + 'management leadership teamwork motivation growth strength service services help advice consulting consultation ' + 'marriage photography architecture travel transport transportation industry company corporate social e-business ' + 'fitness workout workouts exercise exercises crossfit sport sports skill skills knowledge exam exams lecture ' + 'session lesson course hobby leisure power energy wellness talent formation participation ' + 'press show day days night year years time holiday month months week weeks morning evening afternoon season seasons ' + 'kiss hug embrace ' + // A feeling, never a thing anyone holds (AGL-3988): "A father with a care".
4942
- 'care worry trust hope joy peace fear faith grief pride comfort safety bliss delight passion desire feeling feelings ' + 'moment moments memory memories fashion style ' + 'photo photos picture pictures image images shot shots shoot shoots spot spots ' + 'read write learn study lift move remove focus relax think sit smile laugh eat swim teach enjoy celebrate explore ' + 'hike can');
4988
+ 'care worry trust hope joy peace fear faith grief pride comfort safety bliss delight passion desire feeling feelings ' + 'moment moments memory memories fashion style ' + 'photo photos picture pictures image images shot shots shoot shoots spot spots ' + 'read write learn study lift move remove focus relax think sit smile laugh eat swim teach enjoy celebrate explore ' + 'hike can ' + // What a photo feels like, or a doing, never what it shows (AGL-4092): "action, bike", "legal, right", "race, action, racer, adventure".
4989
+ 'action adventure speed right rights bake build speak');
4943
4990
  /** Words ending as an idea does that are things: "a station", "a city", "a ship". */ const CONCRETE_ABSTRACT_ENDINGS = words('station mansion lotion potion ornament instrument apartment monument pavement basement garment compartment ' + 'equipment cement city university facility ship warship spaceship airship');
4944
4991
  /** Whether a word is an idea or a doing by how it ends: "participation", "unity", "empowerment". */ const saysAnIdea = (word)=>/(?:tion|sion|ment|ness|ity|ship|ism)s?$/.test(word) && !CONCRETE_ABSTRACT_ENDINGS.has(aiStockStem(word));
4945
4992
  /**
@@ -4956,13 +5003,14 @@ function jobPhotos(key) {
4956
5003
  /** People said by no role: a model is whoever posed (AGL-3856), "a woman" of "woman, model, show, teacher". */ const GENERIC_PEOPLE = words('man men woman women person people human humans guy guys lady ladies adult boy boys girl girls model models ' + 'tourist tourists traveler travelers traveller travellers hiker hikers visitor visitors friend friends crowd');
4957
5004
  /** A parent a photo shows, said with the child beside them: "A father with a girl" (AGL-3988). */ const PARENTS = words('father mother dad mom mum parent parents grandfather grandmother grandparent grandparents');
4958
5005
  /** A child a photo shows beside a parent (AGL-3988). */ const CHILDREN = words('child children kid kids baby babies toddler toddlers girl girls boy boys son sons daughter daughters');
4959
- /** How a family's word is said: "a dad" is a father (AGL-3988). */ const SAID_AS = {
5006
+ /** How a tag's word is said: "a dad" is a father (AGL-3988), and a library's "motorcross" is spelled right (AGL-4092). */ const SAID_AS = {
4960
5007
  dad: 'father',
4961
5008
  dads: 'fathers',
4962
5009
  mom: 'mother',
4963
5010
  moms: 'mothers',
4964
5011
  mum: 'mother',
4965
- mums: 'mothers'
5012
+ mums: 'mothers',
5013
+ motorcross: 'motocross'
4966
5014
  };
4967
5015
  /**
4968
5016
  * A body's parts, never a thing a photo is described by (AGL-3856): "A girl
@@ -5078,25 +5126,30 @@ function jobPhotos(key) {
5078
5126
  /** A tag's words, a word for the photo itself taken off a compound: "photo-camera" is a camera. */ function tagWords(tag) {
5079
5127
  return tag.toLowerCase().replace(/[^a-zÀ-ɏ\s'-]/g, ' ').replace(/\b(?:photo|picture|image)-(?=[a-z])/g, '').split(/\s+/).filter(Boolean);
5080
5128
  }
5129
+ /** Whether a word is said as many, whatever a word ending as a plural does: "tacos", never "lens". */ const saysMany = (word)=>aiStockStem(word) !== word && !/^(?:lens|canvas|atlas|gas|bus)$/.test(word);
5081
5130
  /**
5082
5131
  * A tag as a phrase of an English description (AGL-3856): "a wedding dress",
5083
5132
  * "an attorney", "books", "chalk", "Columbus"; `null` for a tag that names no
5084
5133
  * thing ("extravagant", "feedback", "training", "sony") or is too long to be
5085
5134
  * one.
5086
5135
  */ function describedTag(tag, proper) {
5087
- const describing = (word)=>FILLER.has(word) || DESCRIBING.has(word) || QUALITIES.has(word) || /(?:ous|ful)$/.test(word) || word.length > 4 && /[^e]ed$/.test(word);
5136
+ const describing = (word)=>FILLER.has(word) || DESCRIBING.has(word) || QUALITIES.has(word) || /(?:ous|ful)$/.test(word) || word.length > 4 && /(?:[^e]ed|ical)$/.test(word);
5088
5137
  const all = tagWords(tag);
5138
+ const ofPerson = PEOPLE_NOUNS.has(all[all.length - 1]);
5089
5139
  // "Beautiful flowers" shows flowers; "roasted" shows nothing; "photo model"
5090
5140
  // is a model and "traveling couples" are couples: a word before the last
5091
- // that is a doing says what they do, never what they are.
5092
- const list = all.filter((word, index)=>!describing(word) && !(all.length > 1 && /^(?:photo|picture|image)$/.test(word)) && !(index < all.length - 1 && index > 0 && word.endsWith('ing') && !COUNTED_ING.has(word)));
5141
+ // that is a doing says what they do, never what they are. A demonym is said
5142
+ // only before a thing (AGL-4092).
5143
+ const list = all.filter((word, index)=>!describing(word) && !(DEMONYMS.has(word) && (all.length === 1 || ofPerson)) && !(all.length > 1 && /^(?:photo|picture|image)$/.test(word)) && !(index < all.length - 1 && index > 0 && word.endsWith('ing') && !COUNTED_ING.has(word)));
5093
5144
  if (!list.length || all.length > 3) return null;
5094
5145
  // A phrase of no thing ("up close") or a doing ("take pictures", "to lift", "work out") is not what it shows.
5095
5146
  if (list.every((word)=>STOPWORDS.has(word) && !SAID_PEOPLE.has(word))) return null;
5096
5147
  if (/^(?:to|take|taking|make|making|get|do|go|lie|in|on|at|for|with|by|of)$/.test(list[0])) return null;
5097
5148
  if (/^(?:out|up|off|down|away|on|in)$/.test(list[list.length - 1])) return null;
5098
5149
  if (list.some((word)=>BRANDS.has(word))) return null;
5099
- if (list.every((word)=>proper.has(word))) return list.map((word)=>`${word.charAt(0).toUpperCase()}${word.slice(1)}`).join(' ');
5150
+ if (list.every((word)=>proper.has(word))) return list.map(capitalized).join(' ');
5151
+ // A city or a country the site's own words do not name is no thing (AGL-4092): "A portugal", "An iran".
5152
+ if (NAMED_PLACES.includes(stemPhrase(list.join(' '))) && !THINGS_NAMED_AS_PLACES.has(list[0])) return null;
5100
5153
  // Two people named side by side are both shown: "bride groom" is a bride and groom (AGL-3942).
5101
5154
  if (list.length === 2 && list.every((word)=>PEOPLE_NOUNS.has(word)) && list[0] !== list[1]) return `${articleFor(list[0])} ${list[0]} and ${list[1]}`;
5102
5155
  const last = list[list.length - 1];
@@ -5105,17 +5158,21 @@ function jobPhotos(key) {
5105
5158
  const doing = last.endsWith('ing') && !COUNTED_ING.has(aiStockStem(last)) && !UNCOUNTED_ING.has(last);
5106
5159
  if (doing) return null;
5107
5160
  const phrase = list.join(' ');
5108
- const plural = PLURAL_NOUNS.has(last) || aiStockStem(last) !== last && !/^(?:lens|canvas|atlas|gas|bus)$/.test(last);
5161
+ const plural = PLURAL_NOUNS.has(last) || saysMany(last);
5109
5162
  if (plural || MASS_NOUNS.has(last) || STOPWORDS.has(list[0]) && !SAID_PEOPLE.has(list[0])) return spelled(phrase);
5163
+ // A plural leading a tag is no one thing to say "a" of (AGL-4092): "A tacos pastor".
5164
+ const lead = list[0];
5165
+ if (list.length > 1 && saysMany(lead) && !NAMING_PLURALS.has(lead) && !lead.includes("'")) return null;
5110
5166
  return `${articleFor(phrase)} ${spelled(phrase)}`;
5111
5167
  }
5112
- /** Letters said one by one, written in capitals: "an SLR camera", "a DSLR" (AGL-3942). */ const INITIALISMS = words('slr dslr tv dj diy bbq suv atv uv vr');
5113
- /** A phrase as a description writes it, its initialisms in capitals. */ const spelled = (phrase)=>phrase.split(' ').map((word)=>INITIALISMS.has(word) ? word.toUpperCase() : word).join(' ');
5168
+ /** Letters said one by one, written in capitals: "an SLR camera", "a DSLR" (AGL-3942). */ const INITIALISMS = words('slr dslr tv dj diy bbq suv atv uv vr bmx fmx mtb');
5169
+ const capitalized = (text)=>`${text.charAt(0).toUpperCase()}${text.slice(1)}`;
5170
+ /** A phrase as a description writes it, its initialisms and demonyms in capitals. */ const spelled = (phrase)=>phrase.split(' ').map((word)=>INITIALISMS.has(word) ? word.toUpperCase() : DEMONYMS.has(word) ? capitalized(word) : word).join(' ');
5114
5171
  /** "a" or "an" before a phrase, an initialism by how its first letter is said: "an SLR", "a DSLR". */ const articleFor = (phrase)=>{
5115
5172
  var _phrase_split_;
5116
5173
  const first = (_phrase_split_ = phrase.split(' ')[0]) != null ? _phrase_split_ : '';
5117
5174
  if (INITIALISMS.has(first)) return /^[aefhilmnorsx]/.test(first) ? 'an' : 'a';
5118
- return /^(?:[aeio]|u(?!ni|s[eu]))/.test(phrase) ? 'an' : 'a';
5175
+ return /^(?:[aio]|e(?!u)|u(?!ni|s[eu]))/.test(phrase) ? 'an' : 'a';
5119
5176
  };
5120
5177
  /** Words a description never ends on: an article, a preposition, a conjunction. */ const DANGLING_END = /(?:\s+(?:a|an|the|and|or|with|in|on|at|by|of|for|to|from|into|onto))+$/i;
5121
5178
  /** Whether two words name one thing, one inside the other: "law" and "lawyer", "cam" and "camera". */ function nearSynonyms(a, b) {
@@ -5144,9 +5201,15 @@ function jobPhotos(key) {
5144
5201
  * - of two words for one thing the first tag's stays ("book" over
5145
5202
  * "bookwork", "camera" over "photo-camera"), unless the later phrase holds
5146
5203
  * it whole ("wedding dress" over "wedding");
5147
- * - a second thing comes only from the first two tags and where no place is
5148
- * said, what a person holds only from the first three, where it is set
5149
- * from the first ten;
5204
+ * - one thing is said, never a second beside it: two tags side by side make
5205
+ * no sentence ("A motorcycle and a bike", "Tacos and a beef", AGL-4092); what
5206
+ * a person holds comes only from the first three and takes an article or is
5207
+ * many ("a woman with a book"), where it is set from the first ten;
5208
+ * - an adjective is an adjective wherever it stands: a demonym is said only
5209
+ * before its thing ("Mexican food"), and a city or a country, or a plural
5210
+ * leading a tag ("tacos pastor"), is no thing at all;
5211
+ * - a motor sport's name alone takes no article ("Motocross"), and stands for
5212
+ * a word that says too little beside it ("bike", "race") (AGL-4092);
5150
5213
  * - no word is said twice: never "an elderly couple and an elderly";
5151
5214
  * - the sky, the clouds and the light are no thing anyone holds, and the
5152
5215
  * weather is said as where it is: "a couple in the fog at a wedding",
@@ -5161,7 +5224,8 @@ function jobPhotos(key) {
5161
5224
  *
5162
5225
  * `null` where no tag names a thing.
5163
5226
  */ export function aiStockTagsAlt(tags, proper = new Set()) {
5164
- var _ref;
5227
+ var _ref, _ref1;
5228
+ var _things_;
5165
5229
  const parts = [];
5166
5230
  let quality = '';
5167
5231
  let portrait = false;
@@ -5171,7 +5235,7 @@ function jobPhotos(key) {
5171
5235
  index
5172
5236
  })));
5173
5237
  for (const { tag, index } of read){
5174
- var _ref1;
5238
+ var _ref2;
5175
5239
  var _bare_split_pop;
5176
5240
  const lower = tag.toLowerCase().trim();
5177
5241
  const reading = index < ALT_TAGS_READ;
@@ -5194,12 +5258,12 @@ function jobPhotos(key) {
5194
5258
  if (!said) continue;
5195
5259
  const bare = said.replace(/^an?\s+/, '');
5196
5260
  const stems = stemList(bare);
5197
- const head = (_ref1 = (_bare_split_pop = bare.split(/\s+/).pop()) == null ? void 0 : _bare_split_pop.toLowerCase()) != null ? _ref1 : '';
5261
+ const head = (_ref2 = (_bare_split_pop = bare.split(/\s+/).pop()) == null ? void 0 : _bare_split_pop.toLowerCase()) != null ? _ref2 : '';
5198
5262
  if (!head) continue;
5199
5263
  const headStem = aiStockStem(head);
5200
5264
  const kind = PEOPLE_NOUNS.has(head) || PEOPLE_NOUNS.has(headStem) ? 'person' : PLACES[headStem] ? 'place' : 'thing';
5201
- // Past the first tags only where it is set is read.
5202
- if (!reading && kind !== 'place') continue;
5265
+ // Past the first tags only where it is set is read, and the sport a bike or a race is of.
5266
+ if (!reading && kind !== 'place' && !SPORT_NAMES.has(headStem)) continue;
5203
5267
  // A hand or a body is never what a photo is described by.
5204
5268
  if (kind === 'thing' && (BODY_PARTS.has(head) || BODY_PARTS.has(headStem))) continue;
5205
5269
  if (parts.some((part)=>stems.every((stem)=>part.stems.includes(stem)))) continue;
@@ -5233,6 +5297,12 @@ function jobPhotos(key) {
5233
5297
  let things = parts.filter((part)=>part.kind === 'thing');
5234
5298
  // A kind of thing only where nothing names the thing: "a cat", never "a cat and an animal".
5235
5299
  if (things.some((part)=>!KINDS_OF_THING.has(part.head))) things = things.filter((part)=>!KINDS_OF_THING.has(part.head));
5300
+ // "A bike" and "A race" say little where a tag names the sport (AGL-4092): "Motocross".
5301
+ const sport = things.find((part)=>SPORT_NAMES.has(part.head));
5302
+ if (sport && GENERAL_THINGS.has((_ref = (_things_ = things[0]) == null ? void 0 : _things_.stems.join(' ')) != null ? _ref : '')) things = [
5303
+ sport,
5304
+ ...things.filter((part)=>part !== sport)
5305
+ ];
5236
5306
  // A person tagged after the things a photo is of is not who it shows:
5237
5307
  // "petri, camera, film, photography, photographer" is a camera, and "men,
5238
5308
  // silhouettes, camera, nature, photographer" men with a camera.
@@ -5243,7 +5313,7 @@ function jobPhotos(key) {
5243
5313
  const parent = people.find((part)=>PARENTS.has(part.head) && part.index < ALT_ROLE_TAGS_READ);
5244
5314
  const child = people.find((part)=>CHILDREN.has(part.head) && part.index < ALT_ROLE_TAGS_READ);
5245
5315
  const family = parent && child && (!role || role === parent || role === child) ? parent : undefined;
5246
- const person = (_ref = family != null ? family : role) != null ? _ref : people.find(leads);
5316
+ const person = (_ref1 = family != null ? family : role) != null ? _ref1 : people.find(leads);
5247
5317
  // Nothing but places: a desk is the thing in a classroom; "a school in a classroom" says one place.
5248
5318
  if (!person && !things.length && places.length > 1) {
5249
5319
  const object = places.find((part)=>OBJECT_PLACES.has(part.head));
@@ -5268,11 +5338,11 @@ function jobPhotos(key) {
5268
5338
  if (person && fresh(person)) {
5269
5339
  phrase = portrait ? `a portrait of ${person.said}` : qualified(person);
5270
5340
  const held = family && child && child !== person ? child : things.find((part)=>part.index <= 2);
5271
- if (!portrait && held && fresh(held)) phrase += ` ${CLOTHING.has(held.head) ? 'in' : 'with'} ${held.said}`;
5341
+ // Nothing no one holds, and nothing after it: never "a woman with yoga", nor "a rider with a motocross" (AGL-4092).
5342
+ const holdable = held && !MASS_NOUNS.has(held.head) && !SPORT_NAMES.has(held.head);
5343
+ if (!portrait && holdable && fresh(held)) phrase += ` ${CLOTHING.has(held.head) ? 'in' : 'with'} ${held.said}`;
5272
5344
  } else if (things[0] && fresh(things[0])) {
5273
5345
  phrase = qualified(things[0]);
5274
- const second = things[1];
5275
- if (second && second.index <= 1 && !place && fresh(second)) phrase += ` and ${second.said}`;
5276
5346
  }
5277
5347
  /** A place as it is said alone: "a classroom", "the mountains", "sunset". */ const placeOf = (part)=>{
5278
5348
  var _PLACES_SAID_part_head;
@@ -5305,7 +5375,9 @@ function jobPhotos(key) {
5305
5375
  // Never a dangling article or preposition, whatever a tag left behind.
5306
5376
  phrase = phrase.replace(DANGLING_END, '').trim();
5307
5377
  if (!phrase || /^(?:a|an|the)$/i.test(phrase)) return null;
5308
- const out = `${phrase.charAt(0).toUpperCase()}${phrase.slice(1)}`;
5378
+ const alone = phrase.replace(/^an?\s+/, '');
5379
+ if (SPORT_NAMES.has(alone.toLowerCase())) phrase = alone;
5380
+ const out = capitalized(phrase);
5309
5381
  return out.length > AI_STOCK_ALT_MAX ? out.slice(0, AI_STOCK_ALT_MAX).replace(/[\s,]+\S*$/, '') : out;
5310
5382
  }
5311
5383
  /** The thing a description names: its subject's object, a trailing "speaking calmly" or "dusted" dropped. */ function describedObject(text, sectionName) {