compromise
Version:
modest natural language processing
1 lines • 291 kB
JavaScript
var e,t;e=this,t=function(){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((a=>{t.compute.hasOwnProperty(a)?n[a](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)=>{let a=this.update([t]);e(a,n)})),this},map:function(e,t){let n=this.fullPointer.map(((t,n)=>{let a=this.update([t]),r=e(a,n);return void 0===r?this.none():r}));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 a=[];return n.forEach((e=>{a=a.concat(e.fullPointer)})),this.toView(a)},filter:function(e){let t=this.fullPointer;return t=t.filter(((t,n)=>{let a=this.update([t]);return e(a,n)})),this.update(t)},find:function(e){let t=this.fullPointer.find(((t,n)=>{let a=this.update([t]);return e(a,n)}));return this.update([t])},some:function(e){return this.fullPointer.some(((t,n)=>{let a=this.update([t]);return e(a,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 a={termList:function(){return this.methods.one.termList(this.docs)},terms:function(e){let t=this.match(".");return"number"==typeof e?t.eq(e):t},groups:function(e){if(e||0===e)return this.update(this._groups[e]||[]);let 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(){let 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(){let 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;let 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(){let 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}};a.group=a.groups,a.fullSentence=a.fullSentences,a.sentence=a.fullSentences,a.lastTerm=a.lastTerms,a.firstTerm=a.firstTerms;const r=Object.assign({},a,t,n);r.get=r.eq;class View{constructor(t,n,a={}){[["document",t],["world",e],["_groups",a],["_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(){let{docs:e,ptrs:t,document:n}=this,a=t||e.map(((e,t)=>[t]));return a.map((e=>{let[t,a,r,o,i]=e;return a=a||0,r=r||(n[t]||[]).length,n[t]&&n[t][a]&&(o=o||n[t][a].id,n[t][r-1]&&(i=i||n[t][r-1].id)),[t,a,r,o,i]}))}update(e){let t=new View(this.document,e);if(this._cache&&e&&e.length>0){let n=[];e.forEach(((e,t)=>{let[a,r,o]=e;(1===e.length||0===r&&this.document[a].length===o)&&(n[t]=this._cache[a])})),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;let n=t.one.tokenize.fromString(e,this.world),a=new View(n);return a.world=this.world,a.compute(["normal","freeze","lexicon"]),this.world.compute.preTagger&&a.compute("preTagger"),a.compute("unfreeze"),a}clone(){let e=this.document.slice(0);e=e.map((e=>e.map((e=>((e=Object.assign({},e)).tags=new Set(e.tags),e)))));let t=this.update(this.pointer);return t.document=e,t._cache=this._cache,t}}Object.assign(View.prototype,r);const o=function(e){return e&&"object"==typeof e&&!Array.isArray(e)};function i(e,t){if(o(t))for(const n in t)o(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,a){const{methods:r,model:o,compute:s,hooks:l}=t;e.methods&&function(e,t){for(const n in t)e[n]=e[n]||{},Object.assign(e[n],t[n])}(r,e.methods),e.model&&i(o,e.model),e.irregulars&&function(e,t){let 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))}))}(o,e.irregulars),e.compute&&Object.assign(s,e.compute),l&&(t.hooks=l.concat(e.hooks||[])),e.api&&e.api(n),e.lib&&Object.keys(e.lib).forEach((t=>a[t]=e.lib[t])),e.tags&&a.addTags(e.tags),e.words&&a.addWords(e.words),e.frozen&&a.addWords(e.frozen,!0),e.mutate&&e.mutate(t,a)},l=function(e){return"[object Array]"===Object.prototype.toString.call(e)},u=function(e,t,n){const{methods:a}=n;let r=new t([]);if(r.world=n,"number"==typeof e&&(e=String(e)),!e)return r;if("string"==typeof e)return new t(a.one.tokenize.fromString(e,n));if(o=e,"[object Object]"===Object.prototype.toString.call(o)&&e.isView)return new t(e.document,e.ptrs);var o;if(l(e)){if(l(e[0])){let n=e.map((e=>e.map((e=>({text:e,normal:e,pre:"",post:" ",tags:new Set})))));return new t(n)}let n=e.map((e=>e.terms.map((e=>(l(e.tags)&&(e.tags=new Set(e.tags)),e)))));return new t(n)}return r};let c=Object.assign({},e);const d=function(e,t){t&&d.addWords(t);let n=u(e,View,c);return e&&n.compute(c.hooks),n};Object.defineProperty(d,"_world",{value:c,writable:!0}),d.tokenize=function(e,t){const{compute:n}=this._world;t&&d.addWords(t);let a=u(e,View,c);return n.contractions&&a.compute(["alias","normal","machine","contractions"]),a},d.plugin=function(e){return s(e,this._world,View,this),this},d.extend=d.plugin,d.world=function(){return this._world},d.model=function(){return this._world.model},d.methods=function(){return this._world.methods},d.hooks=function(){return this._world.hooks},d.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},d.version="14.14.4";var h={one:{cacheDoc:function(e){let t=e.map((e=>{let 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)));let 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:h};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){let a=[t,0].concat(n);Array.prototype.splice.apply(e,a)}return e},y=function(e){let t=e[e.length-1];!t||/ $/.test(t.post)||/[-–—]/.test(t.post)||(t.post+=" ")},v=(e,t,n)=>{const a=/[-.?!,;:)–—'"]/g;let r=e[t-1];if(!r)return;let o=r.post;if(a.test(o)){let e=o.match(a).join(""),t=n[n.length-1];t.post=e+t.post,r.post=r.post.replace(a,"")}},w=function(e,t,n,a){let[r,o,i]=t;0===o||i===a[r].length?y(n):(y(n),y([e[t[1]]])),function(e,t,n){let a=e[t];if(0!==t||!f(a.text))return;n[0].text=n[0].text.replace(/^\p{Ll}/u,(e=>e.toUpperCase()));let r=e[t];r.tags.has("ProperNoun")||r.tags.has("Acronym")||f(r.text)&&r.text.length>1&&(r.text=r.text.replace(/^\p{Lu}/u,(e=>e.toLowerCase())))}(e,o,n),b(e,o,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 a=P(k.toString(36));a+=P(t.toString(36));let r=n.toString(36);return r=r.length<2?"0"+r:r,a+=r,a+=parseInt(36*Math.random(),10).toString(36),e.normal+"|"+a.toUpperCase()},C=function(e){e.has("@hasContraction")&&"function"==typeof e.contractions&&e.grow("@hasContraction").contractions().expand()},j=e=>"[object Array]"===Object.prototype.toString.call(e),N=function(e,t,n){const{document:a,world:r}=t;t.uncache();let o=t.fullPointer,i=t.fullPointer;t.forEach(((s,l)=>{let u=s.fullPointer[0],[c]=u,d=a[c],h=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]||[]:j(e)?j(e[0])?e[0]:e:[]}(e,r);0!==h.length&&(h=function(e){return e.map((e=>(e.id=A(e),e)))}(h),n?(C(t.update([u]).firstTerm()),w(d,u,h,a)):(C(t.update([u]).lastTerm()),function(e,t,n,a){let[r,,o]=t,i=(a[r]||[]).length;o<i?(v(e,o,n),y(n)):i===o&&(y(e),v(e,o,n),a[r+1]&&(n[n.length-1].post+=" ")),b(e,t[2],n),t[4]=n[n.length-1].id}(d,u,h,a)),a[c]&&a[c][u[1]]&&(u[3]=a[c][u[1]].id),i[l]=u,u[2]+=h.length,o[l]=u)}));let s=t.toView(o);return t.ptrs=i,s.compute(["id","index","freeze","lexicon"]),s.world.compute.preTagger&&s.compute("preTagger"),s.compute("unfreeze"),s},I={insertAfter:function(e){return N(e,this,!1)},insertBefore:function(e){return N(e,this,!0)}};I.append=I.insertAfter,I.prepend=I.insertBefore,I.insert=I.insertAfter;const D=/\$[0-9a-z]+/g,H={},T=e=>e.replace(/^\p{Ll}/u,(e=>e.toUpperCase())),G=e=>e.replace(/^\p{Lu}/u,(e=>e.toLowerCase()));H.replaceWith=function(e,t={}){let n=this.fullPointer,a=this;if(this.uncache(),"function"==typeof e)return function(e,t,n){return e.forEach((e=>{let a=t(e);e.replaceWith(a,n)})),e}(a,e,t);let r=a.docs[0];if(!r)return a;let o=t.possessives&&r[r.length-1].tags.has("Possessive"),i=t.case&&(s=r[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;let n=t.groups();return e=e.replace(D,(e=>{let t=e.replace(/\$/,"");return n.hasOwnProperty(t)?n[t].text():e})),e}(e,a);let l=this.update(n);n=n.map((e=>e.slice(0,3)));let u=(l.docs[0]||[]).map((e=>Array.from(e.tags))),c=l.docs[0][0].pre,d=l.docs[0][l.docs[0].length-1].post;if("string"==typeof e&&(e=this.fromText(e).compute("id")),a.insertAfter(e),l.has("@hasContraction")&&a.contractions&&a.grow("@hasContraction+").contractions().expand(),a.delete(l),o){let e=a.docs[0],t=e[e.length-1];t.tags.has("Possessive")||(t.text+="'s",t.normal+="'s",t.tags.add("Possessive"))}if(c&&a.docs[0]&&(a.docs[0][0].pre=c),d&&a.docs[0]){let e=a.docs[0][a.docs[0].length-1];e.post.trim()||(e.post=d)}let h=a.toView(n).compute(["index","freeze","lexicon"]);if(h.world.compute.preTagger&&h.compute("preTagger"),h.compute("unfreeze"),t.tags&&h.terms().forEach(((e,t)=>{e.tagSafe(u[t])})),!h.docs[0]||!h.docs[0][0])return h;if(t.case){let e=i?T:G;h.docs[0][0].text=e(h.docs[0][0].text)}return h},H.replace=function(e,t,n){if(e&&!t)return this.replaceWith(e,n);let a=this.match(e);return a.found?(this.soften(),a.replaceWith(t,n)):this};const x={remove:function(e){const{indexN:t}=this.methods.one.pointer;this.uncache();let n=this.all(),a=this;e&&(n=this,a=this.match(e));let r=!n.ptrs;a.has("@hasContraction")&&a.contractions&&a.grow("@hasContraction").contractions().expand();let o=n.fullPointer,i=a.fullPointer.reverse(),s=function(e,t){t.forEach((t=>{let[n,a,r]=t,o=r-a;e[n]&&(r===e[n].length&&r>1&&function(e,t){let n=e.length-1,a=e[n],r=e[n-t];r&&a&&(r.post+=a.post,r.post=r.post.replace(/ +([.?!,;:])/,"$1"),r.post=r.post.replace(/[,;:]+([.?!])/,"$1"))}(e[n],o),e[n].splice(a,o))}));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])){let n=e[t-1],a=n[n.length-1];a&&(a.post=a.post.trimEnd())}return e}(this.document,i);return o=function(e,t){return e=e.map((e=>{let[n]=e;return t[n]?(t[n].forEach((t=>{let 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)))}(o,t(i)),n.ptrs=o,n.document=s,n.compute("index"),r&&(n.ptrs=void 0),e?n.toView(o):(this.ptrs=[],n.none())}};x.delete=x.remove;const E={pre:function(e,t){return void 0===e&&this.found?this.docs[0][0].pre:(this.docs.forEach((n=>{let a=n[0];!0===t?a.pre+=e:a.pre=e})),this)},post:function(e,t){if(void 0===e){let e=this.docs[this.docs.length-1];return e[e.length-1].post}return this.docs.forEach((n=>{let a=n[n.length-1];!0===t?a.post+=e:a.post=e})),this},trim:function(){if(!this.found)return this;let e=this.docs,t=e[0][0];t.pre=t.pre.trimStart();let n=e[e.length-1],a=n[n.length-1];return a.post=a.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;let a=n[n.length-1];a.post=t+a.post})),this},toParentheses:function(e,t){return e=e||"(",t=t||")",this.docs.forEach((n=>{n[0].pre=e+n[0].pre;let a=n[n.length-1];a.post=t+a.post})),this}};E.deHyphenate=E.dehyphenate,E.toQuotation=E.toQuotations;var F={alpha:(e,t)=>e.normal<t.normal?-1:e.normal>t.normal?1:0,length:(e,t)=>{let n=e.normal.trim().length,a=t.normal.trim().length;return n<a?1:n>a?-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){let t={};return e.forEach((e=>{t[e.normal]=t[e.normal]||0,t[e.normal]+=1})),e.sort(((e,n)=>{let a=t[e.normal],r=t[n.normal];return a<r?1:a>r?-1:0})),e}};const O=new Set(["index","sequence","seq","sequential","chron","chronological"]),z=new Set(["freq","frequency","topk","repeats"]),V=new Set(["alpha","alphabetical"]);var B={unique:function(){let e=new Set,t=this.filter((t=>{let 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){let{docs:t,pointer:n}=this;if(this.uncache(),"function"==typeof e)return function(e,t){let n=e.fullPointer;return n=n.sort(((n,a)=>(n=e.update([n]),a=e.update([a]),t(n,a)))),e.ptrs=n,e}(this,e);e=e||"alpha";let a=n||t.map(((e,t)=>[t])),r=t.map(((e,t)=>({index:t,words:e.length,normal:e.map((e=>e.machine||e.normal||"")).join(" "),pointer:a[t]})));return O.has(e)&&(e="sequential"),V.has(e)&&(e="alpha"),z.has(e)?(r=F.byFreq(r),this.update(r.map((e=>e.pointer)))):"function"==typeof F[e]?(r=r.sort(F[e]),this.update(r.map((e=>e.pointer)))):this}};const S=function(e,t){if(e.length>0){let t=e[e.length-1],n=t[t.length-1];!1===/ /.test(n.post)&&(n.post+=" ")}return e=e.concat(t)};var K={concat:function(e){if("string"==typeof e){let t=this.fromText(e);if(this.found&&this.ptrs){let 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){let 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)){let t=S(this.document,e);return this.document=t,this.all()}var t;return this}},$={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}},I,H,x,E,B,K,$),M={id:function(e){let t=e.docs;for(let e=0;e<t.length;e+=1)for(let n=0;n<t[e].length;n+=1){let a=t[e][n];a.id=a.id||A(a)}}};var J={api:function(e){Object.assign(e.prototype,L)},compute:M};const W=!0;var U={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 q=function(e,t,n){let[a,r]=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=[a,r+t],e))),n[0]&&(n[0].pre=e[a][r].pre,n[n.length-1].post=e[a][r].post,n[0].text=e[a][r].text,n[0].normal=e[a][r].normal),e[a].splice(r,1,...n))},R=/'/,Q=new Set(["what","how","when","where","why"]),Z=new Set(["be","go","start","think","need"]),X=new Set(["been","gone"]),_=/'/,Y=/(e|é|aison|sion|tion)$/,ee=/(age|isme|acle|ege|oire)$/;var te=(e,t)=>["je",e[t].normal.split(_)[1]],ne=(e,t)=>{let n=e[t].normal.split(_)[1];return n&&n.endsWith("e")?["la",n]:["le",n]},ae=(e,t)=>{let n=e[t].normal.split(_)[1];return n&&Y.test(n)&&!ee.test(n)?["du",n]:n&&n.endsWith("s")?["des",n]:["de",n]};const re=/^([0-9.]{1,4}[a-z]{0,2}) ?[-–—] ?([0-9]{1,4}[a-z]{0,2})$/i,oe=/^([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){let n=e[t],a=n.text.match(re);return null!==a?!0===n.tags.has("PhoneNumber")||ie.test(n.text)?null:[a[1],"to",a[2]]:(a=n.text.match(oe),null!==a?[a[1],"to",a[4]]:null)},le=/^([+-]?[0-9][.,0-9]*)([a-z°²³µ/]+)$/,ue=function(e,t,n){const a=n.model.one.numberSuffixes||{};let r=e[t].text.match(le);if(null!==r){let e=r[2].toLowerCase().trim();return a.hasOwnProperty(e)?null:[r[1],e]}return null},ce=/'/,de=/^[0-9][^-–—]*[-–—].*?[0-9]/,he=function(e,t,n,a){let r=t.update();r.document=[e];let o=n+a;n>0&&(n-=1),e[o]&&(o+=1),r.ptrs=[[0,n,o]]},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){let n=e[t].normal.split(R)[0];if(Q.has(n))return[n,"did"];if(e[t+1]){if(X.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)=>ae(e,t)},pe=function(e,t,n,a){for(let r=0;r<e.length;r+=1){let o=e[r];if(o.word===t.normal)return o.out;if(null!==a&&a===o.after)return[n].concat(o.out);if(null!==n&&n===o.before&&a&&a.length>2)return o.out.concat(a)}return null},fe=function(e,t){let 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 ye={contractions:e=>{let{world:t,document:n}=e;const{model:a,methods:r}=t;let o=a.one.contractions||[];n.forEach(((a,i)=>{for(let s=a.length-1;s>=0;s-=1){let l=null,u=null;if(!0===ce.test(a[s].normal)){let e=a[s].normal.split(ce);l=e[0],u=e[1]}let c=pe(o,a[s],l,u);!c&&ge.hasOwnProperty(u)&&(c=ge[u](a,s,t)),!c&&me.hasOwnProperty(l)&&(c=me[l](a,s)),"there"===l&&"s"===u&&(c=be(a,s)),c?(c=fe(c,e),q(n,[i,s],c),he(n[i],e,s,c.length)):de.test(a[s].normal)?(c=se(a,s),c&&(c=fe(c,e),q(n,[i,s],c),r.one.setTag(c,"NumberRange",t),c[2]&&c[2].tags.has("Time")&&r.one.setTag([c[0]],"Time",t,null,"time-range"),he(n[i],e,s,c.length))):(c=ue(a,s,t),c&&(c=fe(c,e),q(n,[i,s],c),r.one.setTag([c[1]],"Unit",t,null,"contraction-unit")))}}))}};const ve={model:U,compute:ye,hooks:["contractions"]},we=function(e){const t=e.world,{model:n,methods:a}=e.world,r=a.one.setTag,{frozenLex:o}=n.one,i=n.one._multiCache||{};e.docs.forEach((e=>{for(let n=0;n<e.length;n+=1){let a=e[n],s=a.machine||a.normal;if(void 0!==i[s]&&e[n+1])for(let a=n+i[s]-1;a>n;a-=1){let i=e.slice(n,a+1),s=i.map((e=>e.machine||e.normal)).join(" ");!0!==o.hasOwnProperty(s)||(r(i,o[s],t,!1,"1-frozen-multi-lexicon"),i.forEach((e=>e.frozen=!0)))}void 0!==o[s]&&o.hasOwnProperty(s)&&(r([a],o[s],t,!1,"1-freeze-lexicon"),a.frozen=!0)}}))},ke=e=>"[34m"+e+"[0m",Pe=e=>"[3m[2m"+e+"[0m",Ae=function(e){e.docs.forEach((e=>{console.log(ke("\n ┌─────────")),e.forEach((e=>{let t=` ${Pe("│")} `,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 je=function(e,t,n){const{model:a,methods:r}=n,o=r.one.setTag,i=a.one._multiCache||{},{lexicon:s}=a.one||{};let l=e[t],u=l.machine||l.normal;if(void 0!==i[u]&&e[t+1]){for(let a=t+i[u]-1;a>t;a-=1){let r=e.slice(t,a+1);if(r.length<=1)return!1;let i=r.map((e=>e.machine||e.normal)).join(" ");if(!0===s.hasOwnProperty(i)){let e=s[i];return o(r,e,n,!1,"1-multi-lexicon"),!e||2!==e.length||"PhrasalVerb"!==e[0]&&"PhrasalVerb"!==e[1]||o([r[1]],"Particle",n,!1,"1-phrasal-particle"),!0}}return!1}return null},Ne=/^(under|over|mis|re|un|dis|semi|pre|post)-?/,Ie=new Set(["Verb","Infinitive","PastTense","Gerund","PresentTense","Adjective","Participle"]),De=function(e,t,n){const{model:a,methods:r}=n,o=r.one.setTag,{lexicon:i}=a.one;let s=e[t],l=s.machine||s.normal;if(void 0!==i[l]&&i.hasOwnProperty(l))return o([s],i[l],n,!1,"1-lexicon"),!0;if(s.alias){let e=s.alias.find((e=>i.hasOwnProperty(e)));if(e)return o([s],i[e],n,!1,"1-lexicon-alias"),!0}if(!0===Ne.test(l)){let e=l.replace(Ne,"");if(i.hasOwnProperty(e)&&e.length>3&&Ie.has(i[e]))return o([s],i[e],n,!1,"1-lexicon-prefix"),!0}return null};var He={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 a=null;a=a||je(e,n,t),a=a||De(e,n,t)}}))}},Te={one:{expandLexicon:function(e){let t={},n={};return Object.keys(e).forEach((a=>{let r=e[a],o=(a=(a=a.toLowerCase().trim()).replace(/'s\b/,"")).split(/ /);o.length>1&&(void 0===n[o[0]]||o.length>n[o[0]])&&(n[o[0]]=o.length),t[a]=t[a]||r})),delete t[""],delete t.null,delete t[" "],{lex:t,_multi:n}}}},Ge={addWords:function(e,t=!1){const n=this.world(),{methods:a,model:r}=n;if(!e)return;if(Object.keys(e).forEach((t=>{"string"==typeof e[t]&&e[t].startsWith("#")&&(e[t]=e[t].replace(/^#/,""))})),!0===t){let{lex:t,_multi:o}=a.one.expandLexicon(e,n);return Object.assign(r.one._multiCache,o),void Object.assign(r.one.frozenLex,t)}if(a.two.expandLexicon){let{lex:t,_multi:o}=a.two.expandLexicon(e,n);Object.assign(r.one.lexicon,t),Object.assign(r.one._multiCache,o)}let{lex:o,_multi:i}=a.one.expandLexicon(e,n);Object.assign(r.one.lexicon,o),Object.assign(r.one._multiCache,i)}},xe={model:{one:{lexicon:{},_multiCache:{},frozenLex:{}}},methods:Te,compute:He,lib:Ge,hooks:["lexicon"]};const Ee=function(e,t){let n=[{}],a=[null],r=[0],o=[],i=0;e.forEach((function(e){let r=0,o=function(e,t){const{methods:n,model:a}=t;let r=n.one.tokenize.splitTerms(e,a).map((e=>n.one.tokenize.splitWhitespace(e,a)));return r.map((e=>e.text.toLowerCase()))}(e,t);for(let e=0;e<o.length;e++){let t=o[e];n[r]&&n[r].hasOwnProperty(t)?r=n[r][t]:(i++,n[r][t]=i,n[i]={},r=i,a[i]=null)}a[r]=[o.length]}));for(let e in n[0])i=n[0][e],r[i]=0,o.push(i);for(;o.length;){let e=o.shift(),t=Object.keys(n[e]);for(let s=0;s<t.length;s+=1){let l=t[s],u=n[e][l];for(o.push(u),i=r[e];i>0&&!n[i].hasOwnProperty(l);)i=r[i];if(n.hasOwnProperty(i)){let e=n[i][l];r[u]=e,a[e]&&(a[u]=a[u]||[],a[u]=a[u].concat(a[e]))}else r[u]=0}}return{goNext:n,endAs:a,failTo:r}},Fe=function(e,t,n){let a=0,r=[];for(let o=0;o<e.length;o++){let i=e[o][n.form]||e[o].normal;for(;a>0&&(void 0===t.goNext[a]||!t.goNext[a].hasOwnProperty(i));)a=t.failTo[a]||0;if(t.goNext[a].hasOwnProperty(i)&&(a=t.goNext[a][i],t.endAs[a])){let n=t.endAs[a];for(let t=0;t<n.length;t++){let a=n[t],i=e[o-a+1],[s,l]=i.index;r.push([s,l,l+a,i.id])}}}return r},Oe=function(e,t){for(let n=0;n<e.length;n+=1)if(!0===t.has(e[n]))return!1;return!0},ze=(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},Ve={buildTrie:function(e){return function(e){return e.goNext=e.goNext.map((e=>{if(0!==Object.keys(e).length)return e})),e.goNext=ze(e.goNext,void 0),e.failTo=ze(e.failTo,0),e.endAs=ze(e.endAs,null),e}(Ee(e,this.world()))}};Ve.compile=Ve.buildTrie;var Be={api:function(e){e.prototype.lookup=function(e,t={}){if(!e)return this.none();var n;"string"==typeof e&&(e=[e]);let a=function(e,t,n){let a=[];n.form=n.form||"normal";let r=e.docs;if(!t.goNext||!t.goNext[0])return console.error("Compromise invalid lookup trie"),e.none();let o=Object.keys(t.goNext[0]);for(let i=0;i<r.length;i++){if(e._cache&&e._cache[i]&&!0===Oe(o,e._cache[i]))continue;let s=r[i],l=Fe(s,t,n);l.length>0&&(a=a.concat(l))}return e.update(a)}(this,(n=e,"[object Object]"===Object.prototype.toString.call(n)?e:Ee(e,this.world)),t);return a=a.settle(),a}},lib:Ve};const Se=function(e,t){return t?(e.forEach((e=>{let n=e[0];t[n]&&(e[0]=t[n][0],e[1]+=t[n][1],e[2]+=t[n][1])})),e):e},Ke=function(e,t){let{ptrs:n,byGroup:a}=e;return n=Se(n,t),Object.keys(a).forEach((e=>{a[e]=Se(a[e],t)})),{ptrs:n,byGroup:a}},$e=function(e,t,n){const a=n.methods.one;return"number"==typeof e&&(e=String(e)),"string"==typeof e&&(e=a.killUnicode(e,n),e=a.parseMatch(e,t,n)),e},Le=e=>"[object Object]"===Object.prototype.toString.call(e),Me=e=>e&&Le(e)&&!0===e.isView,Je=e=>e&&Le(e)&&!0===e.isNet;var We={matchOne:function(e,t,n){const a=this.methods.one;if(Me(e))return this.intersection(e).eq(0);if(Je(e))return this.sweep(e,{tagger:!1,matchOne:!0}).view;let r={regs:e=$e(e,n,this.world),group:t,justOne:!0},o=a.match(this.docs,r,this._cache),{ptrs:i,byGroup:s}=Ke(o,this.fullPointer),l=this.toView(i);return l._groups=s,l},match:function(e,t,n){const a=this.methods.one;if(Me(e))return this.intersection(e);if(Je(e))return this.sweep(e,{tagger:!1}).view.settle();let r={regs:e=$e(e,n,this.world),group:t},o=a.match(this.docs,r,this._cache),{ptrs:i,byGroup:s}=Ke(o,this.fullPointer),l=this.toView(i);return l._groups=s,l},has:function(e,t,n){const a=this.methods.one;if(Me(e))return this.intersection(e).fullPointer.length>0;if(Je(e))return this.sweep(e,{tagger:!1}).view.found;let r={regs:e=$e(e,n,this.world),group:t,justOne:!0};return a.match(this.docs,r,this._cache).ptrs.length>0},if:function(e,t,n){const a=this.methods.one;if(Me(e))return this.filter((t=>t.intersection(e).found));if(Je(e)){let t=this.sweep(e,{tagger:!1}).view.settle();return this.if(t)}let r={regs:e=$e(e,n,this.world),group:t,justOne:!0},o=this.fullPointer,i=this._cache||[];o=o.filter(((e,t)=>{let n=this.update([e]);return a.match(n.docs,r,i[t]).ptrs.length>0}));let s=this.update(o);return this._cache&&(s._cache=o.map((e=>i[e[0]]))),s},ifNo:function(e,t,n){const{methods:a}=this,r=a.one;if(Me(e))return this.filter((t=>!t.intersection(e).found));if(Je(e)){let t=this.sweep(e,{tagger:!1}).view.settle();return this.ifNo(t)}e=$e(e,n,this.world);let o=this._cache||[],i=this.filter(((n,a)=>{let i={regs:e,group:t,justOne:!0};return 0===r.match(n.docs,i,o[a]).ptrs.length}));return this._cache&&(i._cache=i.ptrs.map((e=>o[e[0]]))),i}},Ue={before:function(e,t,n){const{indexN:a}=this.methods.one.pointer;let r=[],o=a(this.fullPointer);Object.keys(o).forEach((e=>{let t=o[e].sort(((e,t)=>e[1]>t[1]?1:-1))[0];t[1]>0&&r.push([t[0],0,t[1]])}));let i=this.toView(r);return e?i.match(e,t,n):i},after:function(e,t,n){const{indexN:a}=this.methods.one.pointer;let r=[],o=a(this.fullPointer),i=this.document;Object.keys(o).forEach((e=>{let t=o[e].sort(((e,t)=>e[1]>t[1]?-1:1))[0],[n,,a]=t;a<i[n].length&&r.push([n,a,i[n].length])}));let s=this.toView(r);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;let a=this.fullPointer;return this.forEach(((n,r)=>{let o=n.before(e,t);if(o.found){let e=o.terms();a[r][1]-=e.length,a[r][3]=e.docs[0][0].id}})),this.update(a)},growRight:function(e,t,n){"string"==typeof e&&(e=this.world.methods.one.parseMatch(e,n,this.world)),e[0].start=!0;let a=this.fullPointer;return this.forEach(((n,r)=>{let o=n.after(e,t);if(o.found){let e=o.terms();a[r][2]+=e.length,a[r][4]=null}})),this.update(a)},grow:function(e,t,n){return this.growRight(e,t,n).growLeft(e,t,n)}};const qe=function(e,t){return[e[0],e[1],t[2]]},Re=(e,t,n)=>{return"string"==typeof e||(a=e,"[object Array]"===Object.prototype.toString.call(a))?t.match(e,n):e||t.none();var a},Qe=function(e,t){let[n,a,r]=e;return t.document[n]&&t.document[n][a]&&(e[3]=e[3]||t.document[n][a].id,t.document[n][r-1]&&(e[4]=e[4]||t.document[n][r-1].id)),e},Ze={splitOn:function(e,t){const{splitAll:n}=this.methods.one.pointer;let a=Re(e,this,t).fullPointer,r=n(this.fullPointer,a),o=[];return r.forEach((e=>{o.push(e.passthrough),o.push(e.before),o.push(e.match),o.push(e.after)})),o=o.filter((e=>e)),o=o.map((e=>Qe(e,this))),this.update(o)},splitBefore:function(e,t){const{splitAll:n}=this.methods.one.pointer;let a=Re(e,this,t).fullPointer,r=n(this.fullPointer,a);for(let e=0;e<r.length;e+=1)!r[e].after&&r[e+1]&&r[e+1].before&&r[e].match&&r[e].match[0]===r[e+1].before[0]&&(r[e].after=r[e+1].before,delete r[e+1].before);let o=[];return r.forEach((e=>{o.push(e.passthrough),o.push(e.before),e.match&&e.after?o.push(qe(e.match,e.after)):o.push(e.match)})),o=o.filter((e=>e)),o=o.map((e=>Qe(e,this))),this.update(o)},splitAfter:function(e,t){const{splitAll:n}=this.methods.one.pointer;let a=Re(e,this,t).fullPointer,r=n(this.fullPointer,a),o=[];return r.forEach((e=>{o.push(e.passthrough),e.before&&e.match?o.push(qe(e.before,e.match)):(o.push(e.before),o.push(e.match)),o.push(e.after)})),o=o.filter((e=>e)),o=o.map((e=>Qe(e,this))),this.update(o)}};Ze.split=Ze.splitAfter;const Xe=function(e,t){return!(!e||!t)&&e[0]===t[0]&&e[2]===t[1]},_e=function(e,t,n){const a=e.world,r=a.methods.one.parseMatch;n=n||"^.";let o=r(t=t||".$",{},a),i=r(n,{},a);o[o.length-1].end=!0,i[0].start=!0;let s=e.fullPointer,l=[s[0]];for(let t=1;t<s.length;t+=1){let n=l[l.length-1],a=s[t],r=e.update([n]),u=e.update([a]);Xe(n,a)&&r.has(o)&&u.has(i)?l[l.length-1]=[n[0],n[1],a[2],n[3],a[4]]:l.push(a)}return e.update(l)},Ye={joinIf:function(e,t){return _e(this,e,t)},join:function(){return _e(this)}},et=Object.assign({},We,Ue,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|$)/,at=/ /g,rt=e=>/^[![^]*(<[^<]*>)?\//.test(e)&&/\/[?\]+*$~]*$/.test(e),ot=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),dt=e=>e.charAt(0),ht=e=>e.substring(1),gt=e=>e.substring(0,e.length-1),mt=function(e){return e=ht(e),e=gt(e)},pt=function(e,t){let n={};for(let a=0;a<2;a+=1){if("$"===ct(e)&&(n.end=!0,e=gt(e)),"^"===dt(e)&&(n.start=!0,e=ht(e)),"?"===ct(e)&&(n.optional=!0,e=gt(e)),("["===dt(e)||"]"===ct(e))&&(n.group=null,"["===dt(e)&&(n.groupStart=!0),"]"===ct(e)&&(n.groupEnd=!0),e=(e=e.replace(/^\[/,"")).replace(/\]$/,""),"<"===dt(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)),"!"===dt(e)&&(n.negative=!0,e=ht(e)),"~"===dt(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("/"===dt(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,a)=>(void 0===a?(n.min=Number(t),n.max=Number(t)):(a=a.replace(/, */,""),void 0===t?(n.min=0,n.max=Number(a)):(n.min=Number(t),n.max=Number(a||999))),n.greedy=!0,n.min||(n.optional=!0),"")))),"("===dt(e)&&")"===ct(e)){st.test(e)?(n.choices=e.split(st),n.operator="and"):(n.choices=e.split("|"),n.operator="or"),n.choices[0]=ht(n.choices[0]);let a=n.choices.length-1;n.choices[a]=gt(n.choices[a]),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("{"===dt(e)&&"}"===ct(e)){if(e=mt(e),n.root=e,/\//.test(e)){let 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("<"===dt(e)&&">"===ct(e))return e=mt(e),n.chunk=ut(e),n.greedy=!0,n;if("%"===dt(e)&&"%"===ct(e))return e=mt(e),n.switch=e,n}return"#"===dt(e)?(n.tag=ht(e),n.tag=ut(n.tag),n):"@"===dt(e)?(n.method=ht(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){let{all:n}=t.methods.two.transform.verb||{},a=e.root;return n?n(a,t.model):[]},yt=function(e,t){let{all:n}=t.methods.two.transform.noun||{};return n?n(e.root,t.model):[e.root]},vt=function(e,t){let{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 a=0;a<e.length;a++){const r=e[a];!0===r.groupStart&&(n=r.group,null===n&&(n=String(t),t+=1)),null!==n&&(r.group=n),!0===r.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;let 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(let n of t)if(e.has(n))return!0;return!1},Pt=function(e,t){for(let n=0;n<e.length;n+=1){let a=e[n];if(!0!==a.optional&&!0!==a.negative&&!0!==a.fuzzy){if(void 0!==a.word&&!1===t.has(a.word))return!0;if(void 0!==a.tag&&!1===t.has("#"+a.tag))return!0;if(a.fastOr&&!1===kt(a.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 a=function(e,t){let n=e.length,a=t.length;if(0===n)return a;if(0===a)return n;let r=(a>n?a:n)+1;if(Math.abs(n-a)>(r||100))return r||100;let o,i,s,l,u,c,d=[];for(let e=0;e<r;e++)d[e]=[e],d[e].length=r;for(let e=0;e<r;e++)d[0][e]=e;for(let r=1;r<=n;++r)for(i=e[r-1],o=1;o<=a;++o){if(r===o&&d[r][o]>4)return n;s=t[o-1],l=i===s?0:1,u=d[r-1][o]+1,(c=d[r][o-1]+1)<u&&(u=c),(c=d[r-1][o-1]+l)<u&&(u=c);let a=r>1&&o>1&&i===t[o-2]&&e[r-2]===s&&(c=d[r-2][o-2]+l)<u;d[r][o]=a?c:u}return d[n][a]}(e,t);let r=Math.max(e.length,t.length);return 1-(0===r?0:a/r)},Ct=/([\u0022\uFF02\u0027\u201C\u2018\u201F\u201B\u201E\u2E42\u201A\u00AB\u2039\u2035\u2036\u2037\u301D\u0060\u301F])/,jt=/([\u0022\uFF02\u0027\u201D\u2019\u00BB\u203A\u2032\u2033\u2034\u301E\u00B4])/,Nt=/^[-–—]$/,It=/ [-–—]{1,3} /,Dt=(e,t)=>-1!==e.post.indexOf(t),Ht={hasQuote:e=>Ct.test(e.pre)||jt.test(e.post),hasComma:e=>Dt(e,","),hasPeriod:e=>!0===Dt(e,".")&&!1===Dt(e,"..."),hasExclamation:e=>Dt(e,"!"),hasQuestionMark:e=>Dt(e,"?")||Dt(e,"¿"),hasEllipses:e=>Dt(e,"..")||Dt(e,"…"),hasSemicolon:e=>Dt(e,";"),hasColon:e=>Dt(e,":"),hasSlash:e=>/\//.test(e.text),hasHyphen:e=>Nt.test(e.post)||Nt.test(e.pre),hasDash:e=>It.test(e.post)||It.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)};Ht.hasQuotation=Ht.hasQuote;let Tt=function(){};Tt=function(e,t,n,a){let r=function(e,t,n,a){if(!0===t.anything)return!0;if(!0===t.start&&0!==n)return!1;if(!0===t.end&&n!==a-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 Ht[t.method]&&!0===Ht[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;let 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=>Tt(e,t,n,a))):t.choices.some((t=>Tt(e,t,n,a))))}(e,t,n,a);return!0===t.negative?!r:r};const Gt=function(e,t){if(!0===e.end&&!0===e.greedy&&t.start_i+t.t<t.phrase_length-1){let n=Object.assign({},e,{end:!1});if(!0===Tt(t.terms[t.t],n,t.start_i+t.t,t.phrase_length))return!0}return!1},xt=function(e,t){return e.groups[e.inGroup]||(e.groups[e.inGroup]={start:t,length:0}),e.groups[e.inGroup]},Et=function(e){let{regs:t}=e,n=t[e.r],a=function(e,t){let n=e.t;if(!t)return e.terms.length;for(;n<e.terms.length;n+=1)if(!0===Tt(e.terms[n],t,e.start_i+n,e.phrase_length))return n;return null}(e,t[e.r+1]);return null===a||0===a||void 0!==n.min&&a-e.t<n.min?null:void 0!==n.max&&a-e.t>n.max?(e.t=e.t+n.max,!0):(!0===e.hasGroup&&(xt(e,e.t).length=a-e.t),e.t=a,!0)},Ft=function(e,t=0){let n=e.regs[e.r],a=!1;for(let o=0;o<n.choices.length;o+=1){let i=n.choices[o];if(r=i,"[object Array]"!==Object.prototype.toString.call(r))return!1;if(a=i.every(((n,a)=>{let r=0,o=e.t+a+t+r;if(void 0===e.terms[o])return!1;let i=Tt(e.terms[o],n,o+e.start_i,e.phrase_length);if(!0===i&&!0===n.greedy)for(let t=1;t<e.terms.length;t+=1){let a=e.terms[o+t];if(a){if(!0!==Tt(a,n,e.start_i+t,e.phrase_length))break;r+=1}}return t+=r,i})),a){t+=i.length;break}}var r;return a&&!0===n.greedy?Ft(e,t):t},Ot=function(e){const{regs:t}=e;let n=t[e.r],a=Ft(e);if(a){if(!0===n.negative)return null;if(!0===e.hasGroup&&(xt(e,e.t).length+=a),!0===n.end){let t=e.phrase_length;if(e.t+e.start_i+a!==t)return null}return e.t+=a,!0}return!!n.optional||null},zt=function(e){const{regs:t}=e;let n=t[e.r],a=function(e){let t=0;return!0===e.regs[e.r].choices.every((n=>{let a=n.every(((t,n)=>{let a=e.t+n;return void 0!==e.terms[a]&&Tt(e.terms[a],t,a,e.phrase_length)}));return!0===a&&n.length>t&&(t=n.length),a}))&&t}(e);if(a){if(!0===n.negative)return null;if(!0===e.hasGroup&&(xt(e,e.t).length+=a),!0===n.end){let t=e.phrase_length-1;if(e.t+e.start_i!==t)return null}return e.t+=a,!0}return!!n.optional||null},Vt=function(e){const{regs:t}=e;let n=t[e.r],a=Object.assign({},n);if(a.negative=!1,Tt(e.terms[e.t],a,e.start_i+e.t,e.phrase_length))return!1;if(n.optional){let n=t[e.r+1];n&&(Tt(e.terms[e.t],n,e.start_i+e.t,e.phrase_length)?e.r+=1:n.optional&&t[e.r+2]&&Tt(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 a=0;for(let r=e.t;r<e.terms.length;r+=1){let o=Tt(e.terms[r],t,e.start_i+e.t,e.phrase_length);if(o)break;if(n&&(o=Tt(e.terms[r],n,e.start_i+e.t,e.phrase_length),o))break;if(a+=1,void 0!==t.max&&a===t.max)break}return!(0===a||t.min&&t.min>a||(e.t+=a,0))}(e,a,t[e.r+1]):(e.t+=1,!0)},Bt=function(e){const{regs:t,phrase_length:n}=e;let a=t[e.r];return e.t=function(e,t){let n=Object.assign({},e.regs[e.r],{start:!1,end:!1}),a=e.t;for(;e.t<e.terms.length;e.t+=1){if(t&&Tt(e.terms[e.t],t,e.start_i+e.t,e.phrase_length))return e.t;let r=e.t-a+1;if(void 0!==n.max&&r===n.max)return e.t;if(!1===Tt(e.terms[e.t],n,e.start_i+e.t,e.phrase_length))return void 0!==n.min&&r<n.min?null:e.t}return e.t}(e,t[e.r+1]),null===e.t||a.min&&a.min>e.t?null:!0!==a.end||e.start_i+e.t===n||null},St=function(e){const{regs:t}=e;let n=t[e.r],a=e.terms[e.t],r=e.t;return!!(n.optional&&t[e.r+1]&&n.negative)||(n.optional&&t[e.r+1]&&function(e){const{regs:t}=e;let n=t[e.r],a=e.terms[e.t],r=Tt(a,t[e.r+1],e.start_i+e.t,e.phrase_length);if(n.negative||r){let n=e.terms[e.t+1];n&&Tt(n,t[e.r+1],e.start_i+e.t,e.phrase_length)||(e.r+=1)}}(e),a.implicit&&e.terms[e.t+1]&&function(e){let 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?null:!0!==n.greedy||Bt(e)?(!0===e.hasGroup&&function(e,t){let n=e.regs[e.r];const a=xt(e,t);e.t>1&&n.greedy?a.length+=e.t-t:a.length++}(e,r),!0):null)},Kt=function(e,t,n,a){if(0===e.length||0===t.length)return null;let r={t:0,terms:e,r:0,regs:t,groups:{},start_i:n,phrase_length:a,inGroup:null};for(;r.r<t.length;r.r+=1){let e=t[r.r];if(r.hasGroup=Boolean(e.group),!0===r.hasGroup?r.inGroup=e.group:r.inGroup=null,!r.terms[r.t]){if(!1===t.slice(r.r).some((e=>!e.optional)))break;return null}if(!0!==e.anything||!0!==e.greedy){if(void 0===e.choices||"or"!==e.operator){if(void 0===e.choices||"and"!==e.operator)if(!0!==e.anything){if(!0!==Gt(e,r)){if(e.negative){if(!Vt(r))return null}else if(!0!==Tt(r.terms[r.t],e,r.start_i+r.t,r.phrase_length)){if(!0!==e.optional)return null}else if(!St(r))return null}else if(!St(r))return null}else{if(e.negative&&e.anything)return null;if(!St(r))return null}else if(!zt(r))return null}else if(!Ot(r))return null}else if(!Et(r))return null}let o=[null,n,r.t+n];if(o[1]===o[2])return null;let i={};return Object.keys(r.groups).forEach((e=>{let t=r.groups[e],a=n+t.start;i[e]=[null,a,a+t.length]})),{pointer:o,groups:i}},$t=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 a=Kt(e,t,0,e.length);return a?(a=$t(a,n),a):null},Mt={one:{termMethods:Ht,parseMatch:function(e,t,n){if(null==e||""===e)return[];t=t||{},"number"==typeof e&&(e=String(e));let a=function(e){let t=e.split(tt),n=[];t.forEach((e=>{rt(e)?n.push(e):n=n.concat(e.split(nt))})),n=ot(n);let a=[];return n.forEach((e=>{(e=>/^[![^]*(<[^<]*>)?\(/.test(e)&&/\)[?\]+*$~]*$/.test(e))(e)||rt(e)?a.push(e):a=a.concat(e.split(at))})),a=ot(a),a}(e);return a=a.map((e=>pt(e,t))),a=function(e,t){let n=t.model.one.prefixes;for(let t=e.length-1;t>=0;t-=1){let a=e[t];if(a.word&&ft.test(a.word)){let r=a.word.split(/[-–—]/g);if(n.hasOwnProperty(r[0]))continue;r=r.filter((e=>e)).reverse(),e.splice(t,1),r.forEach((n=>{let r=Object.assign({},a);r.word=n,e.splice(t,0,r)}))}}return e}(a,n),a=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(yt(e,t)):"Adjective"===e.pos&&(n=n.concat(vt(e,t))):(n=n.concat(bt(e,t)),n=n.concat(yt(e,t)),n=n.concat(vt(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}))}(a,n),a=wt(a),a},match:function(e,t,n){n=n||[];let{regs:a,group:r,justOne:o}=t,i=[];if(!a||0===a.length)return{ptrs:[],byGroup:{}};const s=a.filter((e=>!0!==e.optional&&!0!==e.negative)).length;e:for(let t=0;t<e.length;t+=1){let r=e[t];if(!n[t]||!Pt(a,n[t]))if(!0!==a[0].start)for(let e=0;e<r.length;e+=1){let n=r.slice(e);if(n.length<s)break;let l=Kt(n,a,e,r.length);if(l){if(l=$t(l,t),i.push(l),!0===o)break e;let n=l.pointer[2];Math.abs(n-1)>e&&(e=Math.abs(n-1))}}else{let e=Lt(r,a,t);e&&i.push(e)}}return!0===a[a.length-1].end&&(i=i.filter((t=>{let n=t.pointer[0];return e[n].length===t.pointer[2]}))),t.notIf&&(i=function(e,t,n){return e=e.filter((e=>{let[a,r,o]=e.pointer,i=n[a].slice(r,o);for(let e=0;e<i.length;e+=1){let n=i.slice(e);if(null!==Kt(n,t,e,i.length))return!1}return!0})),e}(i,t.notIf,e)),i=function(e,t){let n=[],a={};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=>{a[t]=a[t]||[],a[t].push(e.groups[t])}))}))),{ptrs:n,byGroup:a}}(i,r),i.ptrs.forEach((t=>{let[n,a,r]=t;t[3]=e[n][a].id,t[4]=e[n][r-1].id})),i}}};var Jt={api:function(e){Object.assign(e.prototype,et)},methods:Mt,lib:{parseMatch:function(e,t){const n=this.world();let a=n.methods.one.killUnicode;return a&&(e=a(e,n)),n.methods.one.parseMatch(e,t,n)}}};const Wt=/^\../,Ut=/^#./,qt=function(e,t){let n={},a={};return Object.keys(t).forEach((r=>{let o=t[r],i=function(e){let t="",n="</span>";return e=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Wt.test(e)?t=`<span class="${e.replace(/^\./,"")}"`:Ut.test(e)?t=`<span id="${e.replace(/^#/,"")}"`:(t=`<${e}`,n=`</${e}>`),t+=">",{start:t,end:n}}(r);"string"==typeof o&&(o=e.match(o)),o.docs.forEach((e=>{if(e.every((e=>e.implicit)))return;let t=e[0].id;n[t]=n[t]||[],n[t].push(i.start);let r=e[e.length-1].id;a[r]=a[r]||[],a[r].push(i.end)}))})),{starts:n,ends:a}};var Rt={html:function(e){let{starts:t,ends:n}=qt(this,e),a="";return this.docs.forEach((e=>{for(let r=0;r<e.length;r+=1){let o=e[r];t.hasOwnProperty(o.id)&&(a+=t[o.id].join("")),a+=o.pre||"",a+=o.text||"",n.hasOwnProperty(o.id)&&(a+=n[o.id].join("")),a+=o.post||""}})),a}};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]+/,Xt=/[,:;)('"\u201D\]]/,_t=/^[-–—]$/,Yt=/ /,en=function(e,t,n=!0){let a="";return e.forEach((e=>{let n=e.pre||"",r=e.post||"";"some"===t.punctuation&&(n=n.replace(Zt,""),_t.test(r)&&(r=" "),r=r.replace(Xt,""),r=r.replace(/\?!+/,"?"),r=r.replace(/!+/,"!"),r=r.replace(/\?+/,"?"),r=r.replace(/\.{2,}/,""),e.tags.has("Abbreviation")&&(r=r.replace(/\./,""))),"some"===t.whitespace&&(n=n.replace(/\s/,""),r=r.replace(/\s+/," ")),t.keepPunct||(n=n.replace(Zt,""),r="-"===r?" ":r.replace(Qt,""));let o=e[t.form||"text"]||e.normal||"";"implicit"===t.form&&(o=e.implicit||e.text),"root"===t.form&&e.implicit&&(o=e.root||e.implicit||e.normal),"machine"!==t.form&&"implicit"!==t.form&&"root"!==t.form||!e.implicit||r&&Yt.test(r)||(r+=" "),a+=n+o+r})),!1===n&&(a=a.trim()),!0===t.lowerCase&&(a=a.toLowerCase()),a},tn={text:{form:"text"},normal:{whitespace:"some",punctuation:"some",case:"some",unicode:"some",form:"normal"},machine:{keepSpace:!1,whitespace:"some",punctuation:"some",case:"none",unicode:"some",form:"machine"},root:{keepSpace:!1,whitespace:"some",punctuation:"some",case:"some",unicode:"so