UNPKG

compromise

Version:
1 lines 353 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).nlp=t()}(this,(function(){"use strict";var e={methods:{one:{},two:{},three:{},four:{}},model:{one:{},two:{},three:{}},compute:{},hooks:[]};const t={compute:function(e){const{world:t}=this,n=t.compute;return"string"==typeof e&&n.hasOwnProperty(e)?n[e](this):(e=>"[object Array]"===Object.prototype.toString.call(e))(e)?e.forEach((r=>{t.compute.hasOwnProperty(r)?n[r](this):console.warn("no compute:",e)})):"function"==typeof e?e(this):console.warn("no compute:",e),this}};var n={forEach:function(e){return this.fullPointer.forEach(((t,n)=>{const r=this.update([t]);e(r,n)})),this},map:function(e,t){const n=this.fullPointer.map(((t,n)=>{const r=this.update([t]),o=e(r,n);return void 0===o?this.none():o}));if(0===n.length)return t||this.update([]);if(void 0!==n[0]){if("string"==typeof n[0])return n;if("object"==typeof n[0]&&(null===n[0]||!n[0].isView))return n}let r=[];return n.forEach((e=>{r=r.concat(e.fullPointer)})),this.toView(r)},filter:function(e){let t=this.fullPointer;t=t.filter(((t,n)=>{const r=this.update([t]);return e(r,n)}));return this.update(t)},find:function(e){const t=this.fullPointer.find(((t,n)=>{const r=this.update([t]);return e(r,n)}));return this.update([t])},some:function(e){return this.fullPointer.some(((t,n)=>{const r=this.update([t]);return e(r,n)}))},random:function(e=1){let t=this.fullPointer,n=Math.floor(Math.random()*t.length);return n+e>this.length&&(n=this.length-e,n=n<0?0:n),t=t.slice(n,n+e),this.update(t)}};const r={termList:function(){return this.methods.one.termList(this.docs)},terms:function(e){const t=this.match(".");return"number"==typeof e?t.eq(e):t},groups:function(e){if(e||0===e)return this.update(this._groups[e]||[]);const t={};return Object.keys(this._groups).forEach((e=>{t[e]=this.update(this._groups[e])})),t},eq:function(e){let t=this.pointer;return t||(t=this.docs.map(((e,t)=>[t]))),t[e]?this.update([t[e]]):this.none()},first:function(){return this.eq(0)},last:function(){const e=this.fullPointer.length-1;return this.eq(e)},firstTerms:function(){return this.match("^.")},lastTerms:function(){return this.match(".$")},slice:function(e,t){let n=this.pointer||this.docs.map(((e,t)=>[t]));return n=n.slice(e,t),this.update(n)},all:function(){return this.update().toView()},fullSentences:function(){const e=this.fullPointer.map((e=>[e[0]]));return this.update(e).toView()},none:function(){return this.update([])},isDoc:function(e){if(!e||!e.isView)return!1;const t=this.fullPointer,n=e.fullPointer;return!t.length!==n.length&&t.every(((e,t)=>!!n[t]&&(e[0]===n[t][0]&&e[1]===n[t][1]&&e[2]===n[t][2])))},wordCount:function(){return this.docs.reduce(((e,t)=>(e+=t.filter((e=>""!==e.text)).length,e)),0)},isFull:function(){const e=this.pointer;if(!e)return!0;if(0===e.length||0!==e[0][0])return!1;let t=0,n=0;return this.document.forEach((e=>t+=e.length)),this.docs.forEach((e=>n+=e.length)),t===n},getNth:function(e){return"number"==typeof e?this.eq(e):"string"==typeof e?this.if(e):this}};r.group=r.groups,r.fullSentence=r.fullSentences,r.sentence=r.fullSentences,r.lastTerm=r.lastTerms,r.firstTerm=r.firstTerms;const o=Object.assign({},r,t,n);o.get=o.eq;class View{constructor(t,n,r={}){[["document",t],["world",e],["_groups",r],["_cache",null],["viewType","View"]].forEach((e=>{Object.defineProperty(this,e[0],{value:e[1],writable:!0})})),this.ptrs=n}get docs(){let t=this.document;return this.ptrs&&(t=e.methods.one.getDoc(this.ptrs,this.document)),t}get pointer(){return this.ptrs}get methods(){return this.world.methods}get model(){return this.world.model}get hooks(){return this.world.hooks}get isView(){return!0}get found(){return this.docs.length>0}get length(){return this.docs.length}get fullPointer(){const{docs:e,ptrs:t,document:n}=this,r=t||e.map(((e,t)=>[t]));return r.map((e=>{let[t,r,o,a,i]=e;return r=r||0,o=o||(n[t]||[]).length,n[t]&&n[t][r]&&(a=a||n[t][r].id,n[t][o-1]&&(i=i||n[t][o-1].id)),[t,r,o,a,i]}))}update(e){const t=new View(this.document,e);if(this._cache&&e&&e.length>0){const n=[];e.forEach(((e,t)=>{const[r,o,a]=e;(1===e.length||0===o&&this.document[r].length===a)&&(n[t]=this._cache[r])})),n.length>0&&(t._cache=n)}return t.world=this.world,t}toView(e){return new View(this.document,e||this.pointer)}fromText(e){const{methods:t}=this,n=t.one.tokenize.fromString(e,this.world),r=new View(n);return r.world=this.world,r.compute(["normal","freeze","lexicon"]),this.world.compute.preTagger&&r.compute("preTagger"),r.compute("unfreeze"),r}clone(){let e=this.document.slice(0);e=e.map((e=>e.map((e=>((e=Object.assign({},e)).tags=new Set(e.tags),e)))));const t=this.update(this.pointer);return t.document=e,t._cache=this._cache,t}}Object.assign(View.prototype,o);const a=function(e){return e&&"object"==typeof e&&!Array.isArray(e)};function i(e,t){if(a(t))for(const n in t)a(t[n])?(e[n]||Object.assign(e,{[n]:{}}),i(e[n],t[n])):Object.assign(e,{[n]:t[n]});return e}const s=function(e,t,n,r){if(o=e,"[object Array]"===Object.prototype.toString.call(o))return void e.forEach((e=>s(e,t,n,r)));var o;const{methods:a,model:l,compute:u,hooks:c}=t;e.methods&&function(e,t){for(const n in t)e[n]=e[n]||{},Object.assign(e[n],t[n])}(a,e.methods),e.model&&i(l,e.model),e.irregulars&&function(e,t){const n=e.two.models||{};Object.keys(t).forEach((e=>{t[e].pastTense&&(n.toPast&&(n.toPast.ex[e]=t[e].pastTense),n.fromPast&&(n.fromPast.ex[t[e].pastTense]=e)),t[e].presentTense&&(n.toPresent&&(n.toPresent.ex[e]=t[e].presentTense),n.fromPresent&&(n.fromPresent.ex[t[e].presentTense]=e)),t[e].gerund&&(n.toGerund&&(n.toGerund.ex[e]=t[e].gerund),n.fromGerund&&(n.fromGerund.ex[t[e].gerund]=e)),t[e].comparative&&(n.toComparative&&(n.toComparative.ex[e]=t[e].comparative),n.fromComparative&&(n.fromComparative.ex[t[e].comparative]=e)),t[e].superlative&&(n.toSuperlative&&(n.toSuperlative.ex[e]=t[e].superlative),n.fromSuperlative&&(n.fromSuperlative.ex[t[e].superlative]=e))}))}(l,e.irregulars),e.compute&&Object.assign(u,e.compute),c&&(t.hooks=c.concat(e.hooks||[])),e.api&&e.api(n),e.lib&&Object.keys(e.lib).forEach((t=>r[t]=e.lib[t])),e.tags&&r.addTags(e.tags),e.words&&r.addWords(e.words),e.frozen&&r.addWords(e.frozen,!0),e.mutate&&e.mutate(t,r)},l=function(e){return"[object Array]"===Object.prototype.toString.call(e)},u=function(e,t,n){const{methods:r}=n,o=new t([]);if(o.world=n,"number"==typeof e&&(e=String(e)),!e)return o;if("string"==typeof e){return new t(r.one.tokenize.fromString(e,n))}if(a=e,"[object Object]"===Object.prototype.toString.call(a)&&e.isView)return new t(e.document,e.ptrs);var a;if(l(e)){if(l(e[0])){const n=e.map((e=>e.map((e=>({text:e,normal:e,pre:"",post:" ",tags:new Set})))));return new t(n)}const n=e.map((e=>e.terms.map((e=>(l(e.tags)&&(e.tags=new Set(e.tags)),e)))));return new t(n)}return o},c=Object.assign({},e),h=function(e,t){t&&h.addWords(t);const n=u(e,View,c);return e&&n.compute(c.hooks),n};Object.defineProperty(h,"_world",{value:c,writable:!0}),h.tokenize=function(e,t){const{compute:n}=this._world;t&&h.addWords(t);const r=u(e,View,c);return n.contractions&&r.compute(["alias","normal","machine","contractions"]),r},h.plugin=function(e){return s(e,this._world,View,this),this},h.extend=h.plugin,h.world=function(){return this._world},h.model=function(){return this._world.model},h.methods=function(){return this._world.methods},h.hooks=function(){return this._world.hooks},h.verbose=function(e){const t="undefined"!=typeof process&&process.env?process.env:self.env||{};return t.DEBUG_TAGS="tagger"===e||!0===e||"",t.DEBUG_MATCH="match"===e||!0===e||"",t.DEBUG_CHUNKS="chunker"===e||!0===e||"",this},h.version="14.15.0";var d={one:{cacheDoc:function(e){const t=e.map((e=>{const t=new Set;return e.forEach((e=>{""!==e.normal&&t.add(e.normal),e.switch&&t.add(`%${e.switch}%`),e.implicit&&t.add(e.implicit),e.machine&&t.add(e.machine),e.root&&t.add(e.root),e.alias&&e.alias.forEach((e=>t.add(e)));const n=Array.from(e.tags);for(let e=0;e<n.length;e+=1)t.add("#"+n[e])})),t}));return t}}};const m={cache:function(){return this._cache=this.methods.one.cacheDoc(this.document),this},uncache:function(){return this._cache=null,this}};var p={api:function(e){Object.assign(e.prototype,m)},compute:{cache:function(e){e._cache=e.methods.one.cacheDoc(e.document)}},methods:d};const f=e=>/^\p{Lu}[\p{Ll}'’]/u.test(e)||/^\p{Lu}$/u.test(e),b=(e,t,n)=>{if(n.forEach((e=>e.dirty=!0)),e){const r=[t,0].concat(n);Array.prototype.splice.apply(e,r)}return e},v=function(e){const t=e[e.length-1];!t||/ $/.test(t.post)||/[-–—]/.test(t.post)||(t.post+=" ")},y=(e,t,n)=>{const r=/[-.?!,;:)–—'"]/g,o=e[t-1];if(!o)return;const a=o.post;if(r.test(a)){const e=a.match(r).join(""),t=n[n.length-1];t.post=e+t.post,o.post=o.post.replace(r,"")}},w=function(e,t,n,r){const[o,a,i]=t;0===a||i===r[o].length?v(n):(v(n),v([e[t[1]]])),function(e,t,n){const r=e[t];if(0!==t||!f(r.text))return;n[0].text=n[0].text.replace(/^\p{Ll}/u,(e=>e.toUpperCase()));const o=e[t];o.tags.has("ProperNoun")||o.tags.has("Acronym")||f(o.text)&&o.text.length>1&&(o.text=(a=o.text,a.replace(/^\p{Lu}/u,(e=>e.toLowerCase()))));var a}(e,a,n),b(e,a,n)};let k=0;const P=e=>(e=e.length<3?"0"+e:e).length<3?"0"+e:e,A=function(e){let[t,n]=e.index||[0,0];k+=1,k=k>46655?0:k,t=t>46655?0:t,n=n>1294?0:n;let r=P(k.toString(36));r+=P(t.toString(36));let o=n.toString(36);o=o.length<2?"0"+o:o,r+=o;return r+=parseInt(36*Math.random(),10).toString(36),e.normal+"|"+r.toUpperCase()},C=function(e){if(e.has("@hasContraction")&&"function"==typeof e.contractions){e.grow("@hasContraction").contractions().expand()}},N=e=>"[object Array]"===Object.prototype.toString.call(e),j=function(e,t,n){const{document:r,world:o}=t;t.uncache();const a=t.fullPointer,i=t.fullPointer;t.forEach(((s,l)=>{const u=s.fullPointer[0],[c]=u,h=r[c];let d=function(e,t){const{methods:n}=t;return"string"==typeof e?n.one.tokenize.fromString(e,t)[0]:"object"==typeof e&&e.isView?e.clone().docs[0]||[]:N(e)?N(e[0])?e[0]:e:[]}(e,o);0!==d.length&&(d=function(e){return e.map((e=>(e.id=A(e),e)))}(d),n?(C(t.update([u]).firstTerm()),w(h,u,d,r)):(C(t.update([u]).lastTerm()),function(e,t,n,r){const[o,,a]=t,i=(r[o]||[]).length;a<i?(y(e,a,n),v(n)):i===a&&(v(e),y(e,a,n),r[o+1]&&(n[n.length-1].post+=" ")),b(e,t[2],n),t[4]=n[n.length-1].id}(h,u,d,r)),r[c]&&r[c][u[1]]&&(u[3]=r[c][u[1]].id),i[l]=u,u[2]+=d.length,a[l]=u)}));const s=t.toView(a);return t.ptrs=i,s.compute(["id","index","freeze","lexicon"]),s.world.compute.preTagger&&s.compute("preTagger"),s.compute("unfreeze"),s},x={insertAfter:function(e){return j(e,this,!1)},insertBefore:function(e){return j(e,this,!0)}};x.append=x.insertAfter,x.prepend=x.insertBefore,x.insert=x.insertAfter;const I=/\$[0-9a-z]+/g,T={},D=e=>e.replace(/^\p{Ll}/u,(e=>e.toUpperCase())),H=e=>e.replace(/^\p{Lu}/u,(e=>e.toLowerCase()));T.replaceWith=function(e,t={}){let n=this.fullPointer;const r=this;if(this.uncache(),"function"==typeof e)return function(e,t,n){return e.forEach((e=>{const r=t(e);e.replaceWith(r,n)})),e}(r,e,t);const o=r.docs[0];if(!o)return r;const a=t.possessives&&o[o.length-1].tags.has("Possessive"),i=t.case&&(s=o[0].text,/^\p{Lu}[\p{Ll}'’]/u.test(s)||/^\p{Lu}$/u.test(s));var s;e=function(e,t){if("string"!=typeof e)return e;const n=t.groups();return e=e.replace(I,(e=>{const t=e.replace(/\$/,"");return n.hasOwnProperty(t)?n[t].text():e})),e}(e,r);const l=this.update(n);n=n.map((e=>e.slice(0,3)));const u=(l.docs[0]||[]).map((e=>Array.from(e.tags))),c=l.docs[0][0].pre,h=l.docs[0][l.docs[0].length-1].post;if("string"==typeof e&&(e=this.fromText(e).compute("id")),r.insertAfter(e),l.has("@hasContraction")&&r.contractions){r.grow("@hasContraction+").contractions().expand()}if(r.delete(l),a){const e=r.docs[0],t=e[e.length-1];t.tags.has("Possessive")||(t.text+="'s",t.normal+="'s",t.tags.add("Possessive"))}if(c&&r.docs[0]&&(r.docs[0][0].pre=c),h&&r.docs[0]){const e=r.docs[0][r.docs[0].length-1];e.post.trim()||(e.post=h)}const d=r.toView(n).compute(["index","freeze","lexicon"]);if(d.world.compute.preTagger&&d.compute("preTagger"),d.compute("unfreeze"),t.tags&&d.terms().forEach(((e,t)=>{e.tagSafe(u[t])})),!d.docs[0]||!d.docs[0][0])return d;if(t.case){const e=i?D:H;d.docs[0][0].text=e(d.docs[0][0].text)}return d},T.replace=function(e,t,n){if(e&&!t)return this.replaceWith(e,n);const r=this.match(e);return r.found?(this.soften(),r.replaceWith(t,n)):this};const E={remove:function(e){const{indexN:t}=this.methods.one.pointer;this.uncache();let n=this.all(),r=this;e&&(n=this,r=this.match(e));const o=!n.ptrs;if(r.has("@hasContraction")&&r.contractions){r.grow("@hasContraction").contractions().expand()}let a=n.fullPointer;const i=r.fullPointer.reverse(),s=function(e,t){t.forEach((t=>{const[n,r,o]=t,a=o-r;e[n]&&(o===e[n].length&&o>1&&function(e,t){const n=e.length-1,r=e[n],o=e[n-t];o&&r&&(o.post+=r.post,o.post=o.post.replace(/ +([.?!,;:])/,"$1"),o.post=o.post.replace(/[,;:]+([.?!])/,"$1"))}(e[n],a),e[n].splice(r,a))}));for(let t=e.length-1;t>=0;t-=1)if(0===e[t].length&&(e.splice(t,1),t===e.length&&e[t-1])){const n=e[t-1],r=n[n.length-1];r&&(r.post=r.post.trimEnd())}return e}(this.document,i);if(a=function(e,t){return e=e.map((e=>{const[n]=e;return t[n]?(t[n].forEach((t=>{const n=t[2]-t[1];e[1]<=t[1]&&e[2]>=t[2]&&(e[2]-=n)})),e):e})),e.forEach(((t,n)=>{if(0===t[1]&&0==t[2])for(let t=n+1;t<e.length;t+=1)e[t][0]-=1,e[t][0]<0&&(e[t][0]=0)})),e=(e=e.filter((e=>e[2]-e[1]>0))).map((e=>(e[3]=null,e[4]=null,e)))}(a,t(i)),n.ptrs=a,n.document=s,n.compute("index"),o&&(n.ptrs=void 0),!e)return this.ptrs=[],n.none();return n.toView(a)}};E.delete=E.remove;const G={pre:function(e,t){return void 0===e&&this.found?this.docs[0][0].pre:(this.docs.forEach((n=>{const r=n[0];!0===t?r.pre+=e:r.pre=e})),this)},post:function(e,t){if(void 0===e){const e=this.docs[this.docs.length-1];return e[e.length-1].post}return this.docs.forEach((n=>{const r=n[n.length-1];!0===t?r.post+=e:r.post=e})),this},trim:function(){if(!this.found)return this;const e=this.docs,t=e[0][0];t.pre=t.pre.trimStart();const n=e[e.length-1],r=n[n.length-1];return r.post=r.post.trimEnd(),this},hyphenate:function(){return this.docs.forEach((e=>{e.forEach(((t,n)=>{0!==n&&(t.pre=""),e[n+1]&&(t.post="-")}))})),this},dehyphenate:function(){const e=/[-–—]/;return this.docs.forEach((t=>{t.forEach((t=>{e.test(t.post)&&(t.post=" ")}))})),this},toQuotations:function(e,t){return e=e||'"',t=t||'"',this.docs.forEach((n=>{n[0].pre=e+n[0].pre;const r=n[n.length-1];r.post=t+r.post})),this},toParentheses:function(e,t){return e=e||"(",t=t||")",this.docs.forEach((n=>{n[0].pre=e+n[0].pre;const r=n[n.length-1];r.post=t+r.post})),this}};G.deHyphenate=G.dehyphenate,G.toQuotation=G.toQuotations;var O={alpha:(e,t)=>e.normal<t.normal?-1:e.normal>t.normal?1:0,length:(e,t)=>{const n=e.normal.trim().length,r=t.normal.trim().length;return n<r?1:n>r?-1:0},wordCount:(e,t)=>e.words<t.words?1:e.words>t.words?-1:0,sequential:(e,t)=>e[0]<t[0]?1:e[0]>t[0]?-1:e[1]>t[1]?1:-1,byFreq:function(e){const t={};return e.forEach((e=>{t[e.normal]=t[e.normal]||0,t[e.normal]+=1})),e.sort(((e,n)=>{const r=t[e.normal],o=t[n.normal];return r<o?1:r>o?-1:0})),e}};const F=new Set(["index","sequence","seq","sequential","chron","chronological"]),V=new Set(["freq","frequency","topk","repeats"]),z=new Set(["alpha","alphabetical"]);var B={unique:function(){const e=new Set,t=this.filter((t=>{const n=t.text("machine");return!e.has(n)&&(e.add(n),!0)}));return t},reverse:function(){let e=this.pointer||this.docs.map(((e,t)=>[t]));return e=[].concat(e),e=e.reverse(),this._cache&&(this._cache=this._cache.reverse()),this.update(e)},sort:function(e){const{docs:t,pointer:n}=this;if(this.uncache(),"function"==typeof e)return function(e,t){let n=e.fullPointer;return n=n.sort(((n,r)=>(n=e.update([n]),r=e.update([r]),t(n,r)))),e.ptrs=n,e}(this,e);e=e||"alpha";const r=n||t.map(((e,t)=>[t]));let o=t.map(((e,t)=>({index:t,words:e.length,normal:e.map((e=>e.machine||e.normal||"")).join(" "),pointer:r[t]})));return F.has(e)&&(e="sequential"),z.has(e)&&(e="alpha"),V.has(e)?(o=O.byFreq(o),this.update(o.map((e=>e.pointer)))):"function"==typeof O[e]?(o=o.sort(O[e]),this.update(o.map((e=>e.pointer)))):this}};const S=function(e,t){if(e.length>0){const t=e[e.length-1],n=t[t.length-1];!1===/ /.test(n.post)&&(n.post+=" ")}return e=e.concat(t)};var $={concat:function(e){if("string"==typeof e){const t=this.fromText(e);if(this.found&&this.ptrs){const e=this.fullPointer,n=e[e.length-1][0];this.document.splice(n,0,...t.document)}else this.document=this.document.concat(t.document);return this.all().compute("index")}if("object"==typeof e&&e.isView)return function(e,t){if(e.document===t.document){const n=e.fullPointer.concat(t.fullPointer);return e.toView(n).compute("index")}return t.fullPointer.forEach((t=>{t[0]+=e.document.length})),e.document=S(e.document,t.docs),e.all()}(this,e);if(t=e,"[object Array]"===Object.prototype.toString.call(t)){const t=S(this.document,e);return this.document=t,this.all()}var t;return this}};var M={harden:function(){return this.ptrs=this.fullPointer,this},soften:function(){let e=this.ptrs;return!e||e.length<1||(e=e.map((e=>e.slice(0,3))),this.ptrs=e),this}};const L=Object.assign({},{toLowerCase:function(){return this.termList().forEach((e=>{e.text=e.text.toLowerCase()})),this},toUpperCase:function(){return this.termList().forEach((e=>{e.text=e.text.toUpperCase()})),this},toTitleCase:function(){return this.termList().forEach((e=>{e.text=e.text.replace(/^ *[a-z\u00C0-\u00FF]/,(e=>e.toUpperCase()))})),this},toCamelCase:function(){return this.docs.forEach((e=>{e.forEach(((t,n)=>{0!==n&&(t.text=t.text.replace(/^ *[a-z\u00C0-\u00FF]/,(e=>e.toUpperCase()))),n!==e.length-1&&(t.post="")}))})),this}},x,T,E,G,B,$,M),K={id:function(e){const t=e.docs;for(let e=0;e<t.length;e+=1)for(let n=0;n<t[e].length;n+=1){const r=t[e][n];r.id=r.id||A(r)}}};var J={api:function(e){Object.assign(e.prototype,L)},compute:K};const W=!0;var q={one:{contractions:[{word:"@",out:["at"]},{word:"arent",out:["are","not"]},{word:"alot",out:["a","lot"]},{word:"brb",out:["be","right","back"]},{word:"cannot",out:["can","not"]},{word:"dun",out:["do","not"]},{word:"can't",out:["can","not"]},{word:"shan't",out:["should","not"]},{word:"won't",out:["will","not"]},{word:"that's",out:["that","is"]},{word:"what's",out:["what","is"]},{word:"let's",out:["let","us"]},{word:"dunno",out:["do","not","know"]},{word:"gonna",out:["going","to"]},{word:"gotta",out:["have","got","to"]},{word:"gimme",out:["give","me"]},{word:"outta",out:["out","of"]},{word:"tryna",out:["trying","to"]},{word:"gtg",out:["got","to","go"]},{word:"im",out:["i","am"]},{word:"imma",out:["I","will"]},{word:"imo",out:["in","my","opinion"]},{word:"irl",out:["in","real","life"]},{word:"ive",out:["i","have"]},{word:"rn",out:["right","now"]},{word:"tbh",out:["to","be","honest"]},{word:"wanna",out:["want","to"]},{word:"c'mere",out:["come","here"]},{word:"c'mon",out:["come","on"]},{word:"shoulda",out:["should","have"]},{word:"coulda",out:["coulda","have"]},{word:"woulda",out:["woulda","have"]},{word:"musta",out:["must","have"]},{word:"tis",out:["it","is"]},{word:"twas",out:["it","was"]},{word:"y'know",out:["you","know"]},{word:"ne'er",out:["never"]},{word:"o'er",out:["over"]},{after:"ll",out:["will"]},{after:"ve",out:["have"]},{after:"re",out:["are"]},{after:"m",out:["am"]},{before:"c",out:["ce"]},{before:"m",out:["me"]},{before:"n",out:["ne"]},{before:"qu",out:["que"]},{before:"s",out:["se"]},{before:"t",out:["tu"]},{word:"shouldnt",out:["should","not"]},{word:"couldnt",out:["could","not"]},{word:"wouldnt",out:["would","not"]},{word:"hasnt",out:["has","not"]},{word:"wasnt",out:["was","not"]},{word:"isnt",out:["is","not"]},{word:"cant",out:["can","not"]},{word:"dont",out:["do","not"]},{word:"wont",out:["will","not"]},{word:"howd",out:["how","did"]},{word:"whatd",out:["what","did"]},{word:"whend",out:["when","did"]},{word:"whered",out:["where","did"]}],numberSuffixes:{st:W,nd:W,rd:W,th:W,am:W,pm:W,max:W,"°":W,s:W,e:W,er:W,"ère":W,"ème":W}}};const U=function(e,t,n){const[r,o]=t;n&&0!==n.length&&(n=n.map(((e,t)=>(e.implicit=e.text,e.machine=e.text,e.pre="",e.post="",e.text="",e.normal="",e.index=[r,o+t],e))),n[0]&&(n[0].pre=e[r][o].pre,n[n.length-1].post=e[r][o].post,n[0].text=e[r][o].text,n[0].normal=e[r][o].normal),e[r].splice(o,1,...n))},R=/'/,Q=new Set(["what","how","when","where","why"]),Z=new Set(["be","go","start","think","need"]),_=new Set(["been","gone"]),X=/'/,Y=/(e|é|aison|sion|tion)$/,ee=/(age|isme|acle|ege|oire)$/;var te=(e,t)=>["je",e[t].normal.split(X)[1]],ne=(e,t)=>{const n=e[t].normal.split(X)[1];return n&&n.endsWith("e")?["la",n]:["le",n]},re=(e,t)=>{const n=e[t].normal.split(X)[1];return n&&Y.test(n)&&!ee.test(n)?["du",n]:n&&n.endsWith("s")?["des",n]:["de",n]};const oe=/^([0-9.]{1,4}[a-z]{0,2}) ?[-–—] ?([0-9]{1,4}[a-z]{0,2})$/i,ae=/^([0-9]{1,2}(:[0-9][0-9])?(am|pm)?) ?[-–—] ?([0-9]{1,2}(:[0-9][0-9])?(am|pm)?)$/i,ie=/^[0-9]{3}-[0-9]{4}$/,se=function(e,t){const n=e[t];let r=n.text.match(oe);return null!==r?!0===n.tags.has("PhoneNumber")||ie.test(n.text)?null:[r[1],"to",r[2]]:(r=n.text.match(ae),null!==r?[r[1],"to",r[4]]:null)},le=/^([+-]?[0-9][.,0-9]*)([a-z°²³µ/]+)$/,ue=function(e,t,n){const r=n.model.one.numberSuffixes||{},o=e[t].text.match(le);if(null!==o){const e=o[2].toLowerCase().trim();return r.hasOwnProperty(e)?null:[o[1],e]}return null},ce=/'/,he=/^[0-9][^-–—]*[-–—].*?[0-9]/,de=function(e,t,n,r){const o=t.update();o.document=[e];let a=n+r;n>0&&(n-=1),e[a]&&(a+=1),o.ptrs=[[0,n,a]]},ge={t:(e,t)=>function(e,t){return"ain't"===e[t].normal||"aint"===e[t].normal?null:[e[t].normal.replace(/n't/,""),"not"]}(e,t),d:(e,t)=>function(e,t){const n=e[t].normal.split(R)[0];if(Q.has(n))return[n,"did"];if(e[t+1]){if(_.has(e[t+1].normal))return[n,"had"];if(Z.has(e[t+1].normal))return[n,"would"]}return null}(e,t)},me={j:(e,t)=>te(e,t),l:(e,t)=>ne(e,t),d:(e,t)=>re(e,t)},pe=function(e,t,n,r){for(let o=0;o<e.length;o+=1){const a=e[o];if(a.word===t.normal)return a.out;if(null!==r&&r===a.after)return[n].concat(a.out);if(null!==n&&n===a.before&&r&&r.length>2)return a.out.concat(r)}return null},fe=function(e,t){const n=t.fromText(e.join(" "));return n.compute(["id","alias"]),n.docs[0]},be=function(e,t){for(let n=t+1;n<5&&e[n];n+=1)if("been"===e[n].normal)return["there","has"];return["there","is"]};var ve={contractions:e=>{const{world:t,document:n}=e,{model:r,methods:o}=t,a=r.one.contractions||[];n.forEach(((r,i)=>{for(let s=r.length-1;s>=0;s-=1){let l=null,u=null;if(!0===ce.test(r[s].normal)){const e=r[s].normal.split(ce);l=e[0],u=e[1]}let c=pe(a,r[s],l,u);!c&&ge.hasOwnProperty(u)&&(c=ge[u](r,s,t)),!c&&me.hasOwnProperty(l)&&(c=me[l](r,s)),"there"===l&&"s"===u&&(c=be(r,s)),c?(c=fe(c,e),U(n,[i,s],c),de(n[i],e,s,c.length)):he.test(r[s].normal)?(c=se(r,s),c&&(c=fe(c,e),U(n,[i,s],c),o.one.setTag(c,"NumberRange",t),c[2]&&c[2].tags.has("Time")&&o.one.setTag([c[0]],"Time",t,null,"time-range"),de(n[i],e,s,c.length))):(c=ue(r,s,t),c&&(c=fe(c,e),U(n,[i,s],c),o.one.setTag([c[1]],"Unit",t,null,"contraction-unit")))}}))}};const ye={model:q,compute:ve,hooks:["contractions"]},we=function(e){const t=e.world,{model:n,methods:r}=e.world,o=r.one.setTag,{frozenLex:a}=n.one,i=n.one._multiCache||{};e.docs.forEach((e=>{for(let n=0;n<e.length;n+=1){const r=e[n],s=r.machine||r.normal;if(void 0!==i[s]&&e[n+1]){for(let r=n+i[s]-1;r>n;r-=1){const i=e.slice(n,r+1),s=i.map((e=>e.machine||e.normal)).join(" ");!0!==a.hasOwnProperty(s)||(o(i,a[s],t,!1,"1-frozen-multi-lexicon"),i.forEach((e=>e.frozen=!0)))}}void 0!==a[s]&&a.hasOwnProperty(s)&&(o([r],a[s],t,!1,"1-freeze-lexicon"),r.frozen=!0)}}))};const ke=e=>""+e+"",Pe=e=>""+e+"",Ae=function(e){e.docs.forEach((e=>{console.log(ke("\n ┌─────────")),e.forEach((e=>{let t=` ${Pe("│")} `;const n=e.implicit||e.text||"-";!0===e.frozen?t+=`${ke(n)} ❄️`:t+=Pe(n),console.log(t)}))}))};var Ce={compute:{frozen:we,freeze:we,unfreeze:function(e){return e.docs.forEach((e=>{e.forEach((e=>{delete e.frozen}))})),e}},mutate:e=>{const t=e.methods.one;t.termMethods.isFrozen=e=>!0===e.frozen,t.debug.freeze=Ae,t.debug.frozen=Ae},api:function(e){e.prototype.freeze=function(){return this.docs.forEach((e=>{e.forEach((e=>{e.frozen=!0}))})),this},e.prototype.unfreeze=function(){this.compute("unfreeze")},e.prototype.isFrozen=function(){return this.match("@isFrozen+")}},hooks:["freeze"]};const Ne=function(e,t,n){const{model:r,methods:o}=n,a=o.one.setTag,i=r.one._multiCache||{},{lexicon:s}=r.one||{},l=e[t],u=l.machine||l.normal;if(void 0!==i[u]&&e[t+1]){for(let r=t+i[u]-1;r>t;r-=1){const o=e.slice(t,r+1);if(o.length<=1)return!1;const i=o.map((e=>e.machine||e.normal)).join(" ");if(!0===s.hasOwnProperty(i)){const e=s[i];return a(o,e,n,!1,"1-multi-lexicon"),!e||2!==e.length||"PhrasalVerb"!==e[0]&&"PhrasalVerb"!==e[1]||a([o[1]],"Particle",n,!1,"1-phrasal-particle"),!0}}return!1}return null},je=/^(under|over|mis|re|un|dis|semi|pre|post)-?/,xe=new Set(["Verb","Infinitive","PastTense","Gerund","PresentTense","Adjective","Participle"]),Ie=function(e,t,n){const{model:r,methods:o}=n,a=o.one.setTag,{lexicon:i}=r.one,s=e[t],l=s.machine||s.normal;if(void 0!==i[l]&&i.hasOwnProperty(l))return a([s],i[l],n,!1,"1-lexicon"),!0;if(s.alias){const e=s.alias.find((e=>i.hasOwnProperty(e)));if(e)return a([s],i[e],n,!1,"1-lexicon-alias"),!0}if(!0===je.test(l)){const e=l.replace(je,"");if(i.hasOwnProperty(e)&&e.length>3&&xe.has(i[e]))return a([s],i[e],n,!1,"1-lexicon-prefix"),!0}return null};var Te={lexicon:function(e){const t=e.world;e.docs.forEach((e=>{for(let n=0;n<e.length;n+=1)if(0===e[n].tags.size){let r=null;r=r||Ne(e,n,t),r=r||Ie(e,n,t)}}))}};var De={one:{expandLexicon:function(e){const t={},n={};return Object.keys(e).forEach((r=>{const o=e[r],a=(r=(r=r.toLowerCase().trim()).replace(/'s\b/,"")).split(/ /);a.length>1&&(void 0===n[a[0]]||a.length>n[a[0]])&&(n[a[0]]=a.length),t[r]=t[r]||o})),delete t[""],delete t.null,delete t[" "],{lex:t,_multi:n}}}};var He={addWords:function(e,t=!1){const n=this.world(),{methods:r,model:o}=n;if(!e)return;if(Object.keys(e).forEach((t=>{"string"==typeof e[t]&&e[t].startsWith("#")&&(e[t]=e[t].replace(/^#/,""))})),!0===t){const{lex:t,_multi:a}=r.one.expandLexicon(e,n);return Object.assign(o.one._multiCache,a),void Object.assign(o.one.frozenLex,t)}if(r.two.expandLexicon){const{lex:t,_multi:a}=r.two.expandLexicon(e,n);Object.assign(o.one.lexicon,t),Object.assign(o.one._multiCache,a)}const{lex:a,_multi:i}=r.one.expandLexicon(e,n);Object.assign(o.one.lexicon,a),Object.assign(o.one._multiCache,i)}};var Ee={model:{one:{lexicon:{},_multiCache:{},frozenLex:{}}},methods:De,compute:Te,lib:He,hooks:["lexicon"]};const Ge=function(e,t){const n=[{}],r=[null],o=[0],a=[];let i=0;e.forEach((function(e){let o=0;const a=function(e,t){const{methods:n,model:r}=t,o=n.one.tokenize.splitTerms(e,r).map((e=>n.one.tokenize.splitWhitespace(e,r)));return o.map((e=>e.text.toLowerCase()))}(e,t);for(let e=0;e<a.length;e++){const t=a[e];n[o]&&n[o].hasOwnProperty(t)?o=n[o][t]:(i++,n[o][t]=i,n[i]={},o=i,r[i]=null)}r[o]=[a.length]}));for(const e in n[0])i=n[0][e],o[i]=0,a.push(i);for(;a.length;){const e=a.shift(),t=Object.keys(n[e]);for(let s=0;s<t.length;s+=1){const l=t[s],u=n[e][l];for(a.push(u),i=o[e];i>0&&!n[i].hasOwnProperty(l);)i=o[i];if(n.hasOwnProperty(i)){const e=n[i][l];o[u]=e,r[e]&&(r[u]=r[u]||[],r[u]=r[u].concat(r[e]))}else o[u]=0}}return{goNext:n,endAs:r,failTo:o}},Oe=function(e,t,n){let r=0;const o=[];for(let a=0;a<e.length;a++){const i=e[a][n.form]||e[a].normal;for(;r>0&&(void 0===t.goNext[r]||!t.goNext[r].hasOwnProperty(i));)r=t.failTo[r]||0;if(t.goNext[r].hasOwnProperty(i)&&(r=t.goNext[r][i],t.endAs[r])){const n=t.endAs[r];for(let t=0;t<n.length;t++){const r=n[t],i=e[a-r+1],[s,l]=i.index;o.push([s,l,l+r,i.id])}}}return o},Fe=function(e,t){for(let n=0;n<e.length;n+=1)if(!0===t.has(e[n]))return!1;return!0};const Ve=(e,t)=>{for(let n=e.length-1;n>=0;n-=1)if(e[n]!==t)return e=e.slice(0,n+1);return e},ze={buildTrie:function(e){return function(e){return e.goNext=e.goNext.map((e=>{if(0!==Object.keys(e).length)return e})),e.goNext=Ve(e.goNext,void 0),e.failTo=Ve(e.failTo,0),e.endAs=Ve(e.endAs,null),e}(Ge(e,this.world()))}};ze.compile=ze.buildTrie;var Be={api:function(e){e.prototype.lookup=function(e,t={}){if(!e)return this.none();"string"==typeof e&&(e=[e]);var n;let r=function(e,t,n){let r=[];n.form=n.form||"normal";const o=e.docs;if(!t.goNext||!t.goNext[0])return console.error("Compromise invalid lookup trie"),e.none();const a=Object.keys(t.goNext[0]);for(let i=0;i<o.length;i++){if(e._cache&&e._cache[i]&&!0===Fe(a,e._cache[i]))continue;const s=o[i],l=Oe(s,t,n);l.length>0&&(r=r.concat(l))}return e.update(r)}(this,(n=e,"[object Object]"===Object.prototype.toString.call(n)?e:Ge(e,this.world)),t);return r=r.settle(),r}},lib:ze};const Se=function(e,t){return t?(e.forEach((e=>{const n=e[0];t[n]&&(e[0]=t[n][0],e[1]+=t[n][1],e[2]+=t[n][1])})),e):e},$e=function(e,t){let{ptrs:n}=e;const{byGroup:r}=e;return n=Se(n,t),Object.keys(r).forEach((e=>{r[e]=Se(r[e],t)})),{ptrs:n,byGroup:r}},Me=function(e,t,n){const r=n.methods.one;return"number"==typeof e&&(e=String(e)),"string"==typeof e&&(e=r.killUnicode(e,n),e=r.parseMatch(e,t,n)),e},Le=e=>"[object Object]"===Object.prototype.toString.call(e),Ke=e=>e&&Le(e)&&!0===e.isView,Je=e=>e&&Le(e)&&!0===e.isNet;var We={matchOne:function(e,t,n){const r=this.methods.one;if(Ke(e))return this.intersection(e).eq(0);if(Je(e))return this.sweep(e,{tagger:!1,matchOne:!0}).view;const o={regs:e=Me(e,n,this.world),group:t,justOne:!0},a=r.match(this.docs,o,this._cache),{ptrs:i,byGroup:s}=$e(a,this.fullPointer),l=this.toView(i);return l._groups=s,l},match:function(e,t,n){const r=this.methods.one;if(Ke(e))return this.intersection(e);if(Je(e))return this.sweep(e,{tagger:!1}).view.settle();const o={regs:e=Me(e,n,this.world),group:t},a=r.match(this.docs,o,this._cache),{ptrs:i,byGroup:s}=$e(a,this.fullPointer),l=this.toView(i);return l._groups=s,l},has:function(e,t,n){const r=this.methods.one;if(Ke(e)){return this.intersection(e).fullPointer.length>0}if(Je(e))return this.sweep(e,{tagger:!1}).view.found;const o={regs:e=Me(e,n,this.world),group:t,justOne:!0};return r.match(this.docs,o,this._cache).ptrs.length>0},if:function(e,t,n){const r=this.methods.one;if(Ke(e))return this.filter((t=>t.intersection(e).found));if(Je(e)){const t=this.sweep(e,{tagger:!1}).view.settle();return this.if(t)}const o={regs:e=Me(e,n,this.world),group:t,justOne:!0};let a=this.fullPointer;const i=this._cache||[];a=a.filter(((e,t)=>{const n=this.update([e]);return r.match(n.docs,o,i[t]).ptrs.length>0}));const s=this.update(a);return this._cache&&(s._cache=a.map((e=>i[e[0]]))),s},ifNo:function(e,t,n){const{methods:r}=this,o=r.one;if(Ke(e))return this.filter((t=>!t.intersection(e).found));if(Je(e)){const t=this.sweep(e,{tagger:!1}).view.settle();return this.ifNo(t)}e=Me(e,n,this.world);const a=this._cache||[],i=this.filter(((n,r)=>{const i={regs:e,group:t,justOne:!0};return 0===o.match(n.docs,i,a[r]).ptrs.length}));return this._cache&&(i._cache=i.ptrs.map((e=>a[e[0]]))),i}};var qe={before:function(e,t,n){const{indexN:r}=this.methods.one.pointer,o=[],a=r(this.fullPointer);Object.keys(a).forEach((e=>{const t=a[e].sort(((e,t)=>e[1]>t[1]?1:-1))[0];t[1]>0&&o.push([t[0],0,t[1]])}));const i=this.toView(o);return e?i.match(e,t,n):i},after:function(e,t,n){const{indexN:r}=this.methods.one.pointer,o=[],a=r(this.fullPointer),i=this.document;Object.keys(a).forEach((e=>{const t=a[e].sort(((e,t)=>e[1]>t[1]?-1:1))[0],[n,,r]=t;r<i[n].length&&o.push([n,r,i[n].length])}));const s=this.toView(o);return e?s.match(e,t,n):s},growLeft:function(e,t,n){"string"==typeof e&&(e=this.world.methods.one.parseMatch(e,n,this.world)),e[e.length-1].end=!0;const r=this.fullPointer;return this.forEach(((n,o)=>{const a=n.before(e,t);if(a.found){const e=a.terms();r[o][1]-=e.length,r[o][3]=e.docs[0][0].id}})),this.update(r)},growRight:function(e,t,n){"string"==typeof e&&(e=this.world.methods.one.parseMatch(e,n,this.world)),e[0].start=!0;const r=this.fullPointer;return this.forEach(((n,o)=>{const a=n.after(e,t);if(a.found){const e=a.terms();r[o][2]+=e.length,r[o][4]=null}})),this.update(r)},grow:function(e,t,n){return this.growRight(e,t,n).growLeft(e,t,n)}};const Ue=function(e,t){return[e[0],e[1],t[2]]},Re=(e,t,n)=>{return"string"==typeof e||(r=e,"[object Array]"===Object.prototype.toString.call(r))?t.match(e,n):e||t.none();var r},Qe=function(e,t){const[n,r,o]=e;return t.document[n]&&t.document[n][r]&&(e[3]=e[3]||t.document[n][r].id,t.document[n][o-1]&&(e[4]=e[4]||t.document[n][o-1].id)),e},Ze={splitOn:function(e,t){const{splitAll:n}=this.methods.one.pointer,r=Re(e,this,t).fullPointer,o=n(this.fullPointer,r);let a=[];return o.forEach((e=>{a.push(e.passthrough),a.push(e.before),a.push(e.match),a.push(e.after)})),a=a.filter((e=>e)),a=a.map((e=>Qe(e,this))),this.update(a)},splitBefore:function(e,t){const{splitAll:n}=this.methods.one.pointer,r=Re(e,this,t).fullPointer,o=n(this.fullPointer,r);for(let e=0;e<o.length;e+=1)!o[e].after&&o[e+1]&&o[e+1].before&&o[e].match&&o[e].match[0]===o[e+1].before[0]&&(o[e].after=o[e+1].before,delete o[e+1].before);let a=[];return o.forEach((e=>{a.push(e.passthrough),a.push(e.before),e.match&&e.after?a.push(Ue(e.match,e.after)):a.push(e.match)})),a=a.filter((e=>e)),a=a.map((e=>Qe(e,this))),this.update(a)},splitAfter:function(e,t){const{splitAll:n}=this.methods.one.pointer,r=Re(e,this,t).fullPointer,o=n(this.fullPointer,r);let a=[];return o.forEach((e=>{a.push(e.passthrough),e.before&&e.match?a.push(Ue(e.before,e.match)):(a.push(e.before),a.push(e.match)),a.push(e.after)})),a=a.filter((e=>e)),a=a.map((e=>Qe(e,this))),this.update(a)}};Ze.split=Ze.splitAfter;const _e=function(e,t){return!(!e||!t)&&(e[0]===t[0]&&e[2]===t[1])},Xe=function(e,t,n){const r=e.world,o=r.methods.one.parseMatch;n=n||"^.";const a=o(t=t||".$",{},r),i=o(n,{},r);a[a.length-1].end=!0,i[0].start=!0;const s=e.fullPointer,l=[s[0]];for(let t=1;t<s.length;t+=1){const n=l[l.length-1],r=s[t],o=e.update([n]),u=e.update([r]);_e(n,r)&&o.has(a)&&u.has(i)?l[l.length-1]=[n[0],n[1],r[2],n[3],r[4]]:l.push(r)}return e.update(l)},Ye={joinIf:function(e,t){return Xe(this,e,t)},join:function(){return Xe(this)}},et=Object.assign({},We,qe,Ze,Ye);et.lookBehind=et.before,et.lookBefore=et.before,et.lookAhead=et.after,et.lookAfter=et.after,et.notIf=et.ifNo;const tt=/(?:^|\s)([![^]*(?:<[^<]*>)?\/.*?[^\\/]\/[?\]+*$~]*)(?:\s|$)/,nt=/([!~[^]*(?:<[^<]*>)?\([^)]+[^\\)]\)[?\]+*$~]*)(?:\s|$)/,rt=/ /g,ot=e=>/^[![^]*(<[^<]*>)?\//.test(e)&&/\/[?\]+*$~]*$/.test(e),at=function(e){return e=(e=e.map((e=>e.trim()))).filter((e=>e))},it=/\{([0-9]+)?(, *[0-9]*)?\}/,st=/&&/,lt=new RegExp(/^<\s*(\S+)\s*>/),ut=e=>e.charAt(0).toUpperCase()+e.substring(1),ct=e=>e.charAt(e.length-1),ht=e=>e.charAt(0),dt=e=>e.substring(1),gt=e=>e.substring(0,e.length-1),mt=function(e){return e=dt(e),e=gt(e)},pt=function(e,t){const n={};for(let r=0;r<2;r+=1){if("$"===ct(e)&&(n.end=!0,e=gt(e)),"^"===ht(e)&&(n.start=!0,e=dt(e)),"?"===ct(e)&&(n.optional=!0,e=gt(e)),("["===ht(e)||"]"===ct(e))&&(n.group=null,"["===ht(e)&&(n.groupStart=!0),"]"===ct(e)&&(n.groupEnd=!0),e=(e=e.replace(/^\[/,"")).replace(/\]$/,""),"<"===ht(e))){const t=lt.exec(e);t.length>=2&&(n.group=t[1],e=e.replace(t[0],""))}if("+"===ct(e)&&(n.greedy=!0,e=gt(e)),"*"!==e&&"*"===ct(e)&&"\\*"!==e&&(n.greedy=!0,e=gt(e)),"!"===ht(e)&&(n.negative=!0,e=dt(e)),"~"===ht(e)&&"~"===ct(e)&&e.length>2&&(e=mt(e),n.fuzzy=!0,n.min=t.fuzzy||.85,!1===/\(/.test(e)))return n.word=e,n;if("/"===ht(e)&&"/"===ct(e))return e=mt(e),t.caseSensitive&&(n.use="text"),n.regex=new RegExp(e),n;if(!0===it.test(e)&&(e=e.replace(it,((e,t,r)=>(void 0===r?(n.min=Number(t),n.max=Number(t)):(r=r.replace(/, */,""),void 0===t?(n.min=0,n.max=Number(r)):(n.min=Number(t),n.max=Number(r||999))),n.greedy=!0,n.min||(n.optional=!0),"")))),"("===ht(e)&&")"===ct(e)){st.test(e)?(n.choices=e.split(st),n.operator="and"):(n.choices=e.split("|"),n.operator="or"),n.choices[0]=dt(n.choices[0]);const r=n.choices.length-1;n.choices[r]=gt(n.choices[r]),n.choices=n.choices.map((e=>e.trim())),n.choices=n.choices.filter((e=>e)),n.choices=n.choices.map((e=>e.split(/ /g).map((e=>pt(e,t))))),e=""}if("{"===ht(e)&&"}"===ct(e)){if(e=mt(e),n.root=e,/\//.test(e)){const e=n.root.split(/\//);n.root=e[0],n.pos=e[1],"adj"===n.pos&&(n.pos="Adjective"),n.pos=n.pos.charAt(0).toUpperCase()+n.pos.substr(1).toLowerCase(),void 0!==e[2]&&(n.sense=e[2])}return n}if("<"===ht(e)&&">"===ct(e))return e=mt(e),n.chunk=ut(e),n.greedy=!0,n;if("%"===ht(e)&&"%"===ct(e))return e=mt(e),n.switch=e,n}return"#"===ht(e)?(n.tag=dt(e),n.tag=ut(n.tag),n):"@"===ht(e)?(n.method=dt(e),n):"."===e?(n.anything=!0,n):"*"===e?(n.anything=!0,n.greedy=!0,n.optional=!0,n):(e&&(e=(e=e.replace("\\*","*")).replace("\\.","."),t.caseSensitive?n.use="text":e=e.toLowerCase(),n.word=e),n)},ft=/[a-z0-9][-–—][a-z]/i,bt=function(e,t){const{all:n}=t.methods.two.transform.verb||{},r=e.root;return n?n(r,t.model):[]},vt=function(e,t){const{all:n}=t.methods.two.transform.noun||{};return n?n(e.root,t.model):[e.root]},yt=function(e,t){const{all:n}=t.methods.two.transform.adjective||{};return n?n(e.root,t.model):[e.root]},wt=function(e){return e=function(e){let t=0,n=null;for(let r=0;r<e.length;r++){const o=e[r];!0===o.groupStart&&(n=o.group,null===n&&(n=String(t),t+=1)),null!==n&&(o.group=n),!0===o.groupEnd&&(n=null)}return e}(e),e=function(e){return e.map((e=>(e.fuzzy&&e.choices&&e.choices.forEach((t=>{1===t.length&&t[0].word&&(t[0].fuzzy=!0,t[0].min=e.min)})),e)))}(e=e.map((e=>{if(void 0!==e.choices){if("or"!==e.operator)return e;if(!0===e.fuzzy)return e;!0===e.choices.every((e=>{if(1!==e.length)return!1;const t=e[0];return!0!==t.fuzzy&&!t.start&&!t.end&&void 0!==t.word&&!0!==t.negative&&!0!==t.optional&&!0!==t.method}))&&(e.fastOr=new Set,e.choices.forEach((t=>{e.fastOr.add(t[0].word)})),delete e.choices)}return e}))),e},kt=function(e,t){for(const n of t)if(e.has(n))return!0;return!1},Pt=function(e,t){for(let n=0;n<e.length;n+=1){const r=e[n];if(!0!==r.optional&&!0!==r.negative&&!0!==r.fuzzy){if(void 0!==r.word&&!1===t.has(r.word))return!0;if(void 0!==r.tag&&!1===t.has("#"+r.tag))return!0;if(r.fastOr&&!1===kt(r.fastOr,t))return!1}}return!1},At=function(e,t,n=3){if(e===t)return 1;if(e.length<n||t.length<n)return 0;const r=function(e,t){const n=e.length,r=t.length;if(0===n)return r;if(0===r)return n;const o=(r>n?r:n)+1;if(Math.abs(n-r)>(o||100))return o||100;const a=[];for(let e=0;e<o;e++)a[e]=[e],a[e].length=o;for(let e=0;e<o;e++)a[0][e]=e;let i,s,l,u,c,h;for(let o=1;o<=n;++o)for(s=e[o-1],i=1;i<=r;++i){if(o===i&&a[o][i]>4)return n;l=t[i-1],u=s===l?0:1,c=a[o-1][i]+1,(h=a[o][i-1]+1)<c&&(c=h),(h=a[o-1][i-1]+u)<c&&(c=h);const r=o>1&&i>1&&s===t[i-2]&&e[o-2]===l&&(h=a[o-2][i-2]+u)<c;a[o][i]=r?h:c}return a[n][r]}(e,t),o=Math.max(e.length,t.length);return 1-(0===o?0:r/o)},Ct=/([\u0022\uFF02\u0027\u201C\u2018\u201F\u201B\u201E\u2E42\u201A\u00AB\u2039\u2035\u2036\u2037\u301D\u0060\u301F])/,Nt=/([\u0022\uFF02\u0027\u201D\u2019\u00BB\u203A\u2032\u2033\u2034\u301E\u00B4])/,jt=/^[-–—]$/,xt=/ [-–—]{1,3} /,It=(e,t)=>-1!==e.post.indexOf(t),Tt={hasQuote:e=>Ct.test(e.pre)||Nt.test(e.post),hasComma:e=>It(e,","),hasPeriod:e=>!0===It(e,".")&&!1===It(e,"..."),hasExclamation:e=>It(e,"!"),hasQuestionMark:e=>It(e,"?")||It(e,"¿"),hasEllipses:e=>It(e,"..")||It(e,"…"),hasSemicolon:e=>It(e,";"),hasColon:e=>It(e,":"),hasSlash:e=>/\//.test(e.text),hasHyphen:e=>jt.test(e.post)||jt.test(e.pre),hasDash:e=>xt.test(e.post)||xt.test(e.pre),hasContraction:e=>Boolean(e.implicit),isAcronym:e=>e.tags.has("Acronym"),isKnown:e=>e.tags.size>0,isTitleCase:e=>/^\p{Lu}[a-z'\u00C0-\u00FF]/u.test(e.text),isUpperCase:e=>/^\p{Lu}+$/u.test(e.text)};Tt.hasQuotation=Tt.hasQuote;let Dt=function(){};Dt=function(e,t,n,r){const o=function(e,t,n,r){if(!0===t.anything)return!0;if(!0===t.start&&0!==n)return!1;if(!0===t.end&&n!==r-1)return!1;if(void 0!==t.id&&t.id===e.id)return!0;if(void 0!==t.word){if(t.use)return t.word===e[t.use];if(null!==e.machine&&e.machine===t.word)return!0;if(void 0!==e.alias&&e.alias.hasOwnProperty(t.word))return!0;if(!0===t.fuzzy){if(t.word===e.root)return!0;if(At(t.word,e.normal)>=t.min)return!0}return!(!e.alias||!e.alias.some((e=>e===t.word)))||t.word===e.text||t.word===e.normal}if(void 0!==t.tag)return!0===e.tags.has(t.tag);if(void 0!==t.method)return"function"==typeof Tt[t.method]&&!0===Tt[t.method](e);if(void 0!==t.pre)return e.pre&&e.pre.includes(t.pre);if(void 0!==t.post)return e.post&&e.post.includes(t.post);if(void 0!==t.regex){let n=e.normal;return t.use&&(n=e[t.use]),t.regex.test(n)}if(void 0!==t.chunk)return e.chunk===t.chunk;if(void 0!==t.switch)return e.switch===t.switch;if(void 0!==t.machine)return e.normal===t.machine||e.machine===t.machine||e.root===t.machine;if(void 0!==t.sense)return e.sense===t.sense;if(void 0!==t.fastOr){if(t.pos&&!e.tags.has(t.pos))return null;const n=e.root||e.implicit||e.machine||e.normal;return t.fastOr.has(n)||t.fastOr.has(e.text)}return void 0!==t.choices&&("and"===t.operator?t.choices.every((t=>Dt(e,t,n,r))):t.choices.some((t=>Dt(e,t,n,r))))}(e,t,n,r);return!0===t.negative?!o:o};const Ht=function(e,t){if(!0===e.end&&!0===e.greedy&&t.start_i+t.t<t.phrase_length-1){const n=Object.assign({},e,{end:!1});if(!0===Dt(t.terms[t.t],n,t.start_i+t.t,t.phrase_length))return!0}return!1},Et=function(e,t){return e.groups[e.inGroup]||(e.groups[e.inGroup]={start:t,length:0}),e.groups[e.inGroup]},Gt=function(e){const{regs:t}=e,n=t[e.r],r=function(e,t){let n=e.t;if(!t)return e.terms.length;for(;n<e.terms.length;n+=1)if(!0===Dt(e.terms[n],t,e.start_i+n,e.phrase_length))return n;return null}(e,t[e.r+1]);if(null===r||0===r)return null;if(void 0!==n.min&&r-e.t<n.min)return null;if(void 0!==n.max&&r-e.t>n.max)return e.t=e.t+n.max,!0;if(!0===e.hasGroup){Et(e,e.t).length=r-e.t}return e.t=r,!0},Ot=function(e,t=0){const n=e.regs[e.r];let r=!1;for(let a=0;a<n.choices.length;a+=1){const i=n.choices[a];if(o=i,"[object Array]"!==Object.prototype.toString.call(o))return!1;if(r=i.every(((n,r)=>{let o=0;const a=e.t+r+t+o;if(void 0===e.terms[a])return!1;const i=Dt(e.terms[a],n,a+e.start_i,e.phrase_length);if(!0===i&&!0===n.greedy)for(let t=1;t<e.terms.length;t+=1){const r=e.terms[a+t];if(r){if(!0!==Dt(r,n,e.start_i+t,e.phrase_length))break;o+=1}}return t+=o,i})),r){t+=i.length;break}}var o;return r&&!0===n.greedy?Ot(e,t):t},Ft=function(e){const{regs:t}=e,n=t[e.r],r=Ot(e);if(r){if(!0===n.negative)return null;if(!0===e.hasGroup){Et(e,e.t).length+=r}if(!0===n.end){const t=e.phrase_length;if(e.t+e.start_i+r!==t)return null}return e.t+=r,!0}return!!n.optional||null},Vt=function(e){const{regs:t}=e,n=t[e.r],r=function(e){let t=0;return!0===e.regs[e.r].choices.every((n=>{const r=n.every(((t,n)=>{const r=e.t+n;return void 0!==e.terms[r]&&Dt(e.terms[r],t,r,e.phrase_length)}));return!0===r&&n.length>t&&(t=n.length),r}))&&t}(e);if(r){if(!0===n.negative)return null;if(!0===e.hasGroup){Et(e,e.t).length+=r}if(!0===n.end){const t=e.phrase_length-1;if(e.t+e.start_i!==t)return null}return e.t+=r,!0}return!!n.optional||null},zt=function(e){const{regs:t}=e,n=t[e.r],r=Object.assign({},n);r.negative=!1;if(Dt(e.terms[e.t],r,e.start_i+e.t,e.phrase_length))return!1;if(n.optional){const n=t[e.r+1];if(n){if(Dt(e.terms[e.t],n,e.start_i+e.t,e.phrase_length))e.r+=1;else if(n.optional&&t[e.r+2]){Dt(e.terms[e.t],t[e.r+2],e.start_i+e.t,e.phrase_length)&&(e.r+=2)}}}return n.greedy?function(e,t,n){let r=0;for(let o=e.t;o<e.terms.length;o+=1){let a=Dt(e.terms[o],t,e.start_i+e.t,e.phrase_length);if(a)break;if(n&&(a=Dt(e.terms[o],n,e.start_i+e.t,e.phrase_length),a))break;if(r+=1,void 0!==t.max&&r===t.max)break}return!(0===r||t.min&&t.min>r||(e.t+=r,0))}(e,r,t[e.r+1]):(e.t+=1,!0)},Bt=function(e){const{regs:t,phrase_length:n}=e,r=t[e.r];return e.t=function(e,t){const n=Object.assign({},e.regs[e.r],{start:!1,end:!1}),r=e.t;for(;e.t<e.terms.length;e.t+=1){if(t&&Dt(e.terms[e.t],t,e.start_i+e.t,e.phrase_length))return e.t;const o=e.t-r+1;if(void 0!==n.max&&o===n.max)return e.t;if(!1===Dt(e.terms[e.t],n,e.start_i+e.t,e.phrase_length))return void 0!==n.min&&o<n.min?null:e.t}return e.t}(e,t[e.r+1]),null===e.t||r.min&&r.min>e.t?null:!0!==r.end||e.start_i+e.t===n||null},St=function(e){const{regs:t}=e,n=t[e.r],r=e.terms[e.t],o=e.t;if(n.optional&&t[e.r+1]&&n.negative)return!0;if(n.optional&&t[e.r+1]&&function(e){const{regs:t}=e,n=t[e.r],r=e.terms[e.t],o=Dt(r,t[e.r+1],e.start_i+e.t,e.phrase_length);if(n.negative||o){const n=e.terms[e.t+1];n&&Dt(n,t[e.r+1],e.start_i+e.t,e.phrase_length)||(e.r+=1)}}(e),r.implicit&&e.terms[e.t+1]&&function(e){const t=e.terms[e.t],n=e.regs[e.r];if(t.implicit&&e.terms[e.t+1]){if(!e.terms[e.t+1].implicit)return;n.word===t.normal&&(e.t+=1),"hasContraction"===n.method&&(e.t+=1)}}(e),e.t+=1,!0===n.end&&e.t!==e.terms.length&&!0!==n.greedy)return null;if(!0===n.greedy){if(!Bt(e))return null}return!0===e.hasGroup&&function(e,t){const n=e.regs[e.r],r=Et(e,t);e.t>1&&n.greedy?r.length+=e.t-t:r.length++}(e,o),!0},$t=function(e,t,n,r){if(0===e.length||0===t.length)return null;const o={t:0,terms:e,r:0,regs:t,groups:{},start_i:n,phrase_length:r,inGroup:null};for(;o.r<t.length;o.r+=1){const e=t[o.r];if(o.hasGroup=Boolean(e.group),!0===o.hasGroup?o.inGroup=e.group:o.inGroup=null,!o.terms[o.t]){if(!1===t.slice(o.r).some((e=>!e.optional)))break;return null}if(!0===e.anything&&!0===e.greedy){if(!Gt(o))return null;continue}if(void 0!==e.choices&&"or"===e.operator){if(!Ft(o))return null;continue}if(void 0!==e.choices&&"and"===e.operator){if(!Vt(o))return null;continue}if(!0===e.anything){if(e.negative&&e.anything)return null;if(!St(o))return null;continue}if(!0===Ht(e,o)){if(!St(o))return null;continue}if(e.negative){if(!zt(o))return null;continue}if(!0!==Dt(o.terms[o.t],e,o.start_i+o.t,o.phrase_length)){if(!0!==e.optional)return null}else{if(!St(o))return null}}const a=[null,n,o.t+n];if(a[1]===a[2])return null;const i={};return Object.keys(o.groups).forEach((e=>{const t=o.groups[e],r=n+t.start;i[e]=[null,r,r+t.length]})),{pointer:a,groups:i}},Mt=function(e,t){return e.pointer[0]=t,Object.keys(e.groups).forEach((n=>{e.groups[n][0]=t})),e},Lt=function(e,t,n){let r=$t(e,t,0,e.length);return r?(r=Mt(r,n),r):null},Kt={one:{termMethods:Tt,parseMatch:function(e,t,n){if(null==e||""===e)return[];t=t||{},"number"==typeof e&&(e=String(e));let r=function(e){const t=e.split(tt);let n=[];t.forEach((e=>{ot(e)?n.push(e):n=n.concat(e.split(nt))})),n=at(n);let r=[];return n.forEach((e=>{(e=>/^[![^]*(<[^<]*>)?\(/.test(e)&&/\)[?\]+*$~]*$/.test(e))(e)||ot(e)?r.push(e):r=r.concat(e.split(rt))})),r=at(r),r}(e);return r=r.map((e=>pt(e,t))),r=function(e,t){const n=t.model.one.prefixes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];if(r.word&&ft.test(r.word)){let o=r.word.split(/[-–—]/g);if(n.hasOwnProperty(o[0]))continue;o=o.filter((e=>e)).reverse(),e.splice(t,1),o.forEach((n=>{const o=Object.assign({},r);o.word=n,e.splice(t,0,o)}))}}return e}(r,n),r=function(e,t){return e.map((e=>{if(e.root)if(t.methods.two&&t.methods.two.transform){let n=[];e.pos?"Verb"===e.pos?n=n.concat(bt(e,t)):"Noun"===e.pos?n=n.concat(vt(e,t)):"Adjective"===e.pos&&(n=n.concat(yt(e,t))):(n=n.concat(bt(e,t)),n=n.concat(vt(e,t)),n=n.concat(yt(e,t))),n=n.filter((e=>e)),n.length>0&&(e.operator="or",e.fastOr=new Set(n))}else e.machine=e.root,delete e.id,delete e.root;return e}))}(r,n),r=wt(r),r},match:function(e,t,n){n=n||[];const{regs:r,group:o,justOne:a}=t;let i=[];if(!r||0===r.length)return{ptrs:[],byGroup:{}};const s=r.filter((e=>!0!==e.optional&&!0!==e.negative)).length;e:for(let t=0;t<e.length;t+=1){const o=e[t];if(!n[t]||!Pt(r,n[t]))if(!0!==r[0].start)for(let e=0;e<o.length;e+=1){const n=o.slice(e);if(n.length<s)break;let l=$t(n,r,e,o.length);if(l){if(l=Mt(l,t),i.push(l),!0===a)break e;const n=l.pointer[2];Math.abs(n-1)>e&&(e=Math.abs(n-1))}}else{const e=Lt(o,r,t);e&&i.push(e)}}return!0===r[r.length-1].end&&(i=i.filter((t=>{const n=t.pointer[0];return e[n].length===t.pointer[2]}))),t.notIf&&(i=function(e,t,n){return e=e.filter((e=>{const[r,o,a]=e.pointer,i=n[r].slice(o,a);for(let e=0;e<i.length;e+=1){const n=i.slice(e);if(null!==$t(n,t,e,i.length))return!1}return!0})),e}(i,t.notIf,e)),i=function(e,t){const n=[],r={};return 0===e.length||("number"==typeof t&&(t=String(t)),t?e.forEach((e=>{e.groups[t]&&n.push(e.groups[t])})):e.forEach((e=>{n.push(e.pointer),Object.keys(e.groups).forEach((t=>{r[t]=r[t]||[],r[t].push(e.groups[t])}))}))),{ptrs:n,byGroup:r}}(i,o),i.ptrs.forEach((t=>{const[n,r,o]=t;t[3]=e[n][r].id,t[4]=e[n][o-1].id})),i}}};var Jt={api:function(e){Object.assign(e.prototype,et)},methods:Kt,lib:{parseMatch:function(e,t){const n=this.world(),r=n.methods.one.killUnicode;return r&&(e=r(e,n)),n.methods.one.parseMatch(e,t,n)}}};const Wt=/^\../,qt=/^#./,Ut=function(e,t){const n={},r={};return Object.keys(t).forEach((o=>{let a=t[o];const i=function(e){let t="",n="</span>";return e=e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;"),Wt.test(e)?t=`<span class="${e.replace(/^\./,"")}"`:qt.test(e)?t=`<span id="${e.replace(/^#/,"")}"`:(t=`<${e}`,n=`</${e}>`),t+=">",{start:t,end:n}}(o);"string"==typeof a&&(a=e.match(a)),a.docs.forEach((e=>{if(e.every((e=>e.implicit)))return;const t=e[0].id;n[t]=n[t]||[],n[t].push(i.start);const o=e[e.length-1].id;r[o]=r[o]||[],r[o].push(i.end)}))})),{starts:n,ends:r}};var Rt={html:function(e){const{starts:t,ends:n}=Ut(this,e);let r="";return this.docs.forEach((e=>{for(let o=0;o<e.length;o+=1){const a=e[o];t.hasOwnProperty(a.id)&&(r+=t[a.id].join("")),r+=a.pre||"",r+=a.text||"",n.hasOwnProperty(a.id)&&(r+=n[a.id].join("")),r+=a.post||""}})),r}};const Qt=/[,:;)\]*.?~!\u0022\uFF02\u201D\u2019\u00BB\u203A\u2032\u2033\u2034\u301E\u00B4—-]+$/,Zt=/^[(['"*~\uFF02\u201C\u2018\u201F\u201B\u201E\u2E42\u201A\u00AB\u2039\u2035\u2036\u2037\u301D\u0060\u301F]+/,_t=/[,:;)('"\u201D\]]/,Xt=/^[-–—]$/,Yt=/ /,en=function(e,t,n=!0){let r="";return e.forEach((e=>{let n=e.pre||"",o=e.post||"";"some"===t.punctuation&&(n=n.replace(Zt,""),Xt.test(o)&&(o=" "),o=o.replace(_t,""),o=o.replace(/\?!+/,"?"),o=