@bloomreach/clarity-utils 1.0.7 → 1.0.9

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.
@@ -1,2 +1,2 @@
1
- "use strict";var tmp=(()=>{var y=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var B=(n,e)=>{for(var o in e)y(n,o,{get:e[o],enumerable:!0})},A=(n,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of N(e))!T.call(n,r)&&r!==o&&y(n,r,{get:()=>e[r],enumerable:!(t=U(e,r))||t.enumerable});return n};var G=n=>A(y({},"__esModule",{value:!0}),n);var se={};B(se,{clarityUtils:()=>te});var q={questions:["who","what","when","where","why","how","which","can","should","could","would","will","have","has","is","are","do","does","did"],pronouns:["i","me","my","mine","we","us","our","you","your","it","he","him","his","she","her","they","them","their"],commonVerbs:["is","are","was","were","do","does","did","have","need","want","look","help","know","think","make","create","find","get","buy","use","install","fix","recommend","tell","show","compare","explain"],stopwords:["the","a","an","i","me","my","is","it","in","on","at","to","for","of","and","or","but","not","so","if","by","with","from","that","this","about"],support:["order","package","shipment","tracking","delivery","delayed","late","lost","missing","cancel","modify","return","exchange","refund","replacement","eligible","eligibility","warranty","damaged","broken","defective","wrong","incorrect","password","login","account","locked","verification","otp","loyalty","rewards","reward","points","point","promo","promos","promotion","promotions","coupon","coupons","discount","discounts","gift","gifts","shipping","payment","payments","billing","charged","charge","invoice","receipt","declined","size","sizing","fit","care","stock","restock","availability","sustainability","ethics","careers","privacy","terms","agent","representative","support","human","talk","speak","help","api","failure","server","technical","website","checkout","app","resume","chat","community"],contractions:{"won't":"will not","can't":"cannot","don't":"do not","doesn't":"does not","didn't":"did not","isn't":"is not","aren't":"are not","wasn't":"was not","weren't":"were not","haven't":"have not","hasn't":"has not","hadn't":"had not","wouldn't":"would not","shouldn't":"should not","couldn't":"could not","what's":"what is","what're":"what are","how's":"how is","where's":"where is","who's":"who is","that's":"that is","there's":"there is","it's":"it is","i'm":"i am","i'd":"i would","i'll":"i will","i've":"i have","we're":"we are","we've":"we have","we'd":"we would","they're":"they are","they've":"they have","you're":"you are","you've":"you have","you'd":"you would"}},H={questions:["wer","was","wann","wo","warum","wieso","weshalb","wie","welche","welcher","welches","kann","kannst","k\xF6nnen","soll","sollte","k\xF6nnte","w\xFCrde","wird","hat","habe","haben","ist","sind","tust","tun"],pronouns:["ich","mich","mir","mein","meine","meiner","meinen","wir","uns","unser","unsere","du","dich","dir","dein","deine","sie","ihnen","er","ihn","ihm","sein","seine","ihr","ihre","es"],commonVerbs:["ist","sind","war","waren","tut","tun","tat","taten","hat","habe","haben","hatte","hatten","brauche","brauchen","m\xF6chte","m\xF6chten","will","willst","wollen","suche","suchen","hilf","helfen","wei\xDF","denke","denken","mache","machen","erstelle","erstellen","finde","finden","kaufe","kaufen","benutze","benutzen","installiere","installieren","repariere","reparieren","empfehle","empfehlen","sage","sagen","zeige","zeigen","vergleiche","vergleichen","erkl\xE4re","erkl\xE4ren"],stopwords:["der","die","das","den","dem","des","ein","eine","einen","einer","eines","ich","mich","mein","ist","es","in","an","auf","zu","f\xFCr","von","und","oder","aber","nicht","also","falls","mit","aus","dass","dieser","diese","dieses","\xFCber"],support:["bestellung","bestellungen","paket","sendung","versand","lieferung","tracking","verz\xF6gert","versp\xE4tet","verloren","fehlt","fehlend","stornieren","storno","\xE4ndern","r\xFCcksendung","r\xFCckgabe","retoure","umtausch","r\xFCckerstattung","erstattung","ersatz","berechtigt","anspruch","garantie","besch\xE4digt","kaputt","defekt","falsch","fehlerhaft","passwort","anmelden","login","konto","gesperrt","verifizierung","otp","treue","treueprogramm","pr\xE4mien","punkte","aktion","gutschein","rabatt","geschenk","geschenkkarte","versandkosten","zahlung","abrechnung","belastet","rechnung","beleg","quittung","abgelehnt","gr\xF6\xDFe","passform","pflege","lager","verf\xFCgbarkeit","nachhaltigkeit","ethik","karriere","datenschutz","bedingungen","agb","mitarbeiter","vertreter","support","mensch","sprechen","reden","hilfe","api","fehler","server","technisch","webseite","kasse","app","r\xFCckgabe","zur\xFCckgeben","bestellstatus","lieferstatus"]},D={questions:["qui","que","quoi","quand","o\xF9","pourquoi","comment","combien","quel","quelle","quels","quelles","peux","peut","peuvent","dois","doit","devrait","pourrait","aurait","sera","est","sont","fait","font","ai","as","a","avons","avez","ont"],pronouns:["je","moi","mon","ma","mes","mien","mienne","nous","notre","nos","n\xF4tre","tu","te","toi","ton","ta","tes","vous","votre","vos","il","lui","son","sa","ses","elle","ils","elles","leur","leurs"],commonVerbs:["est","sont","\xE9tait","\xE9taient","fait","font","faisait","ai","as","a","avons","avez","ont","avait","avaient","besoin","veux","veut","voulons","voulez","veulent","cherche","cherchons","cherchez","aide","aider","sais","sait","savez","savons","pense","pensons","pensez","fais","faisons","faites","cr\xE9e","cr\xE9er","trouve","trouver","ach\xE8te","acheter","utilise","utiliser","installe","installer","r\xE9pare","r\xE9parer","recommande","recommander","dis","dites","montre","montrer","compare","comparer","explique","expliquer"],stopwords:["le","la","les","un","une","des","du","au","aux","je","me","mon","est","il","elle","dans","sur","\xE0","pour","de","et","ou","mais","pas","donc","si","par","avec","depuis","que","ce","cette","ces"],support:["commande","commandes","colis","envoi","exp\xE9dition","livraison","suivi","retard\xE9","retard","perdu","manquant","annuler","annulation","modifier","retour","retours","\xE9change","remboursement","remplacement","\xE9ligible","\xE9ligibilit\xE9","garantie","endommag\xE9","cass\xE9","d\xE9fectueux","incorrect","erron\xE9","mot de passe","motdepasse","connexion","identifiant","compte","verrouill\xE9","v\xE9rification","otp","fid\xE9lit\xE9","r\xE9compenses","points","promo","promotion","coupon","remise","r\xE9duction","cadeau","paiement","facturation","factur\xE9","facture","re\xE7u","refus\xE9","taille","pointure","ajustement","entretien","stock","disponibilit\xE9","durabilit\xE9","\xE9thique","carri\xE8res","confidentialit\xE9","conditions","agent","repr\xE9sentant","support","humain","parler","aide","api","panne","serveur","technique","site","paiement","app","application","remboursement","retard","site web","question","concernant","couverture","bris\xE9","article","\xE9changer","probl\xE8me","carte","cr\xE9dit","transaction","\xE9chou\xE9e","login","marche","ab\xEEm\xE9e","d'aide","service","client","assistance","tracking","endommage","communaut\xE9","demander","\xE9tiquette","\xE9tudiants","enseignants","rabais","militaires","g\xE9rer"],elisionPrefixes:["j","n","qu","l","d","c","m","t","s"]},I={questions:["chi","cosa","che","quando","dove","perch\xE9","perch\xE8","come","quanto","quanti","quante","quale","quali","posso","pu\xF2","possono","devo","deve","dovrebbe","potrebbe","vorrebbe","sar\xE0","ho","ha","hanno","\xE8","sono","fa","fanno","fai"],pronouns:["io","mi","me","mio","mia","miei","mie","noi","ci","nostro","nostra","nostri","nostre","tu","ti","te","tuo","tua","tuoi","tue","voi","vi","vostro","vostra","vostri","vostre","lui","lei","suo","sua","suoi","sue","loro"],commonVerbs:["\xE8","sono","era","erano","fa","fanno","faceva","ha","ho","hai","abbiamo","avete","hanno","aveva","avevano","bisogno","voglio","vuole","vogliamo","volete","vogliono","cerco","cerca","cerchiamo","cercate","aiuto","aiutare","so","sa","sappiamo","sapete","penso","pensa","pensiamo","faccio","facciamo","fate","creo","creare","trovo","trovare","compro","comprare","uso","usare","installo","installare","riparo","riparare","raccomando","raccomandare","dimmi","dire","mostra","mostrare","confronto","confrontare","spiego","spiegare"],stopwords:["il","lo","la","i","gli","le","un","uno","una","io","mi","mio","\xE8","in","su","a","per","di","da","e","ed","o","ma","non","cos\xEC","se","con","che","questo","questa","questi","queste"],support:["ordine","ordini","pacco","spedizione","consegna","tracciamento","ritardato","ritardo","perso","mancante","annullare","annullamento","modificare","reso","resi","cambio","rimborso","sostituzione","idoneo","idoneit\xE0","garanzia","danneggiato","rotto","difettoso","sbagliato","errato","password","accesso","login","account","bloccato","verifica","otp","fedelt\xE0","premi","punti","promozione","promo","coupon","sconto","regalo","pagamento","fatturazione","addebitato","fattura","ricevuta","rifiutato","taglia","misura","vestibilit\xE0","cura","scorta","disponibilit\xE0","sostenibilit\xE0","etica","carriere","privacy","termini","agente","rappresentante","supporto","umano","parlare","aiuto","api","guasto","server","tecnico","sito","checkout","app","assistenza","restituzione","stato ordine"],elisionPrefixes:["c","l","d","un","m","t","s","all","nell","dell","sull","quell"]},K={questions:["wie","wat","wanneer","waar","waarom","hoe","hoeveel","welke","welk","kan","kunt","kunnen","zou","zal","moet","heb","heeft","hebben","is","zijn","doe","doet","doen"],pronouns:["ik","mij","me","mijn","wij","we","ons","onze","jij","je","jou","jouw","u","uw","hij","hem","zijn","zij","ze","haar","hen","hun","het"],commonVerbs:["is","zijn","was","waren","doet","doe","doen","deed","deden","heb","heeft","hebben","had","hadden","nodig","wil","willen","wilde","zoek","zoeken","help","helpen","weet","weten","denk","denken","maak","maken","maakte","cre\xEBer","cre\xEBren","vind","vinden","vond","koop","kopen","gebruik","gebruiken","installeer","installeren","repareer","repareren","raad","aanraden","vertel","vertellen","toon","tonen","vergelijk","vergelijken","leg","uitleggen"],stopwords:["de","het","een","ik","mij","mijn","is","in","op","aan","naar","voor","van","en","of","maar","niet","dus","als","door","met","vanaf","dat","dit","deze","die","over"],support:["bestelling","bestellingen","pakket","zending","verzending","levering","tracking","vertraagd","laat","verloren","ontbrekend","annuleren","wijzigen","retour","retourneren","ruil","terugbetaling","restitutie","vervanging","geschikt","geschiktheid","garantie","beschadigd","kapot","defect","verkeerd","onjuist","wachtwoord","inloggen","login","account","geblokkeerd","verificatie","otp","loyaliteit","beloningen","punten","promo","promotie","kortingsbon","korting","cadeau","cadeaubon","verzending","betaling","facturering","gefactureerd","factuur","bonnetje","kassabon","geweigerd","maat","pasvorm","verzorging","voorraad","beschikbaarheid","duurzaamheid","ethiek","carri\xE8res","privacy","voorwaarden","medewerker","vertegenwoordiger","ondersteuning","mens","praten","spreken","hulp","api","storing","server","technisch","website","afrekenen","app","klantenservice","bestelstatus","terugsturen"]},E={questions:["qui\xE9n","quien","qu\xE9","que","cu\xE1ndo","cuando","d\xF3nde","donde","porqu\xE9","porque","c\xF3mo","como","cu\xE1l","cual","cu\xE1les","cuales","cu\xE1nto","cuanto","cu\xE1ntos","puedo","puede","pueden","podr\xEDa","deber\xEDa","ser\xEDa","ha","han","es","son","hace","hacen"],pronouns:["yo","me","m\xED","mi","m\xEDo","m\xEDa","m\xEDos","m\xEDas","nosotros","nosotras","nos","nuestro","nuestra","nuestros","nuestras","t\xFA","tu","te","ti","tuyo","tuya","tuyos","tuyas","usted","ustedes","vosotros","vosotras","vuestro","vuestra","\xE9l","ella","su","sus","suyo","suya","ellos","ellas","les","los","las","le","la","lo"],commonVerbs:["es","son","era","eran","est\xE1","est\xE1n","hace","hacen","hac\xEDa","ha","he","has","hemos","hab\xE9is","han","hab\xEDa","hab\xEDan","necesito","necesita","necesitamos","necesitan","quiero","quiere","queremos","quer\xE9is","quieren","busco","busca","buscamos","buscan","ayuda","ayudar","s\xE9","sabe","sabemos","saben","pienso","piensa","pensamos","hago","hacemos","creo","crear","encuentro","encontrar","compro","comprar","uso","usar","instalo","instalar","reparo","reparar","recomiendo","recomendar","dime","decir","muestra","mostrar","comparo","comparar","explico","explicar"],stopwords:["el","la","los","las","un","una","unos","unas","yo","me","mi","es","en","a","al","para","de","del","y","e","o","u","pero","no","as\xED","si","por","con","desde","que","este","esta","estos","estas","sobre"],support:["pedido","pedidos","paquete","env\xEDo","entrega","seguimiento","retrasado","tarde","perdido","faltante","cancelar","cancelaci\xF3n","modificar","devoluci\xF3n","devoluciones","cambio","reembolso","reemplazo","elegible","elegibilidad","garant\xEDa","da\xF1ado","roto","defectuoso","incorrecto","equivocado","contrase\xF1a","acceso","login","cuenta","bloqueada","bloqueado","verificaci\xF3n","otp","fidelidad","recompensas","puntos","promo","promoci\xF3n","cup\xF3n","descuento","regalo","env\xEDo","pago","facturaci\xF3n","cobrado","cargo","factura","recibo","rechazado","talla","tama\xF1o","ajuste","cuidado","inventario","disponibilidad","sostenibilidad","\xE9tica","carreras","privacidad","t\xE9rminos","agente","representante","soporte","humano","hablar","ayuda","api","fallo","servidor","t\xE9cnico","sitio","pago","app","atenci\xF3n al cliente","estado del pedido","devolver","empleo","trabajo","caracter\xEDstica","art\xEDculo","pregunta","igualan","c\xF3digo","promocional","funciona","sobre","promociones","descuentos","actuales","tengo","militares","agotado"]},V={"en-gb":q,"en-us":q,"en-ca":q,"de-de":H,"fr-fr":D,"fr-ca":D,"it-it":I,"nl-nl":K,"es-es":E,"es-us":E},_="en-us",f=n=>{var e,o;return(o=V[(e=n==null?void 0:n.toLowerCase())!=null?e:_])!=null?o:V[_]};var z=n=>!/\w/.test(n),M=(n,e)=>{if(!e||e.length===0)return n;let o=new RegExp(`\\b(${e.join("|")})['\u2019](?=[\\p{L}\\p{N}])`,"giu");return n.replace(o,"$1' ")},X=(n,e)=>e?n.replace(/[\p{L}\p{N}_'’]+/gu,o=>{var r,s;let t=o.replace(/’/g,"'");return(s=(r=e[t])!=null?r:e[o])!=null?s:o}):n,p=(n,e)=>{var s;let o=f(e),t=M(n,o.elisionPrefixes);return(s=X(t,o.contractions).match(/[\p{L}\p{N}_'’]+|[^\s\p{L}\p{N}_'’]/gu))!=null?s:[]},h=n=>{let e=[];for(let o of n.phrases){let t=o.split(/\s+/).filter(Boolean);if(t.length!==0){if(t.length===1){n.tokens.includes(t[0])&&e.push(o);continue}for(let r=0;r<=n.tokens.length-t.length;r++){let s=!0;for(let a=0;a<t.length;a++)if(n.tokens[r+a]!==t[a]){s=!1;break}if(s){e.push(o);break}}}}return e},F=n=>n.reduce((e,o)=>e+o.split(/\s+/).filter(Boolean).length,0);var L=(n,e)=>{if(!e.maxLength)return console.log(" checkLength \u2192 true (no maxLength configured)"),!0;let o=p(n).length,t=o<=e.maxLength;return console.log(` checkLength \u2192 ${t} (wordCount=${o} maxLength=${e.maxLength})`),t};var Y=(n,e)=>{var o;for(let t of(o=e.blackPunctSet)!=null?o:[])if(n.includes(t))return console.log(` punct "${t}" found in sentence \u2192 false (blacklisted)`),!1;return!0},Z=(n,e)=>{var t,r,s,a,l,u,d;if((t=e.blackWordSet)!=null&&t.has(n))return console.log(` word "${n}" \u2192 false (blacklisted)`),!1;if(((s=(r=e.whiteSet)==null?void 0:r.size)!=null?s:0)>0||((l=(a=e.whiteList)==null?void 0:a.length)!=null?l:0)>0){let c=!!((u=e.whiteSet)!=null&&u.has(n)||(d=e.whiteList)!=null&&d.some(i=>i.toLowerCase()===n));return console.log(` word "${n}" \u2192 ${c} (whitelist check)`),c}return console.log(` word "${n}" \u2192 true`),!0},J=(n,e)=>Y(n,e)&&p(n).every(o=>Z(o,e));var C=(n,e)=>{var W,$,j,R,P;let o=p(n,e.locale);if(o.length===0)return!0;let t=f(e.locale),r=(W=e.scoreQuestionWords)!=null?W:t.questions,s=($=e.scorePronouns)!=null?$:t.pronouns,a=(j=e.scoreCommonVerbs)!=null?j:t.commonVerbs,l=(R=e.scoreStopwords)!=null?R:t.stopwords,u=(P=e.scoreSupportWords)!=null?P:t.support,d=h({tokens:o,phrases:u});if(d.length>0)return console.log(` [A] support words: found [${d.join(", ")}] \u2192 conversational (override)`),!1;let c=0,i=0;o.length<=3?(c+=2,console.log(` [B] token count: word count=${o.length} \u22643 \u2192 keyword +2`)):o.length>=6?(i+=2,console.log(` [B] token count: word count=${o.length} \u22656 \u2192 conversational +2`)):console.log(` [B] token count: word count=${o.length} (no score)`);let m=h({tokens:o,phrases:r});m.length>0?(i+=2,console.log(` [C] question words: found [${m.join(", ")}] \u2192 conversational +2`)):console.log(" [C] question words: none");let g=h({tokens:o,phrases:s});g.length>0?(i+=1,console.log(` [D] pronouns: found [${g.join(", ")}] \u2192 conversational +1`)):console.log(" [D] pronouns: none");let S=h({tokens:o,phrases:a});S.length>0?(i+=1,console.log(` [E] common verbs: found [${S.join(", ")}] \u2192 conversational +1`)):console.log(" [E] common verbs: none"),n.includes("?")?(i+=3,console.log(" [F] question mark: found \u2192 conversational +3")):console.log(" [F] question mark: none");let v=F(h({tokens:o,phrases:l})),w=v/o.length;w>.4?(i+=2,console.log(` [G] stopword ratio: ${w.toFixed(2)} (${v}/${o.length}) >0.4 \u2192 conversational +2`)):(c+=1,console.log(` [G] stopword ratio: ${w.toFixed(2)} (${v}/${o.length}) \u22640.4 \u2192 keyword +1`));let k=o.reduce((O,Q)=>O+Q.length,0)/o.length;k>=6?(c+=1,console.log(` [H] avg token length: ${k.toFixed(2)} \u22656 \u2192 keyword +1`)):console.log(` [H] avg token length: ${k.toFixed(2)} (no score)`);let x=c>=i;return console.log(` scores: keyword=${c} conversational=${i} \u2192 ${x?"keyword":"conversational"}`),x};var b={},ee=async n=>{b={...n};let e=new Set,o=new Set,t=new Set;try{return await Promise.all([n.whiteListJson?fetch(n.whiteListJson).then(r=>r.json()).then(r=>{r.forEach(s=>t.add(s.toLowerCase()))}):null,n.blackListJson?fetch(n.blackListJson).then(r=>r.json()).then(r=>{r.forEach(s=>{let a=s.toLowerCase();z(a)?e.add(a):o.add(a)})}):null]),b={...b,blackJsonPunctSet:e,blackJsonWordSet:o,whiteSet:t},{success:!0}}catch(r){return{success:!1,error:r}}},oe=n=>{var o,t,r;let e={...b,...n!=null?n:{}};return e.blackPunctSet=new Set([...(o=e.blackJsonPunctSet)!=null?o:[]]),e.blackWordSet=new Set([...(t=e.blackJsonWordSet)!=null?t:[]]),(r=e.blackList)==null||r.forEach(s=>{var l,u;let a=s.toLowerCase();z(a)?(l=e.blackPunctSet)==null||l.add(a):(u=e.blackWordSet)==null||u.add(a)}),e.scoreQuestionWords&&(e.scoreQuestionWords=e.scoreQuestionWords.map(s=>s.toLowerCase())),e.scorePronouns&&(e.scorePronouns=e.scorePronouns.map(s=>s.toLowerCase())),e.scoreCommonVerbs&&(e.scoreCommonVerbs=e.scoreCommonVerbs.map(s=>s.toLowerCase())),e.scoreStopwords&&(e.scoreStopwords=e.scoreStopwords.map(s=>s.toLowerCase())),e.scoreSupportWords&&(e.scoreSupportWords=e.scoreSupportWords.map(s=>s.toLowerCase())),e},ne=(n,e)=>{var a,l,u,d,c,i,m,g;let o=oe(e),t=n.toLowerCase(),r=p(t);console.group(`[isSearch] "${n}" | mode=${o.mode} | tokens=[${r.join(", ")}] | locale=${o.locale}`),(o.mode==="mixed"||o.mode==="list")&&console.log(`lists: blackWordSet=${(l=(a=o.blackWordSet)==null?void 0:a.size)!=null?l:0} blackPunctSet=${(d=(u=o.blackPunctSet)==null?void 0:u.size)!=null?d:0} whiteSet=${(i=(c=o.whiteSet)==null?void 0:c.size)!=null?i:0} whiteList=${(g=(m=o.whiteList)==null?void 0:m.length)!=null?g:0}`);let s;return o.mode==="length"?s=L(t,o):o.mode==="mixed"?s=J(t,o)&&L(t,o):o.mode==="score"?s=C(t,o):s=C(t,o),console.log(`\u2192 Result: ${s}`),console.groupEnd(),s},te={setup:ee,isSearch:ne};return G(se);})();
1
+ "use strict";var tmp=(()=>{var y=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var A=(n,e)=>{for(var o in e)y(n,o,{get:e[o],enumerable:!0})},G=(n,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of U(e))!B.call(n,r)&&r!==o&&y(n,r,{get:()=>e[r],enumerable:!(t=T(e,r))||t.enumerable});return n};var H=n=>G(y({},"__esModule",{value:!0}),n);var re={};A(re,{clarityUtils:()=>se});var z={questions:["who","what","when","where","why","how","which","can","should","could","would","will","have","has","is","are","do","does","did"],pronouns:["i","me","my","mine","we","us","our","you","your","it","he","him","his","she","her","they","them","their"],commonVerbs:["is","are","was","were","do","does","did","have","need","want","look","help","know","think","make","create","find","get","buy","use","install","fix","recommend","tell","show","compare","explain"],stopwords:["the","a","an","i","me","my","is","it","in","on","at","to","for","of","and","or","but","not","so","if","by","with","from","that","this","about"],support:["order","package","shipment","tracking","delivery","delayed","late","lost","missing","cancel","modify","return","exchange","refund","replacement","eligible","eligibility","warranty","damaged","broken","defective","wrong","incorrect","password","login","account","locked","verification","otp","loyalty","rewards","reward","points","point","promo","promos","promotion","promotions","coupon","coupons","discount","discounts","gift","gifts","shipping","payment","payments","billing","charged","charge","invoice","receipt","declined","size","sizing","fit","care","stock","restock","availability","sustainability","ethics","careers","privacy","terms","agent","representative","support","human","talk","speak","help","api","failure","server","technical","website","checkout","app","resume","chat","community"],contractions:{"won't":"will not","can't":"cannot","don't":"do not","doesn't":"does not","didn't":"did not","isn't":"is not","aren't":"are not","wasn't":"was not","weren't":"were not","haven't":"have not","hasn't":"has not","hadn't":"had not","wouldn't":"would not","shouldn't":"should not","couldn't":"could not","what's":"what is","what're":"what are","how's":"how is","where's":"where is","who's":"who is","that's":"that is","there's":"there is","it's":"it is","i'm":"i am","i'd":"i would","i'll":"i will","i've":"i have","we're":"we are","we've":"we have","we'd":"we would","they're":"they are","they've":"they have","you're":"you are","you've":"you have","you'd":"you would"}},I={questions:["wer","was","wann","wo","warum","wieso","weshalb","wie","welche","welcher","welches","kann","kannst","k\xF6nnen","soll","sollte","k\xF6nnte","w\xFCrde","wird","hat","habe","haben","ist","sind","tust","tun"],pronouns:["ich","mich","mir","mein","meine","meiner","meinen","wir","uns","unser","unsere","du","dich","dir","dein","deine","sie","ihnen","er","ihn","ihm","sein","seine","ihr","ihre","es"],commonVerbs:["ist","sind","war","waren","tut","tun","tat","taten","hat","habe","haben","hatte","hatten","brauche","brauchen","m\xF6chte","m\xF6chten","will","willst","wollen","suche","such","suchen","hilf","helfen","wei\xDF","denke","denken","mache","mach","machen","erstelle","erstellen","finde","find","finden","kaufe","kauf","kaufen","benutze","benutzen","installiere","installieren","repariere","reparieren","empfehle","empfiehl","empfehlen","sage","sag","sagen","zeige","zeig","zeigen","vergleiche","vergleich","vergleichen","erkl\xE4re","erkl\xE4r","erkl\xE4ren"],stopwords:["der","die","das","den","dem","des","ein","eine","einen","einer","eines","ich","mich","mein","ist","es","in","an","auf","zu","f\xFCr","von","und","oder","aber","nicht","also","falls","mit","aus","dass","dieser","diese","dieses","\xFCber"],support:["bestellung","bestellungen","paket","sendung","versand","lieferung","tracking","verz\xF6gert","versp\xE4tet","verloren","fehlt","fehlend","stornieren","storno","\xE4ndern","r\xFCcksendung","r\xFCckgabe","retoure","umtausch","r\xFCckerstattung","erstattung","ersatz","berechtigt","anspruch","garantie","besch\xE4digt","kaputt","defekt","falsch","fehlerhaft","passwort","anmelden","login","konto","gesperrt","verifizierung","otp","treue","treueprogramm","pr\xE4mien","punkte","aktion","gutschein","rabatt","geschenk","geschenkkarte","versandkosten","zahlung","abrechnung","belastet","rechnung","beleg","quittung","abgelehnt","gr\xF6\xDFe","passform","pflege","lager","verf\xFCgbarkeit","nachhaltigkeit","ethik","karriere","datenschutz","bedingungen","agb","mitarbeiter","vertreter","support","mensch","sprechen","reden","hilfe","api","fehler","server","technisch","webseite","kasse","app","r\xFCckgabe","zur\xFCckgeben","bestellstatus","lieferstatus"]},D={questions:["qui","que","quoi","quand","o\xF9","pourquoi","comment","combien","quel","quelle","quels","quelles","peux","peut","peuvent","dois","doit","devrait","pourrait","aurait","sera","est","sont","fait","font","ai","as","a","avons","avez","ont"],pronouns:["je","moi","mon","ma","mes","mien","mienne","nous","notre","nos","n\xF4tre","tu","te","toi","ton","ta","tes","vous","votre","vos","il","lui","son","sa","ses","elle","ils","elles","leur","leurs"],commonVerbs:["est","sont","\xE9tait","\xE9taient","fait","font","faisait","ai","as","a","avons","avez","ont","avait","avaient","besoin","veux","veut","voulons","voulez","veulent","cherche","cherchons","cherchez","aide","aider","sais","sait","savez","savons","pense","pensons","pensez","fais","faisons","faites","cr\xE9e","cr\xE9er","trouve","trouver","ach\xE8te","acheter","utilise","utiliser","installe","installer","r\xE9pare","r\xE9parer","recommande","recommander","dis","dites","montre","montrer","compare","comparer","explique","expliquer","voudrais","voir"],stopwords:["le","la","les","un","une","des","du","au","aux","je","me","mon","est","il","elle","dans","sur","\xE0","pour","de","et","ou","mais","pas","donc","si","par","avec","depuis","que","ce","cette","ces"],support:["commande","commandes","colis","envoi","exp\xE9dition","livraison","suivi","retard\xE9","retard","perdu","manquant","annuler","annulation","modifier","retour","retours","\xE9change","remboursement","remplacement","\xE9ligible","\xE9ligibilit\xE9","garantie","endommag\xE9","cass\xE9","d\xE9fectueux","incorrect","erron\xE9","mot de passe","motdepasse","connexion","identifiant","compte","verrouill\xE9","v\xE9rification","otp","fid\xE9lit\xE9","r\xE9compenses","points","promo","promotion","coupon","remise","r\xE9duction","cadeau","paiement","facturation","factur\xE9","facture","re\xE7u","refus\xE9","taille","pointure","ajustement","entretien","stock","disponibilit\xE9","durabilit\xE9","\xE9thique","carri\xE8res","confidentialit\xE9","conditions","agent","repr\xE9sentant","support","humain","parler","aide","api","panne","serveur","technique","site","paiement","app","application","remboursement","retard","site web","question","concernant","couverture","bris\xE9","article","\xE9changer","probl\xE8me","carte","cr\xE9dit","transaction","\xE9chou\xE9e","login","marche","ab\xEEm\xE9e","d'aide","service","client","assistance","tracking","endommage","communaut\xE9","demander","\xE9tiquette","\xE9tudiants","enseignants","rabais","militaires","g\xE9rer"],elisionPrefixes:["j","n","qu","l","d","c","m","t","s"]},K={questions:["chi","cosa","che","quando","dove","perch\xE9","perch\xE8","come","quanto","quanti","quante","quale","quali","posso","pu\xF2","possono","devo","deve","dovrebbe","potrebbe","vorrebbe","sar\xE0","ho","ha","hanno","\xE8","sono","fa","fanno","fai"],pronouns:["io","mi","me","mio","mia","miei","mie","noi","ci","nostro","nostra","nostri","nostre","tu","ti","te","tuo","tua","tuoi","tue","voi","vi","vostro","vostra","vostri","vostre","lui","lei","suo","sua","suoi","sue","loro"],commonVerbs:["\xE8","sono","era","erano","fa","fanno","faceva","ha","ho","hai","abbiamo","avete","hanno","aveva","avevano","bisogno","voglio","vuole","vogliamo","volete","vogliono","cerco","cerca","cerchiamo","cercate","aiuto","aiuta","aiutami","aiutare","so","sa","sappiamo","sapete","penso","pensa","pensiamo","faccio","facciamo","fate","creo","creare","trovo","trova","trovami","trovare","compro","compra","comprami","comprare","uso","usare","installo","installare","riparo","riparare","raccomando","raccomanda","raccomandami","raccomandare","dimmi","dire","mostra","mostrami","mostrare","confronto","confronta","confrontami","confrontare","spiego","spiega","spiegami","spiegare","sto","cercando"],stopwords:["il","lo","la","i","gli","le","un","uno","una","io","mi","mio","\xE8","in","su","a","per","di","da","e","ed","o","ma","non","cos\xEC","se","con","che","questo","questa","questi","queste"],support:["ordine","ordini","pacco","spedizione","consegna","tracciamento","ritardato","ritardo","perso","mancante","annullare","annullamento","modificare","reso","resi","cambio","rimborso","sostituzione","idoneo","idoneit\xE0","garanzia","danneggiato","rotto","difettoso","sbagliato","errato","password","accesso","login","account","bloccato","verifica","otp","fedelt\xE0","premi","punti","promozione","promo","coupon","sconto","regalo","pagamento","fatturazione","addebitato","fattura","ricevuta","rifiutato","taglia","misura","vestibilit\xE0","cura","scorta","disponibilit\xE0","sostenibilit\xE0","etica","carriere","privacy","termini","agente","rappresentante","supporto","umano","parlare","aiuto","api","guasto","server","tecnico","sito","checkout","app","assistenza","restituzione","stato ordine"],elisionPrefixes:["c","l","d","un","m","t","s","all","nell","dell","sull","quell"]},M={questions:["wie","wat","wanneer","waar","waarom","hoe","hoeveel","welke","welk","kan","kunt","kunnen","zou","zal","moet","heb","heeft","hebben","is","zijn","doe","doet","doen"],pronouns:["ik","mij","me","mijn","wij","we","ons","onze","jij","je","jou","jouw","u","uw","hij","hem","zijn","zij","ze","haar","hen","hun","het"],commonVerbs:["is","zijn","was","waren","doet","doe","doen","deed","deden","heb","heeft","hebben","had","hadden","nodig","wil","willen","wilde","zoek","zoeken","help","helpen","weet","weten","denk","denken","maak","maken","maakte","cre\xEBer","cre\xEBren","vind","vinden","vond","koop","kopen","gebruik","gebruiken","installeer","installeren","repareer","repareren","raad","aanraden","vertel","vertellen","toon","tonen","vergelijk","vergelijken","leg","uitleggen"],stopwords:["de","het","een","ik","mij","mijn","is","in","op","aan","naar","voor","van","en","of","maar","niet","dus","als","door","met","vanaf","dat","dit","deze","die","over"],support:["bestelling","bestellingen","pakket","zending","verzending","levering","tracking","vertraagd","laat","verloren","ontbrekend","annuleren","wijzigen","retour","retourneren","ruil","terugbetaling","restitutie","vervanging","geschikt","geschiktheid","garantie","beschadigd","kapot","defect","verkeerd","onjuist","wachtwoord","inloggen","login","account","geblokkeerd","verificatie","otp","loyaliteit","beloningen","punten","promo","promotie","kortingsbon","korting","cadeau","cadeaubon","verzending","betaling","facturering","gefactureerd","factuur","bonnetje","kassabon","geweigerd","maat","pasvorm","verzorging","voorraad","beschikbaarheid","duurzaamheid","ethiek","carri\xE8res","privacy","voorwaarden","medewerker","vertegenwoordiger","ondersteuning","mens","praten","spreken","hulp","api","storing","server","technisch","website","afrekenen","app","klantenservice","bestelstatus","terugsturen"]},E={questions:["qui\xE9n","quien","qu\xE9","que","cu\xE1ndo","cuando","d\xF3nde","donde","porqu\xE9","porque","c\xF3mo","como","cu\xE1l","cual","cu\xE1les","cuales","cu\xE1nto","cuanto","cu\xE1ntos","puedo","puede","pueden","podr\xEDa","deber\xEDa","ser\xEDa","ha","han","es","son","hace","hacen"],pronouns:["yo","me","m\xED","mi","m\xEDo","m\xEDa","m\xEDos","m\xEDas","nosotros","nosotras","nos","nuestro","nuestra","nuestros","nuestras","t\xFA","tu","te","ti","tuyo","tuya","tuyos","tuyas","usted","ustedes","vosotros","vosotras","vuestro","vuestra","\xE9l","ella","su","sus","suyo","suya","ellos","ellas","les","los","las","le","la","lo","mu\xE9strame"],commonVerbs:["es","son","era","eran","est\xE1","est\xE1n","hace","hacen","hac\xEDa","ha","he","has","hemos","hab\xE9is","han","hab\xEDa","hab\xEDan","necesito","necesita","necesitamos","necesitan","quiero","quiere","queremos","quer\xE9is","quieren","busco","busca","b\xFAscame","buscamos","buscan","ayuda","ay\xFAdame","ayudar","s\xE9","sabe","sabemos","saben","pienso","piensa","pensamos","hago","hacemos","creo","crear","encuentro","encuentra","encu\xE9ntrame","encontrar","compro","compra","c\xF3mprame","comprar","uso","usar","instalo","instalar","reparo","reparar","recomiendo","recomienda","recomi\xE9ndame","recomendar","dime","decir","muestra","mu\xE9strame","mostrar","comparo","compara","comparar","explico","explica","expl\xEDcame","explicar"],stopwords:["el","la","los","las","un","una","unos","unas","yo","me","mi","es","en","a","al","para","de","del","y","e","o","u","pero","no","as\xED","si","por","con","desde","que","este","esta","estos","estas","sobre"],support:["pedido","pedidos","paquete","env\xEDo","entrega","seguimiento","retrasado","tarde","perdido","faltante","cancelar","cancelaci\xF3n","modificar","devoluci\xF3n","devoluciones","cambio","reembolso","reemplazo","elegible","elegibilidad","garant\xEDa","da\xF1ado","roto","defectuoso","incorrecto","equivocado","contrase\xF1a","acceso","login","cuenta","bloqueada","bloqueado","verificaci\xF3n","otp","fidelidad","recompensas","puntos","promo","promoci\xF3n","cup\xF3n","descuento","regalo","env\xEDo","pago","facturaci\xF3n","cobrado","cargo","factura","recibo","rechazado","talla","tama\xF1o","ajuste","cuidado","inventario","disponibilidad","sostenibilidad","\xE9tica","carreras","privacidad","t\xE9rminos","agente","representante","soporte","humano","hablar","ayuda","api","fallo","servidor","t\xE9cnico","sitio","pago","app","atenci\xF3n al cliente","estado del pedido","devolver","empleo","trabajo","caracter\xEDstica","art\xEDculo","pregunta","igualan","c\xF3digo","promocional","funciona","sobre","promociones","descuentos","actuales","tengo","militares","agotado"]},V={"en-gb":z,"en-us":z,"en-ca":z,"de-de":I,"fr-fr":D,"fr-ca":D,"it-it":K,"nl-nl":M,"es-es":E,"es-us":E},_="en-us",f=n=>{var e,o;return(o=V[(e=n==null?void 0:n.toLowerCase())!=null?e:_])!=null?o:V[_]};var q=n=>!/\w/.test(n),F=n=>n.normalize("NFD").replace(/[̀-ͯ]/g,""),X=(n,e)=>{if(!e||e.length===0)return n;let o=new RegExp(`\\b(${e.join("|")})['\u2019](?=[\\p{L}\\p{N}])`,"giu");return n.replace(o,"$1' ")},Y=(n,e)=>e?n.replace(/[\p{L}\p{N}_'’]+/gu,o=>{var r,s;let t=o.replace(/’/g,"'");return(s=(r=e[t])!=null?r:e[o])!=null?s:o}):n,p=(n,e)=>{var s;let o=f(e),t=X(n,o.elisionPrefixes);return(s=Y(t,o.contractions).match(/[\p{L}\p{N}_'’]+|[^\s\p{L}\p{N}_'’]/gu))!=null?s:[]},m=n=>{let e=[],o=n.tokens.map(F);for(let t of n.phrases){let r=t.split(/\s+/).filter(Boolean).map(F);if(r.length!==0){if(r.length===1){o.includes(r[0])&&e.push(t);continue}for(let s=0;s<=o.length-r.length;s++){let a=!0;for(let i=0;i<r.length;i++)if(o[s+i]!==r[i]){a=!1;break}if(a){e.push(t);break}}}}return e},J=n=>n.reduce((e,o)=>e+o.split(/\s+/).filter(Boolean).length,0);var L=(n,e)=>{if(!e.maxLength)return console.log(" checkLength \u2192 true (no maxLength configured)"),!0;let o=p(n).length,t=o<=e.maxLength;return console.log(` checkLength \u2192 ${t} (wordCount=${o} maxLength=${e.maxLength})`),t};var Z=(n,e)=>{var o;for(let t of(o=e.blackPunctSet)!=null?o:[])if(n.includes(t))return console.log(` punct "${t}" found in sentence \u2192 false (blacklisted)`),!1;return!0},ee=(n,e)=>{var t,r,s,a,i,u,d;if((t=e.blackWordSet)!=null&&t.has(n))return console.log(` word "${n}" \u2192 false (blacklisted)`),!1;if(((s=(r=e.whiteSet)==null?void 0:r.size)!=null?s:0)>0||((i=(a=e.whiteList)==null?void 0:a.length)!=null?i:0)>0){let l=!!((u=e.whiteSet)!=null&&u.has(n)||(d=e.whiteList)!=null&&d.some(c=>c.toLowerCase()===n));return console.log(` word "${n}" \u2192 ${l} (whitelist check)`),l}return console.log(` word "${n}" \u2192 true`),!0},O=(n,e)=>Z(n,e)&&p(n).every(o=>ee(o,e));var x=(n,e)=>{var W,$,j,R,P;let o=p(n,e.locale);if(o.length===0)return!0;let t=f(e.locale),r=(W=e.scoreQuestionWords)!=null?W:t.questions,s=($=e.scorePronouns)!=null?$:t.pronouns,a=(j=e.scoreCommonVerbs)!=null?j:t.commonVerbs,i=(R=e.scoreStopwords)!=null?R:t.stopwords,u=(P=e.scoreSupportWords)!=null?P:t.support,d=m({tokens:o,phrases:u});if(d.length>0)return console.log(` [A] support words: found [${d.join(", ")}] \u2192 conversational (override)`),!1;let l=0,c=0;o.length<=3?(l+=2,console.log(` [B] token count: word count=${o.length} \u22643 \u2192 keyword +2`)):o.length>=6?(c+=2,console.log(` [B] token count: word count=${o.length} \u22656 \u2192 conversational +2`)):console.log(` [B] token count: word count=${o.length} (no score)`);let h=m({tokens:o,phrases:r});h.length>0?(c+=2,console.log(` [C] question words: found [${h.join(", ")}] \u2192 conversational +2`)):console.log(" [C] question words: none");let g=m({tokens:o,phrases:s});g.length>0?(c+=1,console.log(` [D] pronouns: found [${g.join(", ")}] \u2192 conversational +1`)):console.log(" [D] pronouns: none");let C=m({tokens:o,phrases:a});C.length>0?(c+=2,console.log(` [E] common verbs: found [${C.join(", ")}] \u2192 conversational +2`)):console.log(" [E] common verbs: none"),n.includes("?")?(c+=3,console.log(" [F] question mark: found \u2192 conversational +3")):console.log(" [F] question mark: none");let b=J(m({tokens:o,phrases:i})),w=b/o.length;w>.4?(c+=2,console.log(` [G] stopword ratio: ${w.toFixed(2)} (${b}/${o.length}) >0.4 \u2192 conversational +2`)):(l+=1,console.log(` [G] stopword ratio: ${w.toFixed(2)} (${b}/${o.length}) \u22640.4 \u2192 keyword +1`));let k=o.reduce((N,Q)=>N+Q.length,0)/o.length;k>=6?(l+=1,console.log(` [H] avg token length: ${k.toFixed(2)} \u22656 \u2192 keyword +1`)):console.log(` [H] avg token length: ${k.toFixed(2)} (no score)`);let S=l>=c;return console.log(` scores: keyword=${l} conversational=${c} \u2192 ${S?"keyword":"conversational"}`),S};var v={},oe=async n=>{v={...n};let e=new Set,o=new Set,t=new Set;try{return await Promise.all([n.whiteListJson?fetch(n.whiteListJson).then(r=>r.json()).then(r=>{r.forEach(s=>t.add(s.toLowerCase()))}):null,n.blackListJson?fetch(n.blackListJson).then(r=>r.json()).then(r=>{r.forEach(s=>{let a=s.toLowerCase();q(a)?e.add(a):o.add(a)})}):null]),v={...v,blackJsonPunctSet:e,blackJsonWordSet:o,whiteSet:t},{success:!0}}catch(r){return{success:!1,error:r}}},ne=n=>{var o,t,r;let e={...v,...n!=null?n:{}};return e.blackPunctSet=new Set([...(o=e.blackJsonPunctSet)!=null?o:[]]),e.blackWordSet=new Set([...(t=e.blackJsonWordSet)!=null?t:[]]),(r=e.blackList)==null||r.forEach(s=>{var i,u;let a=s.toLowerCase();q(a)?(i=e.blackPunctSet)==null||i.add(a):(u=e.blackWordSet)==null||u.add(a)}),e.scoreQuestionWords&&(e.scoreQuestionWords=e.scoreQuestionWords.map(s=>s.toLowerCase())),e.scorePronouns&&(e.scorePronouns=e.scorePronouns.map(s=>s.toLowerCase())),e.scoreCommonVerbs&&(e.scoreCommonVerbs=e.scoreCommonVerbs.map(s=>s.toLowerCase())),e.scoreStopwords&&(e.scoreStopwords=e.scoreStopwords.map(s=>s.toLowerCase())),e.scoreSupportWords&&(e.scoreSupportWords=e.scoreSupportWords.map(s=>s.toLowerCase())),e},te=(n,e)=>{var a,i,u,d,l,c,h,g;let o=ne(e),t=n.toLowerCase(),r=p(t);console.group(`[isSearch] "${n}" | mode=${o.mode} | tokens=[${r.join(", ")}] | locale=${o.locale}`),(o.mode==="mixed"||o.mode==="list")&&console.log(`lists: blackWordSet=${(i=(a=o.blackWordSet)==null?void 0:a.size)!=null?i:0} blackPunctSet=${(d=(u=o.blackPunctSet)==null?void 0:u.size)!=null?d:0} whiteSet=${(c=(l=o.whiteSet)==null?void 0:l.size)!=null?c:0} whiteList=${(g=(h=o.whiteList)==null?void 0:h.length)!=null?g:0}`);let s;return o.mode==="length"?s=L(t,o):o.mode==="mixed"?s=O(t,o)&&L(t,o):o.mode==="score"?s=x(t,o):s=x(t,o),console.log(`\u2192 Result: ${s}`),console.groupEnd(),s},se={setup:oe,isSearch:te};return H(re);})();
2
2
  window.clarityUtils=tmp.clarityUtils;
package/dist/index.js CHANGED
@@ -336,6 +336,7 @@ var DE_WORDS = {
336
336
  "willst",
337
337
  "wollen",
338
338
  "suche",
339
+ "such",
339
340
  "suchen",
340
341
  "hilf",
341
342
  "helfen",
@@ -343,12 +344,15 @@ var DE_WORDS = {
343
344
  "denke",
344
345
  "denken",
345
346
  "mache",
347
+ "mach",
346
348
  "machen",
347
349
  "erstelle",
348
350
  "erstellen",
349
351
  "finde",
352
+ "find",
350
353
  "finden",
351
354
  "kaufe",
355
+ "kauf",
352
356
  "kaufen",
353
357
  "benutze",
354
358
  "benutzen",
@@ -357,14 +361,19 @@ var DE_WORDS = {
357
361
  "repariere",
358
362
  "reparieren",
359
363
  "empfehle",
364
+ "empfiehl",
360
365
  "empfehlen",
361
366
  "sage",
367
+ "sag",
362
368
  "sagen",
363
369
  "zeige",
370
+ "zeig",
364
371
  "zeigen",
365
372
  "vergleiche",
373
+ "vergleich",
366
374
  "vergleichen",
367
375
  "erkl\xE4re",
376
+ "erkl\xE4r",
368
377
  "erkl\xE4ren"
369
378
  ],
370
379
  stopwords: [
@@ -625,7 +634,9 @@ var FR_WORDS = {
625
634
  "compare",
626
635
  "comparer",
627
636
  "explique",
628
- "expliquer"
637
+ "expliquer",
638
+ "voudrais",
639
+ "voir"
629
640
  ],
630
641
  stopwords: [
631
642
  "le",
@@ -878,6 +889,8 @@ var IT_WORDS = {
878
889
  "cerchiamo",
879
890
  "cercate",
880
891
  "aiuto",
892
+ "aiuta",
893
+ "aiutami",
881
894
  "aiutare",
882
895
  "so",
883
896
  "sa",
@@ -892,8 +905,12 @@ var IT_WORDS = {
892
905
  "creo",
893
906
  "creare",
894
907
  "trovo",
908
+ "trova",
909
+ "trovami",
895
910
  "trovare",
896
911
  "compro",
912
+ "compra",
913
+ "comprami",
897
914
  "comprare",
898
915
  "uso",
899
916
  "usare",
@@ -902,15 +919,24 @@ var IT_WORDS = {
902
919
  "riparo",
903
920
  "riparare",
904
921
  "raccomando",
922
+ "raccomanda",
923
+ "raccomandami",
905
924
  "raccomandare",
906
925
  "dimmi",
907
926
  "dire",
908
927
  "mostra",
928
+ "mostrami",
909
929
  "mostrare",
910
930
  "confronto",
931
+ "confronta",
932
+ "confrontami",
911
933
  "confrontare",
912
934
  "spiego",
913
- "spiegare"
935
+ "spiega",
936
+ "spiegami",
937
+ "spiegare",
938
+ "sto",
939
+ "cercando"
914
940
  ],
915
941
  stopwords: [
916
942
  "il",
@@ -1338,7 +1364,8 @@ var ES_WORDS = {
1338
1364
  "las",
1339
1365
  "le",
1340
1366
  "la",
1341
- "lo"
1367
+ "lo",
1368
+ "mu\xE9strame"
1342
1369
  ],
1343
1370
  commonVerbs: [
1344
1371
  "es",
@@ -1369,9 +1396,11 @@ var ES_WORDS = {
1369
1396
  "quieren",
1370
1397
  "busco",
1371
1398
  "busca",
1399
+ "b\xFAscame",
1372
1400
  "buscamos",
1373
1401
  "buscan",
1374
1402
  "ayuda",
1403
+ "ay\xFAdame",
1375
1404
  "ayudar",
1376
1405
  "s\xE9",
1377
1406
  "sabe",
@@ -1385,8 +1414,12 @@ var ES_WORDS = {
1385
1414
  "creo",
1386
1415
  "crear",
1387
1416
  "encuentro",
1417
+ "encuentra",
1418
+ "encu\xE9ntrame",
1388
1419
  "encontrar",
1389
1420
  "compro",
1421
+ "compra",
1422
+ "c\xF3mprame",
1390
1423
  "comprar",
1391
1424
  "uso",
1392
1425
  "usar",
@@ -1395,14 +1428,20 @@ var ES_WORDS = {
1395
1428
  "reparo",
1396
1429
  "reparar",
1397
1430
  "recomiendo",
1431
+ "recomienda",
1432
+ "recomi\xE9ndame",
1398
1433
  "recomendar",
1399
1434
  "dime",
1400
1435
  "decir",
1401
1436
  "muestra",
1437
+ "mu\xE9strame",
1402
1438
  "mostrar",
1403
1439
  "comparo",
1440
+ "compara",
1404
1441
  "comparar",
1405
1442
  "explico",
1443
+ "explica",
1444
+ "expl\xEDcame",
1406
1445
  "explicar"
1407
1446
  ],
1408
1447
  stopwords: [
@@ -1569,6 +1608,7 @@ var resolveDefaultWords = (locale) => {
1569
1608
 
1570
1609
  // src/utils.ts
1571
1610
  var isPunct = (s) => !/\w/.test(s);
1611
+ var stripDiacritics = (s) => s.normalize("NFD").replace(/[̀-ͯ]/g, "");
1572
1612
  var splitElisions = (query, prefixes) => {
1573
1613
  if (!prefixes || prefixes.length === 0) return query;
1574
1614
  const pattern = new RegExp(`\\b(${prefixes.join("|")})['\u2019](?=[\\p{L}\\p{N}])`, "giu");
@@ -1591,17 +1631,18 @@ var tokenize = (query, locale) => {
1591
1631
  };
1592
1632
  var matchPhrases = (a) => {
1593
1633
  const matched = [];
1634
+ const normTokens = a.tokens.map(stripDiacritics);
1594
1635
  for (const phrase of a.phrases) {
1595
- const phraseTokens = phrase.split(/\s+/).filter(Boolean);
1636
+ const phraseTokens = phrase.split(/\s+/).filter(Boolean).map(stripDiacritics);
1596
1637
  if (phraseTokens.length === 0) continue;
1597
1638
  if (phraseTokens.length === 1) {
1598
- if (a.tokens.includes(phraseTokens[0])) matched.push(phrase);
1639
+ if (normTokens.includes(phraseTokens[0])) matched.push(phrase);
1599
1640
  continue;
1600
1641
  }
1601
- for (let i = 0; i <= a.tokens.length - phraseTokens.length; i++) {
1642
+ for (let i = 0; i <= normTokens.length - phraseTokens.length; i++) {
1602
1643
  let hit = true;
1603
1644
  for (let j = 0; j < phraseTokens.length; j++) {
1604
- if (a.tokens[i + j] !== phraseTokens[j]) {
1645
+ if (normTokens[i + j] !== phraseTokens[j]) {
1605
1646
  hit = false;
1606
1647
  break;
1607
1648
  }
@@ -1699,8 +1740,8 @@ var scoreQuery = (query, c) => {
1699
1740
  }
1700
1741
  const matchedVerbs = matchPhrases({ tokens, phrases: commonVerbs });
1701
1742
  if (matchedVerbs.length > 0) {
1702
- scoreConversational += 1;
1703
- console.log(` [E] common verbs: found [${matchedVerbs.join(", ")}] \u2192 conversational +1`);
1743
+ scoreConversational += 2;
1744
+ console.log(` [E] common verbs: found [${matchedVerbs.join(", ")}] \u2192 conversational +2`);
1704
1745
  } else {
1705
1746
  console.log(` [E] common verbs: none`);
1706
1747
  }