forked from spencermountain/compromise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompromise-tokenize.js
1 lines (1 loc) · 83.7 KB
/
compromise-tokenize.js
1
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).nlp=e()}(this,(function(){"use strict";const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split("");var e=function(e){let r=(e=e||"_")+"-";for(let e=0;e<7;e++)r+=t[Math.floor(Math.random()*t.length)];return r};let r={"!":"¡","?":"¿Ɂ",'"':'“”"❝❞',"'":"‘‛❛❜","-":"—–",a:"ªÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻȀȁȂȃȦȧȺΆΑΔΛάαλАадѦѧӐӑӒӓƛɅæ",b:"ßþƀƁƂƃƄƅɃΒβϐϦБВЪЬвъьѢѣҌҍ",c:"¢©ÇçĆćĈĉĊċČčƆƇƈȻȼͻͼͽϲϹϽϾСсєҀҁҪҫ",d:"ÐĎďĐđƉƊȡƋƌǷ",e:"ÈÉÊËèéêëĒēĔĕĖėĘęĚěƎƏƐǝȄȅȆȇȨȩɆɇΈΕΞΣέεξϱϵ϶ЀЁЕЭеѐёҼҽҾҿӖӗӘәӚӛӬӭ",f:"ƑƒϜϝӺӻҒғſ",g:"ĜĝĞğĠġĢģƓǤǥǦǧǴǵ",h:"ĤĥĦħƕǶȞȟΉΗЂЊЋНнђћҢңҤҥҺһӉӊ",I:"ÌÍÎÏ",i:"ìíîïĨĩĪīĬĭĮįİıƖƗȈȉȊȋΊΐΪίιϊІЇії",j:"ĴĵǰȷɈɉϳЈј",k:"ĶķĸƘƙǨǩΚκЌЖКжкќҚқҜҝҞҟҠҡ",l:"ĹĺĻļĽľĿŀŁłƚƪǀǏǐȴȽΙӀӏ",m:"ΜϺϻМмӍӎ",n:"ÑñŃńŅņŇňʼnŊŋƝƞǸǹȠȵΝΠήηϞЍИЙЛПийлпѝҊҋӅӆӢӣӤӥπ",o:"ÒÓÔÕÖØðòóôõöøŌōŎŏŐőƟƠơǑǒǪǫǬǭǾǿȌȍȎȏȪȫȬȭȮȯȰȱΌΘΟθοσόϕϘϙϬϭϴОФоѲѳӦӧӨөӪӫ",p:"ƤƿΡρϷϸϼРрҎҏÞ",q:"Ɋɋ",r:"ŔŕŖŗŘřƦȐȑȒȓɌɍЃГЯгяѓҐґ",s:"ŚśŜŝŞşŠšƧƨȘșȿЅѕ",t:"ŢţŤťŦŧƫƬƭƮȚțȶȾΓΤτϮТт",u:"µÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưƱƲǓǔǕǖǗǘǙǚǛǜȔȕȖȗɄΰμυϋύ",v:"νѴѵѶѷ",w:"ŴŵƜωώϖϢϣШЩшщѡѿ",x:"×ΧχϗϰХхҲҳӼӽӾӿ",y:"ÝýÿŶŷŸƳƴȲȳɎɏΎΥΫγψϒϓϔЎУучўѰѱҮүҰұӮӯӰӱӲӳ",z:"ŹźŻżŽžƩƵƶȤȥɀΖζ"},n={};Object.keys(r).forEach((function(t){r[t].split("").forEach((function(e){n[e]=t}))}));var i=t=>{let e=t.split("");return e.forEach((t,r)=>{n[t]&&(e[r]=n[t])}),e.join("")};const s=/([A-Z]\.)+[A-Z]?,?$/,o=/^[A-Z]\.,?$/,l=/[A-Z]{2,}('s|,)?$/,a=/([a-z]\.)+[a-z]\.?$/;var u=function(t){return!0===s.test(t)||(!0===a.test(t)||(!0===o.test(t)||!0===l.test(t)))};const c=i,h=u,f=/[a-z\u00C0-\u00FF] ?\/ ?[a-z\u00C0-\u00FF]/;const p=function(t){let e=t=(t=(t=t||"").toLowerCase()).trim();return t=c(t),!0===f.test(t)&&(t=t.replace(/\/.*/,"")),t=(t=(t=(t=(t=(t=(t=t.replace(/^[#@]/,"")).replace(/[,;.!?]+$/,"")).replace(/[\u0027\u0060\u00B4\u2018\u2019\u201A\u201B\u2032\u2035\u2039\u203A]+/g,"'")).replace(/[\u0022\u00AB\u00BB\u201C\u201D\u201E\u201F\u2033\u2034\u2036\u2037\u2E42\u301D\u301E\u301F\uFF02]+/g,'"')).replace(/\u2026/g,"...")).replace(/\u2013/g,"-")).replace(/([aeiou][ktrp])in$/,"$1ing"),!0===/^(re|un)-?[^aeiou]./.test(t)&&(t=t.replace("-","")),h(t)&&(t=t.replace(/\./g,"")),!1===/^[:;]/.test(t)&&(t=(t=(t=t.replace(/\.{3,}$/g,"")).replace(/[",\.!:;\?\)]+$/g,"")).replace(/^['"\(]+/g,"")),""===(t=(t=t.replace(/[\u200B-\u200D\uFEFF]/g,"")).trim())&&(t=e),t=t.replace(/([0-9]),([0-9])/g,"$1$2")},d=function(t){return t=(t=t.replace(/['’]s$/,"")).replace(/s['’]$/,"s")},m=/^[ \n\t\.\[\](){}⟨⟩:,،、‒–—―…!‹›«»‐\-?‘’;\/⁄·&*•^†‡°¡¿※№÷׺ª%‰+−=‱¶′″‴§~\|‖¦©℗®℠™¤₳฿\u0022\uFF02\u0027\u201C\u201F\u201B\u201E\u2E42\u201A\u2035\u2036\u2037\u301D\u0060\u301F]+/,g=/[ \n\t\.'\[\](){}⟨⟩:,،、‒–—―…!‹›«»‐\-?‘’;\/⁄·&*@•^†‡°¡¿※#№÷׺ª‰+−=‱¶′″‴§~\|‖¦©℗®℠™¤₳฿\u0022\uFF02\u201D\u00B4\u301E]+$/,b=/\//,v=/['’]/,y=/^[a-z]\.([a-z]\.)+/i,A=/^[-+\.][0-9]/,w=/^'[0-9]{2}/;var x=t=>{let e=t,r="",n="";""===(t=(t=t.replace(m,e=>(r=e,"-"!==r&&"+"!==r&&"."!==r||!A.test(t)?"'"===r&&w.test(t)?(r="",e):"":(r="",e)))).replace(g,i=>(n=i,v.test(i)&&/[sn]['’]$/.test(e)&&!1===v.test(r)?(n=n.replace(v,""),"'"):!0===y.test(t)?(n=n.replace(/\./,""),"."):"")))&&(e=e.replace(/ *$/,t=>(n=t||"","")),t=e,r="",n=n);let i=p(t);const s={text:t,clean:i,reduced:d(i),pre:r,post:n};return b.test(t)&&t.split(b).forEach(t=>{s.alias=s.alias||{},s.alias[t.trim()]=!0}),s},P={};!function(t){const e=/^[A-Z][a-z'\u00C0-\u00FF]/,r=/^[A-Z]+s?$/;t.toUpperCase=function(){return this.text=this.text.toUpperCase(),this},t.toLowerCase=function(){return this.text=this.text.toLowerCase(),this},t.toTitleCase=function(){return this.text=this.text.replace(/^ *[a-z\u00C0-\u00FF]/,t=>t.toUpperCase()),this},t.isUpperCase=function(){return r.test(this.text)},t.isTitleCase=function(){return e.test(this.text)},t.titleCase=t.isTitleCase}(P);var j={};!function(t){const e=/(\u0022|\uFF02|\u0027|\u201C|\u2018|\u201F|\u201B|\u201E|\u2E42|\u201A|\u00AB|\u2039|\u2035|\u2036|\u2037|\u301D|\u0060|\u301F)/,r=/(\u0022|\uFF02|\u0027|\u201D|\u2019|\u201D|\u2019|\u201D|\u201D|\u2019|\u00BB|\u203A|\u2032|\u2033|\u2034|\u301E|\u00B4|\u301E)/;t.hasPost=function(t){return-1!==this.post.indexOf(t)},t.hasPre=function(t){return-1!==this.pre.indexOf(t)},t.hasQuote=function(){return e.test(this.pre)||r.test(this.post)},t.hasQuotation=t.hasQuote,t.hasComma=function(){return this.hasPost(",")},t.hasPeriod=function(){return!0===this.hasPost(".")&&!1===this.hasPost("...")},t.hasExclamation=function(){return this.hasPost("!")},t.hasQuestionMark=function(){return this.hasPost("?")||this.hasPost("¿")},t.hasEllipses=function(){return this.hasPost("..")||this.hasPost("…")||this.hasPre("..")||this.hasPre("…")},t.hasSemicolon=function(){return this.hasPost(";")},t.hasSlash=function(){return/\//.test(this.text)},t.hasHyphen=function(){const t=/^(-|–|—)$/;return t.test(this.post)||t.test(this.pre)},t.hasDash=function(){const t=/ (-|–|—) /;return t.test(this.post)||t.test(this.pre)},t.hasContraction=function(){return Boolean(this.implicit)},t.addPunctuation=function(t){return","!==t&&";"!==t||(this.post=this.post.replace(t,"")),this.post=t+this.post,this}}(j);var E={};const O=function(t,e,r=3){if(t===e)return 1;if(t.length<r||e.length<r)return 0;const n=function(t,e){let r=t.length,n=e.length;if(0===r)return n;if(0===n)return r;let i=(n>r?n:r)+1;if(Math.abs(r-n)>(i||100))return i||100;let s,o,l,a,u,c,h=[];for(let t=0;t<i;t++)h[t]=[t],h[t].length=i;for(let t=0;t<i;t++)h[0][t]=t;for(let i=1;i<=r;++i)for(o=t[i-1],s=1;s<=n;++s){if(i===s&&h[i][s]>4)return r;l=e[s-1],a=o===l?0:1,u=h[i-1][s]+1,(c=h[i][s-1]+1)<u&&(u=c),(c=h[i-1][s-1]+a)<u&&(u=c);let n=i>1&&s>1&&o===e[s-2]&&t[i-2]===l&&(c=h[i-2][s-2]+a)<u;h[i][s]=n?c:u}return h[r][n]}(t,e);let i=Math.max(t.length,e.length);return 1-(0===i?0:n/i)};let C=function(){};C=function(t,e,r,n){let i=function(t,e,r,n){if(e.id===t.id)return!0;if(!0===e.anything)return!0;if(!0===e.start&&0!==r)return!1;if(!0===e.end&&r!==n-1)return!1;if(void 0!==e.word){if(null!==t.implicit&&t.implicit===e.word)return!0;if(void 0!==t.alias&&t.alias.hasOwnProperty(e.word))return!0;if(!0===e.soft&&e.word===t.root)return!0;if(void 0!==e.fuzzy){let r=O(e.word,t.reduced);if(r>e.fuzzy)return!0;if(!0===e.soft&&(r=O(e.word,t.root),r>e.fuzzy))return!0}return e.word===t.clean||e.word===t.text||e.word===t.reduced}return void 0!==e.tag?!0===t.tags[e.tag]:void 0!==e.method?"function"==typeof t[e.method]&&!0===t[e.method]():void 0!==e.regex?e.regex.test(t.clean):void 0!==e.fastOr?!(!t.implicit||!0!==e.fastOr.hasOwnProperty(t.implicit))||e.fastOr.hasOwnProperty(t.reduced)||e.fastOr.hasOwnProperty(t.text):void 0!==e.choices&&("and"===e.operator?e.choices.every(e=>C(t,e,r,n)):e.choices.some(e=>C(t,e,r,n)))}(t,e,r,n);return!0===e.negative?!i:i};const F=C,T=u,k={};E.doesMatch=function(t,e,r){return F(this,t,e,r)},E.isAcronym=function(){return T(this.text)},E.isImplicit=function(){return""===this.text&&Boolean(this.implicit)},E.isKnown=function(){return Object.keys(this.tags).some(t=>!0!==k[t])},E.setRoot=function(t){let e=t.transforms,r=this.implicit||this.clean;if(this.tags.Plural&&(r=e.toSingular(r,t)),this.tags.Verb&&!this.tags.Negative&&!this.tags.Infinitive){let n=null;this.tags.PastTense?n="PastTense":this.tags.Gerund?n="Gerund":this.tags.PresentTense?n="PresentTense":this.tags.Participle?n="Participle":this.tags.Actor&&(n="Actor"),r=e.toInfinitive(r,t,n)}this.root=r};var N={};const $=i,V=/[\s-]/,I=/^[A-Z-]+$/;N.textOut=function(t,e,r){t=t||{};let n=this.text,i=this.pre,s=this.post;return!0===t.reduced&&(n=this.reduced||""),!0===t.root&&(n=this.root||""),!0===t.implicit&&this.implicit&&(n=this.implicit||""),!0===t.normal&&(n=this.clean||this.text||""),!0===t.root&&(n=this.root||this.reduced||""),!0===t.unicode&&(n=$(n)),!0===t.titlecase&&(this.tags.ProperNoun&&!this.titleCase()||(this.tags.Acronym?n=n.toUpperCase():I.test(n)&&!this.tags.Acronym&&(n=n.toLowerCase()))),!0===t.lowercase&&(n=n.toLowerCase()),!0===t.acronyms&&this.tags.Acronym&&(n=n.replace(/\./g,"")),!0!==t.whitespace&&!0!==t.root||(i="",s=" ",!1!==V.test(this.post)&&!t.last||this.implicit||(s="")),!0!==t.punctuation||t.root||(!0===this.hasPost(".")?s="."+s:!0===this.hasPost("?")?s="?"+s:!0===this.hasPost("!")?s="!"+s:!0===this.hasPost(",")?s=","+s:!0===this.hasEllipses()&&(s="..."+s)),!0!==e&&(i=""),!0!==r&&(s=""),!0===t.abbreviations&&this.tags.Abbreviation&&(s=s.replace(/^\./,"")),i+n+s};var B={};const z={Auxiliary:1,Possessive:1};const S=function(t,e){let r=Object.keys(t.tags);const n=e.tags;return r=r.sort((t,e)=>z[e]||!n[e]?-1:n[e]?n[t]?n[t].lineage.length>n[e].lineage.length?1:n[t].isA.length>n[e].isA.length?-1:0:0:1),r},D={text:!0,tags:!0,implicit:!0,whitespace:!0,clean:!1,id:!1,index:!1,offset:!1,bestTag:!1};B.json=function(t,e){t=t||{};let r={};return(t=Object.assign({},D,t)).text&&(r.text=this.text),t.normal&&(r.normal=this.clean),t.tags&&(r.tags=Object.keys(this.tags)),t.clean&&(r.clean=this.clean),(t.id||t.offset)&&(r.id=this.id),t.implicit&&null!==this.implicit&&(r.implicit=this.implicit),t.whitespace&&(r.pre=this.pre,r.post=this.post),t.bestTag&&(r.bestTag=S(this,e)[0]),r};var M=Object.assign({},P,j,E,N,B),_={},G={};function L(){return"undefined"!=typeof window&&window.document}const q=function(t,e){for(t=t.toString();t.length<e;)t+=" ";return t};G.logTag=function(t,e,r){if(L())return void console.log("%c"+q(t.clean,3)+" + "+e+" ","color: #6accb2;");let n="[33m"+q(t.clean,15)+"[0m + [32m"+e+"[0m ";r&&(n=q(n,35)+" "+r),console.log(n)},G.logUntag=function(t,e,r){if(L())return void console.log("%c"+q(t.clean,3)+" - "+e+" ","color: #AB5850;");let n="[33m"+q(t.clean,3)+" [31m - #"+e+"[0m ";r&&(n=q(n,35)+" "+r),console.log(n)},G.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},G.titleCase=t=>t.charAt(0).toUpperCase()+t.substr(1);const W=G,U=function(t,e,r,n){let i=n.tags;if(""===e||"."===e||"-"===e)return;if("#"===e[0]&&(e=e.replace(/^#/,"")),e=W.titleCase(e),!0===t.tags[e])return;const s=n.isVerbose();!0===s&&W.logTag(t,e,r),t.tags[e]=!0,!0===i.hasOwnProperty(e)&&(i[e].isA.forEach(e=>{t.tags[e]=!0,!0===s&&W.logTag(t,"→ "+e)}),t.unTag(i[e].notA,"←",n))};const H=G,R=/^[a-z]/,Q=function(t,e,r,n){const i=n.isVerbose();if("*"===e)return t.tags={},t;var s;e=e.replace(/^#/,""),!0===R.test(e)&&(e=(s=e).charAt(0).toUpperCase()+s.substr(1)),!0===t.tags[e]&&(delete t.tags[e],!0===i&&H.logUntag(t,e,r));const o=n.tags;if(o[e]){let r=o[e].lineage;for(let e=0;e<r.length;e++)!0===t.tags[r[e]]&&(delete t.tags[r[e]],!0===i&&H.logUntag(t," - "+r[e]))}return t};const Z=function(t,e,r){const n=r.tags;if("#"===e[0]&&(e=e.replace(/^#/,"")),void 0===n[e])return!0;let i=n[e].notA||[];for(let e=0;e<i.length;e++)if(!0===t.tags[i[e]])return!1;return void 0===n[e].isA||Z(t,n[e].isA,r)};const J=function(t,e,r,n){if("string"!=typeof e)for(let i=0;i<e.length;i++)U(t,e[i],r,n);else U(t,e,r,n)},Y=function(t,e,r,n){if("string"!=typeof e&&e)for(let i=0;i<e.length;i++)Q(t,e[i],r,n);else Q(t,e,r,n)},K=Z;_.tag=function(t,e,r){return J(this,t,e,r),this},_.tagSafe=function(t,e,r){return K(this,t,r)&&J(this,t,e,r),this},_.unTag=function(t,e,r){return Y(this,t,e,r),this},_.canBe=function(t,e){return K(this,t,e)};const X=e,tt=x,et=M,rt=_;class nt{constructor(t=""){t=String(t);let e=tt(t);this.text=e.text||"",this.clean=e.clean,this.reduced=e.reduced,this.root=null,this.implicit=null,this.pre=e.pre||"",this.post=e.post||"",this.tags={},this.prev=null,this.next=null,this.id=X(e.clean),this.isA="Term",e.alias&&(this.alias=e.alias)}set(t){let e=tt(t);return this.text=e.text,this.clean=e.clean,this.reduced=e.reduced,this.root=null,this.implicit=null,this}}nt.prototype.clone=function(){let t=new nt(this.text);return t.pre=this.pre,t.post=this.post,t.clean=this.clean,t.reduced=this.reduced,t.root=this.root,t.implicit=this.implicit,t.tags=Object.assign({},this.tags),t},Object.assign(nt.prototype,et),Object.assign(nt.prototype,rt);var it=nt,st={terms:function(t){if(0===this.length)return[];if(this.cache.terms)return void 0!==t?this.cache.terms[t]:this.cache.terms;let e=[this.pool.get(this.start)];for(let r=0;r<this.length-1;r+=1){let n=e[e.length-1].next;if(null===n){console.error("Compromise error: Linked list broken in phrase '"+this.start+"'");break}let i=this.pool.get(n);if(e.push(i),void 0!==t&&t===r)return e[t]}return void 0===t&&(this.cache.terms=e),void 0!==t?e[t]:e},clone:function(t){if(t){let t=this.buildFrom(this.start,this.length);return t.cache=this.cache,t}let e=this.terms().map(t=>t.clone());return e.forEach((t,r)=>{this.pool.add(t),e[r+1]&&(t.next=e[r+1].id),e[r-1]&&(t.prev=e[r-1].id)}),this.buildFrom(e[0].id,e.length)},lastTerm:function(){let t=this.terms();return t[t.length-1]},hasId:function(t){if(0===this.length||!t)return!1;if(this.start===t)return!0;if(this.cache.terms){let e=this.cache.terms;for(let r=0;r<e.length;r++)if(e[r].id===t)return!0;return!1}let e=this.start;for(let r=0;r<this.length-1;r+=1){let r=this.pool.get(e);if(void 0===r)return console.error(`Compromise error: Linked list broken. Missing term '${e}' in phrase '${this.start}'\n`),!1;if(r.next===t)return!0;e=r.next}return!1},wordCount:function(){return this.terms().filter(t=>""!==t.text).length},fullSentence:function(){let t=this.terms(0);for(;t.prev;)t=this.pool.get(t.prev);let e=t.id,r=1;for(;t.next;)t=this.pool.get(t.next),r+=1;return this.buildFrom(e,r)}},ot={};ot.text=function(t={},e,r){"string"==typeof t&&(t="normal"===t?{whitespace:!0,unicode:!0,lowercase:!0,punctuation:!0,acronyms:!0,abbreviations:!0,implicit:!0,normal:!0}:"clean"===t?{titlecase:!1,lowercase:!0,punctuation:!0,whitespace:!0,unicode:!0,implicit:!0,normal:!0}:"reduced"===t?{punctuation:!1,titlecase:!1,lowercase:!0,whitespace:!0,unicode:!0,implicit:!0,reduced:!0}:"implicit"===t?{punctuation:!0,implicit:!0,whitespace:!0,trim:!0}:"root"===t?{titlecase:!1,lowercase:!0,punctuation:!0,whitespace:!0,unicode:!0,implicit:!0,root:!0}:{});let n=this.terms(),i=!1;n[0]&&null===n[0].prev&&null===n[n.length-1].next&&(i=!0);let s=n.reduce((s,o,l)=>{if(0===l&&""===o.text&&null!==o.implicit&&!t.implicit)return s;t.last=r&&l===n.length-1;let a=!0,u=!0;return!1===i&&(0===l&&e&&(a=!1),l===n.length-1&&r&&(u=!1)),s+o.textOut(t,a,u)},"");return!0===i&&r&&(s=s.replace(/ +$/,"")),!0===t.trim&&(s=s.trim()),s};var lt={trim:function(){let t=this.terms();if(t.length>0){t[0].pre=t[0].pre.replace(/^\s+/,"");let e=t[t.length-1];e.post=e.post.replace(/\s+$/,"")}return this}},at={};const ut=/[.?!]\s*$/,ct=function(t,e){e[0].pre=t[0].pre;let r=t[t.length-1],n=e[e.length-1];n.post=function(t,e){if(ut.test(e))return e+t.match(/\s*$/);return t}(r.post,n.post),r.post="",""===r.post&&(r.post+=" ")};const ht=/ /;const ft=function(t,e,r){let n=t.terms(),i=e.terms();ct(n,i),function(t,e,r){let n=t[t.length-1],i=e[e.length-1],s=n.next;n.next=e[0].id,i.next=s,s&&(r.get(s).prev=i.id);let o=t[0].id;o&&(e[0].prev=o)}(n,i,t.pool);let s=[t],o=t.start,l=[r];var a;return l=l.concat(r.parents()),l.forEach(t=>{let e=t.list.filter(t=>t.hasId(o));s=s.concat(e)}),s=(a=s).filter((t,e)=>a.indexOf(t)===e),s.forEach(t=>{t.length+=e.length}),t.cache={},t},pt=function(t,e,r){const n=t.start;let i=e.terms();!function(t){let e=t[t.length-1];!1===ht.test(e.post)&&(e.post+=" ")}(i),function(t,e,r){let n=r[r.length-1];n.next=t.start;let i=t.pool,s=i.get(t.start);s.prev&&(i.get(s.prev).next=e.start);r[0].prev=t.terms(0).prev,t.terms(0).prev=n.id}(t,e,i);let s=[t],o=[r];var l;return o=o.concat(r.parents()),o.forEach(t=>{let r=t.list.filter(t=>t.hasId(n)||t.hasId(e.start));s=s.concat(r)}),s=(l=s).filter((t,e)=>l.indexOf(t)===e),s.forEach(t=>{t.length+=e.length,t.start===n&&(t.start=e.start),t.cache={}}),t},dt=function(t,e){let r=e.pool(),n=t.terms(),i=r.get(n[0].prev)||{},s=r.get(n[n.length-1].next)||{};n[0].implicit&&i.implicit&&(i.set(i.implicit),i.post+=" "),function(t,e,r,n){let i=t.parents();i.push(t),i.forEach(t=>{let i=t.list.find(t=>t.hasId(e));i&&(i.length-=r,i.start===e&&(i.start=n.id),i.cache={})}),t.list=t.list.filter(t=>!(!t.start||!t.length))}(e,t.start,t.length,s),i&&(i.next=s.id),s&&(s.prev=i.id)};at.append=function(t,e){return ft(this,t,e),this},at.prepend=function(t,e){return pt(this,t,e),this},at.delete=function(t){return dt(this,t),this},at.replace=function(t,e){let r=this.length;ft(this,t,e);let n=this.buildFrom(this.start,this.length);n.length=r,dt(n,e)},at.splitOn=function(t){let e=this.terms(),r={before:null,match:null,after:null},n=e.findIndex(e=>e.id===t.start);if(-1===n)return r;let i=e.slice(0,n);i.length>0&&(r.before=this.buildFrom(i[0].id,i.length));let s=e.slice(n,n+t.length);s.length>0&&(r.match=this.buildFrom(s[0].id,s.length));let o=e.slice(n+t.length,e.length);return o.length>0&&(r.after=this.buildFrom(o[0].id,o.length,this.pool)),r};var mt={json:function(t={},e){let r={};return t.text&&(r.text=this.text()),t.normal&&(r.normal=this.text("normal")),t.clean&&(r.clean=this.text("clean")),t.reduced&&(r.reduced=this.text("reduced")),t.implicit&&(r.implicit=this.text("implicit")),t.root&&(r.root=this.text("root")),t.trim&&(r.text&&(r.text=r.text.trim()),r.normal&&(r.normal=r.normal.trim()),r.reduced&&(r.reduced=r.reduced.trim())),t.terms&&(!0===t.terms&&(t.terms={}),r.terms=this.terms().map(r=>r.json(t.terms,e))),r}},gt={lookAhead:function(t){t||(t=".*");let e=this.pool,r=[];const n=function(t){let i=e.get(t);i&&(r.push(i),i.prev&&n(i.next))};let i=this.terms(),s=i[i.length-1];return n(s.next),0===r.length?[]:this.buildFrom(r[0].id,r.length).match(t)},lookBehind:function(t){t||(t=".*");let e=this.pool,r=[];const n=function(t){let i=e.get(t);i&&(r.push(i),i.prev&&n(i.prev))};let i=e.get(this.start);return n(i.prev),0===r.length?[]:this.buildFrom(r[r.length-1].id,r.length).match(t)}},bt=Object.assign({},st,ot,lt,at,mt,gt),vt={};var yt=function(t,e){if(0===e.length)return!0;for(let t=0;t<e.length;t+=1){let r=e[t];if(!0!==r.optional&&!0!==r.negative&&!0===r.start&&t>0)return!0;if(!0===r.anything&&!0===r.negative)return!0}return!1},At={};!function(t){t.getGreedy=function(t,e){let r=Object.assign({},t.regs[t.r],{start:!1,end:!1}),n=t.t;for(;t.t<t.terms.length;t.t+=1){if(e&&t.terms[t.t].doesMatch(e,t.start_i+t.t,t.phrase_length))return t.t;let i=t.t-n+1;if(void 0!==r.max&&i===r.max)return t.t;if(!1===t.terms[t.t].doesMatch(r,t.start_i+t.t,t.phrase_length))return void 0!==r.min&&i<r.min?null:t.t}return t.t},t.greedyTo=function(t,e){let r=t.t;if(!e)return t.terms.length;for(;r<t.terms.length;r+=1)if(!0===t.terms[r].doesMatch(e,t.start_i+r,t.phrase_length))return r;return null},t.isEndGreedy=function(t,e){if(!0===t.end&&!0===t.greedy&&e.start_i+e.t<e.phrase_length-1){let r=Object.assign({},t,{end:!1});if(!0===e.terms[e.t].doesMatch(r,e.start_i+e.t,e.phrase_length))return!0}return!1},t.doOrBlock=function(e,r=0){let n=e.regs[e.r],i=!1;for(let t=0;t<n.choices.length;t+=1){let s=n.choices[t];if(i=s.every((t,n)=>{let i=0,s=e.t+n+r+i;if(void 0===e.terms[s])return!1;let o=e.terms[s].doesMatch(t,s+e.start_i,e.phrase_length);if(!0===o&&!0===t.greedy)for(let r=1;r<e.terms.length;r+=1){let n=e.terms[s+r];if(n){if(!0!==n.doesMatch(t,e.start_i+r,e.phrase_length))break;i+=1}}return r+=i,o}),i){r+=s.length;break}}return i&&!0===n.greedy?t.doOrBlock(e,r):r},t.doAndBlock=function(t){let e=0;return!0===t.regs[t.r].choices.every(r=>{let n=r.every((e,r)=>{let n=t.t+r;return void 0!==t.terms[n]&&t.terms[n].doesMatch(e,n,t.phrase_length)});return!0===n&&r.length>e&&(e=r.length),n})&&e},t.getGroup=function(t,e,r){if(t.groups[t.groupId])return t.groups[t.groupId];const n=t.terms[e].id;return t.groups[t.groupId]={group:String(r),start:n,length:0},t.groups[t.groupId]}}(At);const wt=e,xt=At;var Pt=function(t,e,r,n){let i={t:0,terms:t,r:0,regs:e,groups:{},start_i:r,phrase_length:n,hasGroup:!1,groupId:null,previousGroup:null};for(;i.r<e.length;i.r+=1){let t=e[i.r];if(i.hasGroup="string"==typeof t.named||"number"==typeof t.named,!0===i.hasGroup){const r=e[i.r-1];r&&r.named===t.named&&i.previousGroup?i.groupId=i.previousGroup:(i.groupId=wt(t.named),i.previousGroup=i.groupId)}if(!i.terms[i.t]){if(!1===e.slice(i.r).some(t=>!t.optional))break;return null}if(!0===t.anything&&!0===t.greedy){let r=xt.greedyTo(i,e[i.r+1]);if(null===r||0===r)return null;if(void 0!==t.min&&r-i.t<t.min)return null;if(void 0!==t.max&&r-i.t>t.max){i.t=i.t+t.max;continue}if(!0===i.hasGroup){xt.getGroup(i,i.t,t.named).length=r-i.t}i.t=r;continue}if(void 0!==t.choices&&"or"===t.operator){let e=xt.doOrBlock(i);if(e){if(!0===t.negative)return null;if(!0===i.hasGroup){xt.getGroup(i,i.t,t.named).length+=e}i.t+=e;continue}if(!t.optional)return null}if(void 0!==t.choices&&"and"===t.operator){let e=xt.doAndBlock(i);if(e){if(!0===t.negative)return null;if(!0===i.hasGroup){xt.getGroup(i,i.t,t.named).length+=e}i.t+=e;continue}if(!t.optional)return null}let r=i.terms[i.t],s=r.doesMatch(t,i.start_i+i.t,i.phrase_length);if(!0===t.anything||!0===s||xt.isEndGreedy(t,i)){let s=i.t;if(t.optional&&e[i.r+1]&&t.negative)continue;if(t.optional&&e[i.r+1]){let n=r.doesMatch(e[i.r+1],i.start_i+i.t,i.phrase_length);if(t.negative||n){let t=i.terms[i.t+1];t&&t.doesMatch(e[i.r+1],i.start_i+i.t,i.phrase_length)||(i.r+=1)}}if(i.t+=1,!0===t.end&&i.t!==i.terms.length&&!0!==t.greedy)return null;if(!0===t.greedy){if(i.t=xt.getGreedy(i,e[i.r+1]),null===i.t)return null;if(t.min&&t.min>i.t)return null;if(!0===t.end&&i.start_i+i.t!==n)return null}if(!0===i.hasGroup){const e=xt.getGroup(i,s,t.named);i.t>1&&t.greedy?e.length+=i.t-s:e.length++}}else{if(t.negative){let e=Object.assign({},t);if(e.negative=!1,!0===i.terms[i.t].doesMatch(e,i.start_i+i.t,i.phrase_length))return null}if(!0!==t.optional){if(i.terms[i.t].isImplicit()&&e[i.r-1]&&i.terms[i.t+1]){if(i.terms[i.t-1]&&i.terms[i.t-1].implicit===e[i.r-1].word)return null;if(i.terms[i.t+1].doesMatch(t,i.start_i+i.t,i.phrase_length)){i.t+=2;continue}}return null}}}return{match:i.terms.slice(0,i.t),groups:i.groups}};var jt=function(t,e,r){if(!r||0===r.length)return r;if(e.some(t=>t.end)){let e=t[t.length-1];r=r.filter(({match:t})=>-1!==t.indexOf(e))}return r};const Et=/(?:^|\s)([\!\[\^]*(?:<[^<]*>)?\/.*?[^\\\/]\/[\?\]\+\*\$~]*)(?:\s|$)/,Ot=/([\!\[\^]*(?:<[^<]*>)?\([^\)]+[^\\\)]\)[\?\]\+\*\$~]*)(?:\s|$)/,Ct=/ /g,Ft=t=>/^[\!\[\^]*(<[^<]*>)?\//.test(t)&&/\/[\?\]\+\*\$~]*$/.test(t),Tt=function(t){return t=(t=t.map(t=>t.trim())).filter(t=>t)};var kt=function(t){let e=t.split(Et),r=[];e.forEach(t=>{Ft(t)?r.push(t):r=r.concat(t.split(Ot))}),r=Tt(r);let n=[];return r.forEach(t=>{(t=>/^[\!\[\^]*(<[^<]*>)?\(/.test(t)&&/\)[\?\]\+\*\$~]*$/.test(t))(t)||Ft(t)?n.push(t):n=n.concat(t.split(Ct))}),n=Tt(n),n};const Nt=/\{([0-9]+,?[0-9]*)\}/,$t=/&&/,Vt=new RegExp(/^<\s*?(\S+)\s*?>/),It=function(t){return t[t.length-1]},Bt=function(t){return t[0]},zt=function(t){return t.substr(1)},St=function(t){return t.substr(0,t.length-1)},Dt=function(t){return t=zt(t),t=St(t)},Mt=function(t){let e={};for(let r=0;r<2;r+=1){if("$"===It(t)&&(e.end=!0,t=St(t)),"^"===Bt(t)&&(e.start=!0,t=zt(t)),("["===Bt(t)||"]"===It(t))&&(e.named=!0,"["===Bt(t)?e.groupType="]"===It(t)?"single":"start":e.groupType="end",t=(t=t.replace(/^\[/,"")).replace(/\]$/,""),"<"===Bt(t))){const r=Vt.exec(t);r.length>=2&&(e.named=r[1],t=t.replace(r[0],""))}if("+"===It(t)&&(e.greedy=!0,t=St(t)),"*"!==t&&"*"===It(t)&&"\\*"!==t&&(e.greedy=!0,t=St(t)),"?"===It(t)&&(e.optional=!0,t=St(t)),"!"===Bt(t)&&(e.negative=!0,t=zt(t)),"("===Bt(t)&&")"===It(t)){$t.test(t)?(e.choices=t.split($t),e.operator="and"):(e.choices=t.split("|"),e.operator="or"),e.choices[0]=zt(e.choices[0]);let r=e.choices.length-1;e.choices[r]=St(e.choices[r]),e.choices=e.choices.map(t=>t.trim()),e.choices=e.choices.filter(t=>t),e.choices=e.choices.map(t=>t.split(/ /g).map(Mt)),t=""}if("/"===Bt(t)&&"/"===It(t))return t=Dt(t),e.regex=new RegExp(t),e;if("~"===Bt(t)&&"~"===It(t))return t=Dt(t),e.soft=!0,e.word=t,e}return!0===Nt.test(t)&&(t=t.replace(Nt,(t,r)=>{let n=r.split(/,/g);return 1===n.length?(e.min=Number(n[0]),e.max=Number(n[0])):(e.min=Number(n[0]),e.max=Number(n[1]||999)),e.greedy=!0,e.optional=!0,""})),"#"===Bt(t)?(e.tag=zt(t),e.tag=(r=e.tag).charAt(0).toUpperCase()+r.substr(1),e):"@"===Bt(t)?(e.method=zt(t),e):"."===t?(e.anything=!0,e):"*"===t?(e.anything=!0,e.greedy=!0,e.optional=!0,e):(t&&(t=(t=t.replace("\\*","*")).replace("\\.","."),e.word=t.toLowerCase()),e);var r};const _t=kt,Gt=Mt,Lt=function(t,e={}){return t.filter(t=>t.groupType).length>0&&(t=function(t){let e,r=!1,n=-1;for(let i=0;i<t.length;i++){const s=t[i];"single"!==s.groupType||!0!==s.named?("start"===s.groupType&&(r=!0,"string"==typeof s.named||"number"==typeof s.named?e=s.named:(n+=1,e=n)),r&&(s.named=e),"end"===s.groupType&&(r=!1)):(n+=1,s.named=n)}return t}(t)),e.fuzzy||(t=function(t){return t.map(t=>{if(void 0!==t.choices&&!0===t.choices.every(t=>{if(1!==t.length)return!1;let e=t[0];return void 0!==e.word&&!0!==e.negative&&!0!==e.optional&&!0!==e.method})){let e={};t.choices.forEach(t=>{e[t[0].word]=!0}),t.fastOr=e,delete t.choices}return t})}(t)),t};var qt=function(t,e={}){if(null==t||""===t)return[];if("object"==typeof t){if(function(t){return"[object Array]"===Object.prototype.toString.call(t)}(t)){if(0===t.length||!t[0])return[];if("object"==typeof t[0])return t;if("string"==typeof t[0])return function(t){return[{choices:t.map(t=>[{word:t}]),operator:"or"}]}(t)}return t&&"Doc"===t.isA?function(t){if(!t||!t.list||!t.list[0])return[];let e=[];return t.list.forEach(t=>{let r=[];t.terms().forEach(t=>{r.push(t.id)}),e.push(r)}),[{idBlocks:e}]}(t):[]}"number"==typeof t&&(t=String(t));let r=_t(t);return r=r.map(t=>Gt(t)),r=Lt(r,e),r=function(t,e){return!0===e.fuzzy&&(e.fuzzy=.85),"number"==typeof e.fuzzy&&(t=t.map(t=>(e.fuzzy>0&&t.word&&(t.fuzzy=e.fuzzy),t.choices&&t.choices.forEach(t=>{t.forEach(t=>{t.fuzzy=e.fuzzy})}),t))),t}(r,e),r};const Wt=yt,Ut=Pt,Ht=jt,Rt=qt,Qt=function(t,e){let r=[],n=e[0].idBlocks;for(let e=0;e<t.length;e+=1)n.forEach(n=>{if(0===n.length)return;n.every((r,n)=>t[e+n].id===r)&&(r.push({match:t.slice(e,e+n.length)}),e+=n.length-1)});return r};var Zt=function(t,e,r=!1){if("string"==typeof e&&(e=Rt(e)),!0===Wt(t,e))return[];const n=e.filter(t=>!0!==t.optional&&!0!==t.negative).length;let i=t.terms(),s=[];if(e[0].idBlocks){let t=Qt(i,e);if(t&&t.length>0)return Ht(i,e,t)}if(!0===e[0].start){let t=Ut(i,e,0,i.length);return t&&t.match&&t.match.length>0&&(t.match=t.match.filter(t=>t),s.push(t)),Ht(i,e,s)}for(let t=0;t<i.length&&!(t+n>i.length);t+=1){let n=Ut(i.slice(t),e,t,i.length);if(n&&n.match&&n.match.length>0&&(t+=n.match.length-1,n.match=n.match.filter(t=>t),s.push(n),!0===r))return Ht(i,e,s)}return Ht(i,e,s)};const Jt=Zt;const Yt=Zt,Kt=function(t,e){let r={};Jt(t,e).forEach(({match:t})=>{t.forEach(t=>{r[t.id]=!0})});let n=t.terms(),i=[],s=[];return n.forEach(t=>{!0!==r[t.id]?s.push(t):s.length>0&&(i.push(s),s=[])}),s.length>0&&i.push(s),i};vt.match=function(t,e=!1){let r=Yt(this,t,e);return r=r.map(({match:t,groups:e})=>{let r=this.buildFrom(t[0].id,t.length,e);return r.cache.terms=t,r}),r},vt.has=function(t){return Yt(this,t,!0).length>0},vt.not=function(t){let e=Kt(this,t);return e=e.map(t=>this.buildFrom(t[0].id,t.length)),e},vt.canBe=function(t,e){let r=[],n=this.terms(),i=!1;for(let s=0;s<n.length;s+=1){let o=n[s].canBe(t,e);!0===o&&(!0===i?r[r.length-1].push(n[s]):r.push([n[s]]),i=o)}return r=r.filter(t=>t.length>0).map(t=>this.buildFrom(t[0].id,t.length)),r};const Xt=bt,te=vt;class ee{constructor(t,e,r){this.start=t,this.length=e,this.isA="Phrase",Object.defineProperty(this,"pool",{enumerable:!1,writable:!0,value:r}),Object.defineProperty(this,"cache",{enumerable:!1,writable:!0,value:{}}),Object.defineProperty(this,"groups",{enumerable:!1,writable:!0,value:{}})}}ee.prototype.buildFrom=function(t,e,r){let n=new ee(t,e,this.pool);return r&&Object.keys(r).length>0?n.groups=r:n.groups=this.groups,n},Object.assign(ee.prototype,te),Object.assign(ee.prototype,Xt);const re={term:"terms"};Object.keys(re).forEach(t=>ee.prototype[t]=ee.prototype[re[t]]);var ne=ee;class ie{constructor(t={}){Object.defineProperty(this,"words",{enumerable:!1,value:t})}add(t){return this.words[t.id]=t,this}get(t){return this.words[t]}remove(t){delete this.words[t]}merge(t){return Object.assign(this.words,t.words),this}stats(){return{words:Object.keys(this.words).length}}}ie.prototype.clone=function(){let t=Object.keys(this.words).reduce((t,e)=>{let r=this.words[e].clone();return t[r.id]=r,t},{});return new ie(t)};var se=ie;var oe=t=>{t.forEach((e,r)=>{r>0&&(e.prev=t[r-1].id),t[r+1]&&(e.next=t[r+1].id)})};const le=/(\S.+?[.!?\u203D\u2E18\u203C\u2047-\u2049])(?=\s+|$)/g,ae=/\S/,ue=/[ .][A-Z]\.? *$/i,ce=/(?:\u2026|\.{2,}) *$/,he=/((?:\r?\n|\r)+)/,fe=/[a-z0-9\u00C0-\u00FF\u00a9\u00ae\u2000-\u3300\ud000-\udfff]/i,pe=/^\s+/,de=function(t,e,r,n){if(n.hasLetter=function(t,e){return e||fe.test(t)}(e,n.hasLetter),!n.hasLetter)return!1;if(function(t,e){return-1!==e.indexOf(".")&&ue.test(t)}(t,e))return!1;if(function(t,e){return-1!==e.indexOf(".")&&ce.test(t)}(t,e))return!1;let i=t.replace(/[.!?\u203D\u2E18\u203C\u2047-\u2049] *$/,"").split(" "),s=i[i.length-1].toLowerCase();return!r.hasOwnProperty(s)};var me=function(t,e){let r=e.cache.abbreviations;t=t||"";let n=[],i=[];if(!(t=String(t))||"string"!=typeof t||!1===ae.test(t))return n;let s=function(t){let e=[],r=t.split(he);for(let t=0;t<r.length;t++){let n=r[t].split(le);for(let t=0;t<n.length;t++)e.push(n[t])}return e}(t=t.replace(" "," "));for(let t=0;t<s.length;t++){let e=s[t];if(void 0!==e&&""!==e){if(!1===ae.test(e)){if(i[i.length-1]){i[i.length-1]+=e;continue}if(s[t+1]){s[t+1]=e+s[t+1];continue}}i.push(e)}}let o=i[0]||"";const l={hasLetter:!1};for(let t=0;t<i.length;t++){let e=i[t];i[t+1]&&!1===de(e,o,r,l)?(o=i[t+1]||"",i[t+1]=e+o):e&&e.length>0&&(n.push(e),o=i[t+1]||"",l.hasLetter=!1),i[t]=""}if(0===n.length)return[t];for(let t=1;t<n.length;t+=1){let e=n[t].match(pe);null!==e&&(n[t-1]+=e[0],n[t]=n[t].replace(pe,""))}return n};const ge=/\S/,be=/^[!?.]+$/,ve=/(\S+)/,ye=/[a-z] ?\/ ?[a-z]*$/;let Ae=[".","?","!",":",";","-","–","—","--","...","(",")","[","]",'"',"'","`"];Ae=Ae.reduce((t,e)=>(t[e]=!0,t),{});const we=function(t){if(!0===/^(re|un|micro|macro|trans|bi|mono|over)-?[^aeiou]./.test(t))return!1;if(!0===/^([a-z\u00C0-\u00FF/]+)(-|–|—)(like|ish|less|able)/i.test(t))return!1;if(!0===/^([a-z\u00C0-\u00FF`"'/]+)(-|–|—)([a-z0-9\u00C0-\u00FF].*)/i.test(t))return!0;return!0===/^([0-9]{1,4})(-|–|—)([a-z\u00C0-\u00FF`"'/-]+$)/i.test(t)},xe=function(t){let e=[];const r=t.split(/[-–—]/);let n="-",i=t.match(/[-–—]/);i&&i[0]&&(n=i);for(let t=0;t<r.length;t++)t===r.length-1?e.push(r[t]):e.push(r[t]+n);return e};const Pe=it,je=ne,Ee=se,Oe=oe,Ce=me,Fe=function(t){let e=[],r=[];if("number"==typeof(t=t||"")&&(t=String(t)),function(t){return"[object Array]"===Object.prototype.toString.call(t)}(t))return t;const n=t.split(ve);for(let t=0;t<n.length;t++)!0!==we(n[t])?r.push(n[t]):r=r.concat(xe(n[t]));let i="";for(let t=0;t<r.length;t++){let n=r[t];!0===ge.test(n)&&!1===Ae.hasOwnProperty(n)&&!1===be.test(n)?(e.length>0?(e[e.length-1]+=i,e.push(n)):e.push(i+n),i=""):i+=n}return i&&(0===e.length&&(e[0]=""),e[e.length-1]+=i),e=function(t){for(let e=1;e<t.length-1;e++)ye.test(t[e])&&(t[e-1]+=t[e]+t[e+1],t[e]=null,t[e+1]=null);return t}(e),e=function(t){const e=/^[0-9]{1,4}(:[0-9][0-9])?([a-z]{1,2})? ?(-|–|—) ?$/,r=/^[0-9]{1,4}([a-z]{1,2})? ?$/;for(let n=0;n<t.length-1;n+=1)t[n+1]&&e.test(t[n])&&r.test(t[n+1])&&(t[n]=t[n]+t[n+1],t[n+1]=null);return t}(e),e=e.filter(t=>t),e};var Te=function(t="",e,r){let n=null;return"string"!=typeof t&&("number"==typeof t?t=String(t):function(t){return"[object Array]"===Object.prototype.toString.call(t)}(t)&&(n=t)),n=n||Ce(t,e),n=n.map(t=>Fe(t)),r=r||new Ee,n.map(t=>{t=t.map(t=>{let e=new Pe(t);return r.add(e),e}),Oe(t);let e=new je(t[0].id,t.length,r);return e.cache.terms=t,e})};const ke=it,Ne=ne,$e=se,Ve=oe;var Ie=function(t,e){let r=new $e;return t.map((t,n)=>{let i=t.terms.map((i,s)=>{let o=new ke(i.text);return o.pre=void 0!==i.pre?i.pre:"",void 0===i.post&&(i.post=" ",s>=t.terms.length-1&&(i.post=". ",n>=t.terms.length-1&&(i.post="."))),o.post=void 0!==i.post?i.post:" ",i.tags&&i.tags.forEach(t=>o.tag(t,"",e)),r.add(o),o});return Ve(i),new Ne(i[0].id,i.length,r)})};const Be=["Person","Place","Organization"];const ze=["Noun","Verb","Adjective","Adverb","Value","QuestionWord"];const Se={Noun:"blue",Verb:"green",Negative:"green",Date:"red",Value:"red",Adjective:"magenta",Preposition:"cyan",Conjunction:"cyan",Determiner:"cyan",Adverb:"cyan"};const De=function(t){return Object.keys(t).forEach(e=>{t[e].color?t[e].color=t[e].color:Se[e]?t[e].color=Se[e]:t[e].isA.some(r=>!!Se[r]&&(t[e].color=Se[r],!0))}),t},Me=function(t){return Object.keys(t).forEach(e=>{let r=t[e],n=r.isA.length;for(let e=0;e<n;e++){let n=r.isA[e];t[n]&&(r.isA=r.isA.concat(t[n].isA))}r.isA=function(t){return t.filter((t,e,r)=>r.indexOf(t)===e)}(r.isA)}),t},_e=function(t){let e=Object.keys(t);return e.forEach(r=>{let n=t[r];n.notA=n.notA||[],n.isA.forEach(e=>{if(t[e]&&t[e].notA){let r="string"==typeof t[e].notA?[t[e].isA]:t[e].notA||[];n.notA=n.notA.concat(r)}});for(let i=0;i<e.length;i++){const s=e[i];-1!==t[s].notA.indexOf(r)&&n.notA.push(s)}n.notA=function(t){return t.filter((t,e,r)=>r.indexOf(t)===e)}(n.notA)}),t},Ge=function(t){let e=Object.keys(t);return e.forEach(r=>{let n=t[r];n.lineage=[];for(let i=0;i<e.length;i++)-1!==t[e[i]].isA.indexOf(r)&&n.lineage.push(e[i])}),t};var Le=function(t){return t=function(t){return Object.keys(t).forEach(e=>{let r=t[e];r.isA=r.isA||[],"string"==typeof r.isA&&(r.isA=[r.isA]),r.notA=r.notA||[],"string"==typeof r.notA&&(r.notA=[r.notA])}),t}(t),t=Me(t),t=_e(t),t=De(t),t=Ge(t)};const qe={Noun:{notA:["Verb","Adjective","Adverb"]},Singular:{isA:"Noun",notA:"Plural"},ProperNoun:{isA:"Noun"},Person:{isA:["ProperNoun","Singular"],notA:["Place","Organization","Date"]},FirstName:{isA:"Person"},MaleName:{isA:"FirstName",notA:["FemaleName","LastName"]},FemaleName:{isA:"FirstName",notA:["MaleName","LastName"]},LastName:{isA:"Person",notA:["FirstName"]},NickName:{isA:"Person",notA:["FirstName","LastName"]},Honorific:{isA:"Noun",notA:["FirstName","LastName","Value"]},Place:{isA:"Singular",notA:["Person","Organization"]},Country:{isA:["Place","ProperNoun"],notA:["City"]},City:{isA:["Place","ProperNoun"],notA:["Country"]},Region:{isA:["Place","ProperNoun"]},Address:{isA:"Place"},Organization:{isA:["Singular","ProperNoun"],notA:["Person","Place"]},SportsTeam:{isA:"Organization"},School:{isA:"Organization"},Company:{isA:"Organization"},Plural:{isA:"Noun",notA:["Singular"]},Uncountable:{isA:"Noun"},Pronoun:{isA:"Noun",notA:Be},Actor:{isA:"Noun",notA:Be},Activity:{isA:"Noun",notA:["Person","Place"]},Unit:{isA:"Noun",notA:Be},Demonym:{isA:["Noun","ProperNoun"],notA:Be},Possessive:{isA:"Noun"}},We={Verb:{notA:["Noun","Adjective","Adverb","Value","Expression"]},PresentTense:{isA:"Verb",notA:["PastTense","FutureTense"]},Infinitive:{isA:"PresentTense",notA:["PastTense","Gerund"]},Imperative:{isA:"Infinitive"},Gerund:{isA:"PresentTense",notA:["PastTense","Copula","FutureTense"]},PastTense:{isA:"Verb",notA:["FutureTense"]},FutureTense:{isA:"Verb"},Copula:{isA:"Verb"},Modal:{isA:"Verb",notA:["Infinitive"]},PerfectTense:{isA:"Verb",notA:"Gerund"},Pluperfect:{isA:"Verb"},Participle:{isA:"PastTense"},PhrasalVerb:{isA:"Verb"},Particle:{isA:"PhrasalVerb"},Auxiliary:{notA:["Noun","Adjective","Value"]}},Ue={Value:{notA:["Verb","Adjective","Adverb"]},Ordinal:{isA:"Value",notA:["Cardinal"]},Cardinal:{isA:"Value",notA:["Ordinal"]},Fraction:{isA:"Value",notA:["Noun"]},RomanNumeral:{isA:"Cardinal",notA:["Ordinal","TextValue"]},TextValue:{isA:"Value",notA:["NumericValue"]},NumericValue:{isA:"Value",notA:["TextValue"]},Money:{isA:"Cardinal"},Percent:{isA:"Value"}},He={Adjective:{notA:["Noun","Verb","Adverb","Value"]},Comparable:{isA:["Adjective"]},Comparative:{isA:["Adjective"]},Superlative:{isA:["Adjective"],notA:["Comparative"]},NumberRange:{},Adverb:{notA:["Noun","Verb","Adjective","Value"]},Date:{notA:["Verb","Adverb","Preposition","Adjective"]},Month:{isA:["Date","Singular"],notA:["Year","WeekDay","Time"]},WeekDay:{isA:["Date","Noun"]},Timezone:{isA:["Date","Noun"],notA:["Adjective","ProperNoun"]},Time:{isA:["Date"],notA:["AtMention"]},Determiner:{notA:ze},Conjunction:{notA:ze},Preposition:{notA:ze},QuestionWord:{notA:["Determiner"]},Currency:{isA:["Noun"]},Expression:{notA:["Noun","Adjective","Verb","Adverb"]},Abbreviation:{},Url:{notA:["HashTag","PhoneNumber","Verb","Adjective","Value","AtMention","Email"]},PhoneNumber:{notA:["HashTag","Verb","Adjective","Value","AtMention","Email"]},HashTag:{},AtMention:{isA:["Noun"],notA:["HashTag","Verb","Adjective","Value","Email"]},Emoji:{notA:["HashTag","Verb","Adjective","Value","AtMention"]},Emoticon:{notA:["HashTag","Verb","Adjective","Value","AtMention"]},Email:{notA:["HashTag","Verb","Adjective","Value","AtMention"]},Acronym:{notA:["Plural","RomanNumeral"]},Negative:{notA:["Noun","Adjective","Value"]},Condition:{notA:["Verb","Adjective","Noun","Value"]}},Re=Le,Qe=function(t,e){Object.keys(t).forEach(r=>{e[r]=t[r]})};var Ze=(()=>{let t={};return Qe(qe,t),Qe(We,t),Qe(Ue,t),Qe(He,t),t=Re(t),t})(),Je={},Ye=t=>t;const Ke=Je,Xe=Ye;let tr=Je;const er={Unit:(t,e)=>{t[e]=["Abbreviation","Unit"]},Cardinal:(t,e)=>{t[e]=["TextValue","Cardinal"]},TextOrdinal:(t,e)=>{t[e]=["Ordinal","TextValue"],t[e+"s"]=["TextValue","Fraction"]},Singular:(t,e,r)=>{t[e]="Singular";let n=r.transforms.toPlural(e,r);t[n]=t[n]||"Plural"},Infinitive:(t,e,r)=>{t[e]="Infinitive";let n=r.transforms.conjugate(e,r),i=Object.keys(n);for(let e=0;e<i.length;e++){let r=n[i[e]];t[r]=t[r]||i[e]}},Comparable:(t,e,r)=>{t[e]="Comparable";let n=r.transforms.adjectives(e),i=Object.keys(n);for(let e=0;e<i.length;e++){let r=n[i[e]];t[r]=t[r]||i[e]}},PhrasalVerb:(t,e,r)=>{t[e]=["PhrasalVerb","Infinitive"];let n=e.split(" "),i=r.transforms.conjugate(n[0],r),s=Object.keys(i);for(let e=0;e<s.length;e++){let o=i[s[e]]+" "+n[1];t[o]=t[o]||["PhrasalVerb",s[e]],r.hasCompound[i[s[e]]]=!0}},Demonym:(t,e,r)=>{t[e]="Demonym";let n=r.transforms.toPlural(e,r);t[n]=t[n]||["Demonym","Plural"]}},rr=function(t,e,r){Object.keys(t).forEach(n=>{let i=t[n];"Abbreviation"!==i&&"Unit"!==i||(r.cache.abbreviations[n]=!0);let s=n.split(" ");s.length>1&&(r.hasCompound[s[0]]=!0),void 0===er[i]?void 0!==e[n]?("string"==typeof e[n]&&(e[n]=[e[n]]),"string"==typeof i?e[n].push(i):e[n]=e[n].concat(i)):e[n]=i:er[i](e,n,r)})};const nr=Ze,ir={buildOut:function(t){let e=Object.assign({},tr);return Object.keys(Ke).forEach(r=>{let n=Xe(Ke[r]);Object.keys(n).forEach(t=>{n[t]=r}),rr(n,e,t)}),e},addWords:rr},sr=function(t){let e=t.irregulars.nouns,r=Object.keys(e);for(let n=0;n<r.length;n++){const i=r[n];t.words[i]="Singular",t.words[e[i]]="Plural"}let n=t.irregulars.verbs,i=Object.keys(n);for(let e=0;e<i.length;e++){const r=i[e];t.words[r]=t.words[r]||"Infinitive";let s=t.transforms.conjugate(r,t);s=Object.assign(s,n[r]),Object.keys(s).forEach(e=>{t.words[s[e]]=t.words[s[e]]||e,"Participle"===t.words[s[e]]&&(t.words[s[e]]=e)})}},or=Le,lr={nouns:Je,verbs:Je},ar={conjugate:Ye,adjectives:Ye,toPlural:Ye,toSingular:Ye,toInfinitive:Ye};let ur=!1;class cr{constructor(){Object.defineProperty(this,"words",{enumerable:!1,value:{},writable:!0}),Object.defineProperty(this,"hasCompound",{enumerable:!1,value:{},writable:!0}),Object.defineProperty(this,"irregulars",{enumerable:!1,value:lr,writable:!0}),Object.defineProperty(this,"tags",{enumerable:!1,value:Object.assign({},nr),writable:!0}),Object.defineProperty(this,"transforms",{enumerable:!1,value:ar,writable:!0}),Object.defineProperty(this,"taggers",{enumerable:!1,value:[],writable:!0}),Object.defineProperty(this,"cache",{enumerable:!1,value:{abbreviations:{}}}),this.words=ir.buildOut(this),sr(this)}verbose(t){return ur=t,this}isVerbose(){return ur}addWords(t){let e={};Object.keys(t).forEach(r=>{let n=t[r];r=r.toLowerCase().trim(),e[r]=n}),ir.addWords(e,this.words,this)}addConjugations(t){return Object.assign(this.irregulars.verbs,t),this}addPlurals(t){return Object.assign(this.irregulars.nouns,t),this}addTags(t){return t=Object.assign({},t),this.tags=Object.assign(this.tags,t),this.tags=or(this.tags),this}postProcess(t){return this.taggers.push(t),this}stats(){return{words:Object.keys(this.words).length,plurals:Object.keys(this.irregulars.nouns).length,conjugations:Object.keys(this.irregulars.verbs).length,compounds:Object.keys(this.hasCompound).length,postProcessors:this.taggers.length}}}const hr=function(t){return JSON.parse(JSON.stringify(t))};cr.prototype.clone=function(){let t=new cr;return t.words=Object.assign({},this.words),t.hasCompound=Object.assign({},this.hasCompound),t.irregulars=hr(this.irregulars),t.tags=hr(this.tags),t.transforms=this.transforms,t.taggers=this.taggers,t};var fr=cr,pr={};!function(t){t.all=function(){return this.parents()[0]||this},t.parent=function(){return this.from?this.from:this},t.parents=function(t){let e=[];const r=function(t){t.from&&(e.push(t.from),r(t.from))};return r(this),e=e.reverse(),"number"==typeof t?e[t]:e},t.clone=function(t){let e=this.list.map(e=>e.clone(t));return this.buildFrom(e)},t.wordCount=function(){return this.list.reduce((t,e)=>t+=e.wordCount(),0)},t.wordcount=t.wordCount}(pr);var dr={};!function(t){t.first=function(t){return void 0===t?this.get(0):this.slice(0,t)},t.last=function(t){if(void 0===t)return this.get(this.list.length-1);let e=this.list.length;return this.slice(e-t,e)},t.slice=function(t,e){let r=this.list.slice(t,e);return this.buildFrom(r)},t.eq=function(t){let e=this.list[t];return void 0===e?this.buildFrom([]):this.buildFrom([e])},t.get=t.eq,t.firstTerms=function(){return this.match("^.")},t.firstTerm=t.firstTerms,t.lastTerms=function(){return this.match(".$")},t.lastTerm=t.lastTerms,t.termList=function(t){let e=[];for(let r=0;r<this.list.length;r++){let n=this.list[r].terms();for(let r=0;r<n.length;r++)if(e.push(n[r]),void 0!==t&&void 0!==e[t])return e[t]}return e};t.groups=function(t){return void 0===t?function(t){let e={};const r={};for(let e=0;e<t.list.length;e++){const n=t.list[e],i=Object.keys(n.groups).map(t=>n.groups[t]);for(let t=0;t<i.length;t++){const{group:e,start:s,length:o}=i[t];r[e]||(r[e]=[]),r[e].push(n.buildFrom(s,o))}}const n=Object.keys(r);for(let i=0;i<n.length;i++){const s=n[i];e[s]=t.buildFrom(r[s])}return e}(this):("number"==typeof t&&(t=String(t)),function(t,e){const r=[];for(let n=0;n<t.list.length;n++){const i=t.list[n];let s=Object.keys(i.groups);s=s.filter(t=>i.groups[t].group===e),s.forEach(t=>{r.push(i.buildFrom(i.groups[t].start,i.groups[t].length))})}return t.buildFrom(r)}(this,t)||this.buildFrom([]))},t.group=t.groups,t.sentences=function(t){let e=[];return this.list.forEach(t=>{e.push(t.fullSentence())}),"number"==typeof t?this.buildFrom([e[t]]):this.buildFrom(e)},t.sentence=t.sentences}(dr);var mr={};var gr=function(t,e){if(t._cache&&!0===t._cache.set){let{words:r,tags:n}=function(t){let e=[],r=[];return t.forEach(t=>{!0!==t.optional&&!0!==t.negative&&(void 0!==t.tag&&e.push(t.tag),void 0!==t.word&&r.push(t.word))}),{tags:e,words:r}}(e);for(let e=0;e<r.length;e++)if(void 0===t._cache.words[r[e]])return!1;for(let e=0;e<n.length;e++)if(void 0===t._cache.tags[n[e]])return!1}return!0};!function(t){const e=qt,r=gr;t.match=function(t,n={}){"string"!=typeof n&&"number"!=typeof n&&null!==n||(n={group:n});let i=e(t,n);if(0===i.length)return this.buildFrom([]);if(!1===r(this,i))return this.buildFrom([]);let s=this.list.reduce((t,e)=>t.concat(e.match(i)),[]);return void 0!==n.group&&null!==n.group&&""!==n.group?this.buildFrom(s).groups(n.group):this.buildFrom(s)},t.not=function(t,n={}){let i=e(t,n);if(0===i.length||!1===r(this,i))return this;let s=this.list.reduce((t,e)=>t.concat(e.not(i)),[]);return this.buildFrom(s)},t.matchOne=function(t,n={}){let i=e(t,n);if(!1===r(this,i))return this.buildFrom([]);for(let t=0;t<this.list.length;t++){let e=this.list[t].match(i,!0);return this.buildFrom(e)}return this.buildFrom([])},t.if=function(t,n={}){let i=e(t,n);if(!1===r(this,i))return this.buildFrom([]);let s=this.list.filter(t=>!0===t.has(i));return this.buildFrom(s)},t.ifNo=function(t,r={}){let n=e(t,r),i=this.list.filter(t=>!1===t.has(n));return this.buildFrom(i)},t.has=function(t,n={}){let i=e(t,n);return!1!==r(this,i)&&this.list.some(t=>!0===t.has(i))},t.lookAhead=function(t,r={}){t||(t=".*");let n=e(t,r),i=[];return this.list.forEach(t=>{i=i.concat(t.lookAhead(n))}),i=i.filter(t=>t),this.buildFrom(i)},t.lookAfter=t.lookAhead,t.lookBehind=function(t,r={}){t||(t=".*");let n=e(t,r),i=[];return this.list.forEach(t=>{i=i.concat(t.lookBehind(n))}),i=i.filter(t=>t),this.buildFrom(i)},t.lookBefore=t.lookBehind,t.before=function(t,r={}){let n=e(t,r),i=this.if(n).list.map(t=>{let e=t.terms().map(t=>t.id),r=t.match(n)[0],i=e.indexOf(r.start);return 0===i||-1===i?null:t.buildFrom(t.start,i)});return i=i.filter(t=>null!==t),this.buildFrom(i)},t.after=function(t,r={}){let n=e(t,r),i=this.if(n).list.map(t=>{let e=t.terms(),r=e.map(t=>t.id),i=t.match(n)[0],s=r.indexOf(i.start);if(-1===s||!e[s+i.length])return null;let o=e[s+i.length].id,l=t.length-s-i.length;return t.buildFrom(o,l)});return i=i.filter(t=>null!==t),this.buildFrom(i)},t.hasAfter=function(t,e={}){return this.filter(r=>r.lookAfter(t,e).found)},t.hasBefore=function(t,e={}){return this.filter(r=>r.lookBefore(t,e).found)}}(mr);var br={};const vr=function(t,e,r,n){let i=[];"string"==typeof t&&(i=t.split(" ")),e.list.forEach(s=>{let o=s.terms();!0===r&&(o=o.filter(r=>r.canBe(t,e.world))),o.forEach((r,s)=>{i.length>1?i[s]&&"."!==i[s]&&r.tag(i[s],n,e.world):r.tag(t,n,e.world)})})};br.tag=function(t,e){return t?(vr(t,this,!1,e),this):this},br.tagSafe=function(t,e){return t?(vr(t,this,!0,e),this):this},br.unTag=function(t,e){return this.list.forEach(r=>{r.terms().forEach(r=>r.unTag(t,e,this.world))}),this},br.canBe=function(t){if(!t)return this;let e=this.world,r=this.list.reduce((r,n)=>r.concat(n.canBe(t,e)),[]);return this.buildFrom(r)};var yr={map:function(t){if(!t)return this;let e=this.list.map((e,r)=>{let n=this.buildFrom([e]);n.from=null;let i=t(n,r);return i&&i.list&&i.list[0]?i.list[0]:i});return e=e.filter(t=>t),0===e.length?this.buildFrom(e):"object"!=typeof e[0]||"Phrase"!==e[0].isA?e:this.buildFrom(e)},forEach:function(t,e){return t?(this.list.forEach((r,n)=>{let i=this.buildFrom([r]);!0===e&&(i.from=null),t(i,n)}),this):this},filter:function(t){if(!t)return this;let e=this.list.filter((e,r)=>{let n=this.buildFrom([e]);return n.from=null,t(n,r)});return this.buildFrom(e)},find:function(t){if(!t)return this;let e=this.list.find((e,r)=>{let n=this.buildFrom([e]);return n.from=null,t(n,r)});return e?this.buildFrom([e]):void 0},some:function(t){return t?this.list.some((e,r)=>{let n=this.buildFrom([e]);return n.from=null,t(n,r)}):this},random:function(t){if(!this.found)return this;let e=Math.floor(Math.random()*this.list.length);if(void 0===t){let t=[this.list[e]];return this.buildFrom(t)}return e+t>this.length&&(e=this.length-t,e=e<0?0:e),this.slice(e,e+t)}},Ar={};var wr=function(t,e,r){let n=function(t,e=[]){let r={};return t.forEach((t,n)=>{let i=!0;void 0!==e[n]&&(i=e[n]);let s=function(t){return t.split(/[ -]/g)}(t=(t=(t||"").toLowerCase()).replace(/[,;.!?]+$/,"")).map(t=>t.trim());r[s[0]]=r[s[0]]||{},1===s.length?r[s[0]].value=i:(r[s[0]].more=r[s[0]].more||[],r[s[0]].more.push({rest:s.slice(1),value:i}))}),r}(t,e),i=[];for(let t=0;t<r.list.length;t++){const e=r.list[t];let s=e.terms().map(t=>t.reduced);for(let t=0;t<s.length;t++)void 0!==n[s[t]]&&(void 0!==n[s[t]].more&&n[s[t]].more.forEach(r=>{if(void 0===s[t+r.rest.length])return;!0===r.rest.every((e,r)=>e===s[t+r+1])&&i.push({id:e.terms()[t].id,value:r.value,length:r.rest.length+1})}),void 0!==n[s[t]].value&&i.push({id:e.terms()[t].id,value:n[s[t]].value,length:1}))}return i};!function(t){const e=wr;t.lookup=function(t){let r=[],n=(i=t)&&"[object Object]"===Object.prototype.toString.call(i);var i;!0===n&&(t=Object.keys(t).map(e=>(r.push(t[e]),e))),"string"==typeof t&&(t=[t]),!0!==this._cache.set&&this.cache();let s=e(t,r,this),o=this.list[0];if(!0===n){let t={};return s.forEach(e=>{t[e.value]=t[e.value]||[],t[e.value].push(o.buildFrom(e.id,e.length))}),Object.keys(t).forEach(e=>{t[e]=this.buildFrom(t[e])}),t}return s=s.map(t=>o.buildFrom(t.id,t.length)),this.buildFrom(s)},t.lookUp=t.lookup}(Ar);var xr={cache:function(t){t=t||{};let e={},r={};return this._cache.words=e,this._cache.tags=r,this._cache.set=!0,this.list.forEach((n,i)=>{n.cache=n.cache||{},n.terms().forEach(n=>{e[n.reduced]&&!e.hasOwnProperty(n.reduced)||(e[n.reduced]=e[n.reduced]||[],e[n.reduced].push(i),Object.keys(n.tags).forEach(t=>{r[t]=r[t]||[],r[t].push(i)}),t.root&&(n.setRoot(this.world),e[n.root]=[i]))})}),this},uncache:function(){return this._cache={},this.list.forEach(t=>{t.cache={}}),this.parents().forEach(t=>{t._cache={},t.list.forEach(t=>{t.cache={}})}),this}},Pr={};const jr=Te;Pr.replaceWith=function(t,e={}){return t?(!0===e&&(e={keepTags:!0}),!1===e&&(e={keepTags:!1}),e=e||{},this.uncache(),this.list.forEach(r=>{let n,i=t;if("function"==typeof t&&(i=t(r)),i&&"object"==typeof i&&"Doc"===i.isA)n=i.list,this.pool().merge(i.pool());else{if("string"!=typeof i)return;{!1!==e.keepCase&&r.terms(0).isTitleCase()&&(i=(s=i).charAt(0).toUpperCase()+s.substr(1)),n=jr(i,this.world,this.pool());let t=this.buildFrom(n);t.tagger(),n=t.list}}var s;if(!0===e.keepTags){let t=r.json({terms:{tags:!0}}).terms;n[0].terms().forEach((e,r)=>{t[r]&&e.tagSafe(t[r].tags,"keptTag",this.world)})}r.replace(n[0],this)}),this):this.delete()},Pr.replace=function(t,e,r){return void 0===e?this.replaceWith(t,r):(this.match(t).replaceWith(e,r),this)};var Er={};!function(t){const e=Te,r=function(t){return t&&"[object Object]"===Object.prototype.toString.call(t)},n=function(t,r){let n=e(t,r.world)[0],i=r.buildFrom([n]);return i.tagger(),r.list=i.list,r};t.append=function(t=""){return t?this.found?(this.uncache(),this.list.forEach(n=>{let i;r(t)&&"Doc"===t.isA?i=t.list[0].clone():"string"==typeof t&&(i=e(t,this.world,this.pool())[0]),this.buildFrom([i]).tagger(),n.append(i,this)}),this):n(t,this):this},t.insertAfter=t.append,t.insertAt=t.append,t.prepend=function(t){return t?this.found?(this.uncache(),this.list.forEach(n=>{let i;r(t)&&"Doc"===t.isA?i=t.list[0].clone():"string"==typeof t&&(i=e(t,this.world,this.pool())[0]),this.buildFrom([i]).tagger(),n.prepend(i,this)}),this):n(t,this):this},t.insertBefore=t.prepend,t.concat=function(){this.uncache();let t=this.list.slice(0);for(let r=0;r<arguments.length;r++){let n=arguments[r];if("string"==typeof n){let r=e(n,this.world);t=t.concat(r)}else"Doc"===n.isA?t=t.concat(n.list):"Phrase"===n.isA&&t.push(n)}return this.buildFrom(t)},t.delete=function(t){this.uncache();let e=this;return t&&(e=this.match(t)),e.list.forEach(t=>t.delete(this)),this},t.remove=t.delete}(Er);var Or={};const Cr={clean:!0,reduced:!0,root:!0};Or.text=function(t){t=t||{};let e=!1;0===this.parents().length&&(e=!0),("root"===t||"object"==typeof t&&t.root)&&this.list.forEach(t=>{t.terms().forEach(t=>{null===t.root&&t.setRoot(this.world)})});let r=this.list.reduce((r,n,i)=>{const s=!e&&0===i,o=!e&&i===this.list.length-1;return r+n.text(t,s,o)},"");return!0!==Cr[t]&&!0!==t.reduced&&!0!==t.clean&&!0!==t.root||(r=r.trim()),r};var Fr={};var Tr=function(t,e,r){let n=function(t){let e=0,r=0,n={};return t.termList().forEach(t=>{n[t.id]={index:r,start:e+t.pre.length,length:t.text.length},e+=t.pre.length+t.text.length+t.post.length,r+=1}),n}(t.all());(r.terms.index||r.index)&&e.forEach(t=>{t.terms.forEach(t=>{t.index=n[t.id].index}),t.index=t.terms[0].index}),(r.terms.offset||r.offset)&&e.forEach(t=>{t.terms.forEach(t=>{t.offset=n[t.id]||{}}),t.offset={index:t.terms[0].offset.index,start:t.terms[0].offset.start-t.text.indexOf(t.terms[0].text),length:t.text.length}})};!function(t){const e=Tr,r={text:!0,terms:!0,trim:!0};t.json=function(t={}){if("number"==typeof t&&this.list[t])return this.list[t].json(r);!0===(t=function(t){return(t=Object.assign({},r,t)).unique&&(t.reduced=!0),t.offset&&(t.text=!0,t.terms&&!0!==t.terms||(t.terms={}),t.terms.offset=!0),(t.index||t.terms.index)&&(t.terms=!0===t.terms?{}:t.terms,t.terms.id=!0),t}(t)).root&&this.list.forEach(t=>{t.terms().forEach(t=>{null===t.root&&t.setRoot(this.world)})});let n=this.list.map(e=>e.json(t,this.world));if((t.terms.offset||t.offset||t.terms.index||t.index)&&e(this,n,t),t.frequency||t.freq||t.count){let t={};this.list.forEach(e=>{let r=e.text("reduced");t[r]=t[r]||0,t[r]+=1}),this.list.forEach((e,r)=>{n[r].count=t[e.text("reduced")]})}if(t.unique){let t={};n=n.filter(e=>!0!==t[e.reduced]&&(t[e.reduced]=!0,!0))}return n},t.data=t.json}(Fr);var kr={},Nr={exports:{}};!function(t){const e="[0m",r=function(t,e){for(t=t.toString();t.length<e;)t+=" ";return t};const n={green:"#7f9c6c",red:"#914045",blue:"#6699cc",magenta:"#6D5685",cyan:"#2D85A8",yellow:"#e6d7b3",black:"#303b50"},i={green:function(t){return"[32m"+t+e},red:function(t){return"[31m"+t+e},blue:function(t){return"[34m"+t+e},magenta:function(t){return"[35m"+t+e},cyan:function(t){return"[36m"+t+e},yellow:function(t){return"[33m"+t+e},black:function(t){return"[30m"+t+e}};t.exports=function(t){return"undefined"!=typeof window&&window.document?(function(t){let e=t.world.tags;t.list.forEach(t=>{console.log('\n%c"'+t.text()+'"',"color: #e6d7b3;"),t.terms().forEach(t=>{let i=Object.keys(t.tags),s=t.text||"-";t.implicit&&(s="["+t.implicit+"]");let o="'"+s+"'";o=r(o,8);let l=i.find(t=>e[t]&&e[t].color),a="steelblue";e[l]&&(a=e[l].color,a=n[a]),console.log(` ${o} - %c${i.join(", ")}`,`color: ${a||"steelblue"};`)})})}(t),t):(console.log(i.blue("=====")),t.list.forEach(e=>{console.log(i.blue(" -----")),e.terms().forEach(e=>{let n=Object.keys(e.tags),s=e.text||"-";e.implicit&&(s="["+e.implicit+"]"),s=i.yellow(s);let o="'"+s+"'";o=r(o,18);let l=i.blue(" | ")+o+" - "+function(t,e){return(t=t.map(t=>{if(!e.tags.hasOwnProperty(t))return t;const r=e.tags[t].color||"blue";return i[r](t)})).join(", ")}(n,t.world);console.log(l)})}),console.log(""),t)}}(Nr);const $r=Nr.exports,Vr=function(t){let e=t.json({text:!1,terms:!1,reduced:!0}),r={};e.forEach(t=>{r[t.reduced]||(t.count=0,r[t.reduced]=t),r[t.reduced].count+=1});let n=Object.keys(r).map(t=>r[t]);return n.sort((t,e)=>t.count>e.count?-1:t.count<e.count?1:0),n};kr.debug=function(){return $r(this),this},kr.out=function(t){if("text"===t)return this.text();if("normal"===t)return this.text("normal");if("json"===t)return this.json();if("offset"===t||"offsets"===t)return this.json({offset:!0});if("array"===t)return this.json({terms:!1}).map(t=>t.text).filter(t=>t);if("freq"===t||"frequency"===t)return Vr(this);if("terms"===t){let t=[];return this.json({text:!1,terms:{text:!0}}).forEach(e=>{let r=e.terms.map(t=>t.text);r=r.filter(t=>t),t=t.concat(r)}),t}return"tags"===t?this.list.map(t=>t.terms().reduce((t,e)=>(t[e.clean||e.implicit]=Object.keys(e.tags),t),{})):"debug"===t?($r(this),this):this.text()};var Ir={};const Br={alpha:(t,e)=>{let r=t.text("clean"),n=e.text("clean");return r<n?-1:r>n?1:0},length:(t,e)=>{let r=t.text().trim().length,n=e.text().trim().length;return r<n?1:r>n?-1:0},wordCount:(t,e)=>{let r=t.wordCount(),n=e.wordCount();return r<n?1:r>n?-1:0}};Br.alphabetical=Br.alpha,Br.wordcount=Br.wordCount;const zr={index:!0,sequence:!0,seq:!0,sequential:!0,chron:!0,chronological:!0};Ir.sort=function(t){return"freq"===(t=t||"alpha")||"frequency"===t||"topk"===t?function(t){let e={};const r={case:!0,punctuation:!1,whitespace:!0,unicode:!0};return t.list.forEach(t=>{let n=t.text(r);e[n]=e[n]||0,e[n]+=1}),t.list.sort((t,n)=>{let i=e[t.text(r)],s=e[n.text(r)];return i<s?1:i>s?-1:0}),t}(this):zr.hasOwnProperty(t)?function(t){let e={};return t.json({terms:{offset:!0}}).forEach(t=>{e[t.terms[0].id]=t.terms[0].offset.start}),t.list=t.list.sort((t,r)=>e[t.start]>e[r.start]?1:e[t.start]<e[r.start]?-1:0),t}(this):"function"==typeof(t=Br[t]||t)?(this.list=this.list.sort(t),this):this},Ir.reverse=function(){let t=[].concat(this.list);return t=t.reverse(),this.buildFrom(t)},Ir.unique=function(){let t=[].concat(this.list),e={};return t=t.filter(t=>{let r=t.text("reduced").trim()||t.text("implicit").trim();return!0!==e.hasOwnProperty(r)&&(e[r]=!0,!0)}),this.buildFrom(t)};var Sr={};const Dr=i,Mr=/[\[\]{}⟨⟩:,،、‒–—―…‹›«»‐\-;\/⁄·*\•^†‡°¡¿※№÷׺ª%‰=‱¶§~|‖¦©℗®℠™¤₳฿]/g,_r=/['‘’“”"′″‴]+/g;const Gr={whitespace:function(t){let e=t.list.map(t=>t.terms());e.forEach((t,r)=>{t.forEach((n,i)=>{!0!==n.hasDash()?(n.pre=n.pre.replace(/\s/g,""),n.post=n.post.replace(/\s/g,""),(t.length-1!==i||e[r+1])&&(n.implicit&&!0===Boolean(n.text)||!0!==n.hasHyphen()&&(n.post+=" "))):n.post=" - "})})},punctuation:function(t){t.forEach(t=>{!0===t.hasHyphen()&&(t.post=" "),t.pre=t.pre.replace(Mr,""),t.post=t.post.replace(Mr,""),t.post=t.post.replace(/\.\.\./,""),!0===/!/.test(t.post)&&(t.post=t.post.replace(/!/g,""),t.post="!"+t.post),!0===/\?/.test(t.post)&&(t.post=t.post.replace(/[\?!]*/,""),t.post="?"+t.post)})},unicode:function(t){t.forEach(t=>{!0!==t.isImplicit()&&(t.text=Dr(t.text))})},quotations:function(t){t.forEach(t=>{t.post=t.post.replace(_r,""),t.pre=t.pre.replace(_r,"")})},adverbs:function(t){t.match("#Adverb").not("(not|nary|seldom|never|barely|almost|basically|so)").remove()},abbreviations:function(t){t.list.forEach(t=>{let e=t.terms();e.forEach((t,r)=>{!0===t.tags.Abbreviation&&e[r+1]&&(t.post=t.post.replace(/^\./,""))})})}},Lr={whitespace:!0,unicode:!0,punctuation:!0,emoji:!0,acronyms:!0,abbreviations:!0,case:!1,contractions:!1,parentheses:!1,quotations:!1,adverbs:!1,possessives:!1,verbs:!1,nouns:!1,honorifics:!1},qr={light:{},medium:{case:!0,contractions:!0,parentheses:!0,quotations:!0,adverbs:!0}};qr.heavy=Object.assign({},qr.medium,{possessives:!0,verbs:!0,nouns:!0,honorifics:!0}),Sr.normalize=function(t){"string"==typeof(t=t||{})&&(t=qr[t]||{}),t=Object.assign({},Lr,t),this.uncache();let e=this.termList();return t.case&&this.toLowerCase(),t.whitespace&&Gr.whitespace(this),t.unicode&&Gr.unicode(e),t.punctuation&&Gr.punctuation(e),t.emoji&&this.remove("(#Emoji|#Emoticon)"),t.acronyms&&this.acronyms().strip(),t.abbreviations&&Gr.abbreviations(this),(t.contraction||t.contractions)&&this.contractions().expand(),t.parentheses&&this.parentheses().unwrap(),(t.quotations||t.quotes)&&Gr.quotations(e),t.adverbs&&Gr.adverbs(this),(t.possessive||t.possessives)&&this.possessives().strip(),t.verbs&&this.verbs().toInfinitive(),(t.nouns||t.plurals)&&this.nouns().toSingular(),t.honorifics&&this.remove("#Honorific"),this};var Wr={};!function(t){const e=qt;t.splitOn=function(t){if(!t){return this.parent().splitOn(this)}let r=e(t),n=[];return this.list.forEach(t=>{let e=t.match(r);if(0===e.length)return void n.push(t);let i=t;e.forEach(t=>{let e=i.splitOn(t);e.before&&n.push(e.before),e.match&&n.push(e.match),i=e.after}),i&&n.push(i)}),this.buildFrom(n)},t.splitAfter=function(t){if(!t){return this.parent().splitAfter(this)}let r=e(t),n=[];return this.list.forEach(t=>{let e=t.match(r);if(0===e.length)return void n.push(t);let i=t;e.forEach(t=>{let e=i.splitOn(t);e.before&&e.match?(e.before.length+=e.match.length,n.push(e.before)):e.match&&n.push(e.match),i=e.after}),i&&n.push(i)}),this.buildFrom(n)},t.split=t.splitAfter,t.splitBefore=function(t){if(!t){return this.parent().splitBefore(this)}let r=e(t),n=[];return this.list.forEach(t=>{let e=t.match(r);if(0===e.length)return void n.push(t);let i=t;e.forEach(t=>{let e=i.splitOn(t);e.before&&n.push(e.before),e.match&&e.after&&(e.match.length+=e.after.length),i=e.match}),i&&n.push(i)}),this.buildFrom(n)},t.segment=function(t,e){t=t||{},e=e||{text:!0};let r=this,n=Object.keys(t);return n.forEach(t=>{r=r.splitOn(t)}),r.list.forEach(e=>{for(let r=0;r<n.length;r+=1)if(e.has(n[r]))return void(e.segment=t[n[r]])}),r.list.map(t=>{let r=t.json(e);return r.segment=t.segment||null,r})}}(Wr);var Ur={};const Hr=function(t,e){let r=t.world;return t.list.forEach(t=>{t.terms().forEach(t=>t[e](r))}),t};Ur.toLowerCase=function(){return Hr(this,"toLowerCase")},Ur.toUpperCase=function(){return Hr(this,"toUpperCase")},Ur.toTitleCase=function(){return Hr(this,"toTitleCase")},Ur.toCamelCase=function(){return this.list.forEach(t=>{let e=t.terms();e.forEach((t,r)=>{0!==r&&t.toTitleCase(),r!==e.length-1&&(t.post="")})}),this};var Rr={};!function(t){t.pre=function(t,e){return void 0===t?this.list[0].terms(0).pre:(this.list.forEach(r=>{let n=r.terms(0);!0===e?n.pre+=t:n.pre=t}),this)},t.post=function(t,e){return void 0===t?this.list.map(t=>{let e=t.terms();return e[e.length-1].post}):(this.list.forEach(r=>{let n=r.terms(),i=n[n.length-1];!0===e?i.post+=t:i.post=t}),this)},t.trim=function(){return this.list=this.list.map(t=>t.trim()),this},t.hyphenate=function(){return this.list.forEach(t=>{let e=t.terms();e.forEach((t,r)=>{0!==r&&(t.pre=""),e[r+1]&&(t.post="-")})}),this},t.dehyphenate=function(){const t=/(-|–|—)/;return this.list.forEach(e=>{e.terms().forEach(e=>{t.test(e.post)&&(e.post=" ")})}),this},t.deHyphenate=t.dehyphenate,t.toQuotations=function(t,e){return t=t||'"',e=e||'"',this.list.forEach(r=>{let n=r.terms();n[0].pre=t+n[0].pre;let i=n[n.length-1];i.post=e+i.post}),this},t.toQuotation=t.toQuotations,t.toParentheses=function(t,e){return t=t||"(",e=e||")",this.list.forEach(r=>{let n=r.terms();n[0].pre=t+n[0].pre;let i=n[n.length-1];i.post=e+i.post}),this}}(Rr);var Qr={join:function(t){this.uncache();let e=this.list[0],r=e.length,n={};for(let r=1;r<this.list.length;r++){const i=this.list[r];n[i.start]=!0;let s=e.lastTerm();t&&(s.post+=t),s.next=i.start,i.terms(0).prev=s.id,e.length+=i.length,e.cache={}}let i=e.length-r;return this.parents().forEach(t=>{t.list.forEach(t=>{let r=t.terms();for(let n=0;n<r.length;n++)if(r[n].id===e.start){t.length+=i;break}t.cache={}}),t.list=t.list.filter(t=>!0!==n[t.start])}),this.buildFrom([e])}},Zr={};const Jr=/[,\)"';:\-–—\.…]/,Yr=function(t,e){if(!t.found)return;let r=t.termList();for(let t=0;t<r.length-1;t++){const e=r[t];if(Jr.test(e.post))return}r.forEach(t=>{t.implicit=t.clean}),r[0].text+=e,r.slice(1).forEach(t=>{t.text=""});for(let t=0;t<r.length-1;t++){const e=r[t];e.post=e.post.replace(/ /,"")}};Zr.contract=function(){let t=this.not("@hasContraction"),e=t.match("(we|they|you) are");return Yr(e,"'re"),e=t.match("(he|she|they|it|we|you) will"),Yr(e,"'ll"),e=t.match("(he|she|they|it|we) is"),Yr(e,"'s"),e=t.match("#Person is"),Yr(e,"'s"),e=t.match("#Person would"),Yr(e,"'d"),e=t.match("(is|was|had|would|should|could|do|does|have|has|can) not"),Yr(e,"n't"),e=t.match("(i|we|they) have"),Yr(e,"'ve"),e=t.match("(would|should|could) have"),Yr(e,"'ve"),e=t.match("i am"),Yr(e,"'m"),e=t.match("going to"),this};var Kr=Object.assign({},pr,dr,mr,br,yr,Ar,xr,Pr,Er,Or,Fr,kr,Ir,Sr,Wr,Ur,Rr,Qr,Zr);let Xr={};[["terms","."],["hyphenated","@hasHyphen ."],["adjectives","#Adjective"],["hashTags","#HashTag"],["emails","#Email"],["emoji","#Emoji"],["emoticons","#Emoticon"],["atMentions","#AtMention"],["urls","#Url"],["adverbs","#Adverb"],["pronouns","#Pronoun"],["conjunctions","#Conjunction"],["prepositions","#Preposition"]].forEach(t=>{Xr[t[0]]=function(e){let r=this.match(t[1]);return"number"==typeof e&&(r=r.get(e)),r}}),Xr.emojis=Xr.emoji,Xr.atmentions=Xr.atMentions,Xr.words=Xr.terms,Xr.phoneNumbers=function(t){let e=this.splitAfter("@hasComma");return e=e.match("#PhoneNumber+"),"number"==typeof t&&(e=e.get(t)),e},Xr.money=function(t){let e=this.match("#Money #Currency?");return"number"==typeof t&&(e=e.get(t)),e},Xr.places=function(t){let e=this.match("(#City && @hasComma) (#Region|#Country)"),r=this.not(e).splitAfter("@hasComma");return r=r.concat(e),r.sort("index"),r=r.match("#Place+"),"number"==typeof t&&(r=r.get(t)),r},Xr.organizations=function(t){let e=this.clauses();return e=e.match("#Organization+"),"number"==typeof t&&(e=e.get(t)),e},Xr.entities=function(t){let e=this.clauses(),r=e.people();r=r.concat(e.places()),r=r.concat(e.organizations());return r=r.not(["someone","man","woman","mother","brother","sister","father"]),r.sort("sequence"),"number"==typeof t&&(r=r.get(t)),r},Xr.things=Xr.entities,Xr.topics=Xr.entities;var tn=Xr;const en=/^(under|over)-?.{3}/,rn=function(t,e,r){let n=r.words,i=t[e].reduced+" "+t[e+1].reduced;return void 0!==n[i]&&!0===n.hasOwnProperty(i)?(t[e].tag(n[i],"lexicon-two",r),t[e+1].tag(n[i],"lexicon-two",r),1):e+2<t.length&&(i+=" "+t[e+2].reduced,void 0!==n[i]&&!0===n.hasOwnProperty(i))?(t[e].tag(n[i],"lexicon-three",r),t[e+1].tag(n[i],"lexicon-three",r),t[e+2].tag(n[i],"lexicon-three",r),2):e+3<t.length&&(i+=" "+t[e+3].reduced,void 0!==n[i]&&!0===n.hasOwnProperty(i))?(t[e].tag(n[i],"lexicon-four",r),t[e+1].tag(n[i],"lexicon-four",r),t[e+2].tag(n[i],"lexicon-four",r),t[e+3].tag(n[i],"lexicon-four",r),3):0};const nn=function(t,e){let r=e.words,n=e.hasCompound;for(let i=0;i<t.length;i+=1){let s=t[i].clean;if(!0===n[s]&&i+1<t.length){let r=rn(t,i,e);if(r>0){i+=r;continue}}if(void 0===r[s]||!0!==r.hasOwnProperty(s))if(s===t[i].reduced||!0!==r.hasOwnProperty(t[i].reduced)){if(!0===en.test(s)){let n=s.replace(/^(under|over)-?/,"");!0===r.hasOwnProperty(n)&&t[i].tag(r[n],"noprefix-lexicon",e)}}else t[i].tag(r[t[i].reduced],"lexicon",e);else t[i].tag(r[s],"lexicon",e)}return t};var sn=function(t){let e=t.termList();return nn(e,t.world),t.world.taggers.forEach(e=>{e(t)}),t};var on=function(t){class e extends t{stripPeriods(){return this.termList().forEach(t=>{!0===t.tags.Abbreviation&&t.next&&(t.post=t.post.replace(/^\./,""));let e=t.text.replace(/\./,"");t.set(e)}),this}addPeriods(){return this.termList().forEach(t=>{t.post=t.post.replace(/^\./,""),t.post="."+t.post}),this}}return e.prototype.unwrap=e.prototype.stripPeriods,t.prototype.abbreviations=function(t){let r=this.match("#Abbreviation");return"number"==typeof t&&(r=r.get(t)),new e(r.list,this,this.world)},t};const ln=/\./;var an=function(t){class e extends t{stripPeriods(){return this.termList().forEach(t=>{let e=t.text.replace(/\./g,"");t.set(e)}),this}addPeriods(){return this.termList().forEach(t=>{let e=t.text.replace(/\./g,"");e=e.split("").join("."),!1===ln.test(t.post)&&(e+="."),t.set(e)}),this}}return e.prototype.unwrap=e.prototype.stripPeriods,e.prototype.strip=e.prototype.stripPeriods,t.prototype.acronyms=function(t){let r=this.match("#Acronym");return"number"==typeof t&&(r=r.get(t)),new e(r.list,this,this.world)},t};var un=function(t){return t.prototype.clauses=function(e){let r=this.if("@hasComma").notIf("@hasComma @hasComma").notIf("@hasComma . .? (and|or) .").notIf("(#City && @hasComma) #Country").notIf("(#WeekDay && @hasComma) #Date").notIf("(#Date && @hasComma) #Year").notIf("@hasComma (too|also)$").match("@hasComma"),n=this.splitAfter(r),i=n.quotations();n=n.splitOn(i);let s=n.parentheses();n=n.splitOn(s);let o=n.if("#Copula #Adjective #Conjunction (#Pronoun|#Determiner) #Verb").match("#Conjunction");n=n.splitBefore(o);let l=n.if("if .{2,9} then .").match("then");n=n.splitBefore(l),n=n.splitBefore("as well as ."),n=n.splitBefore("such as ."),n=n.splitBefore("in addition to ."),n=n.splitAfter("@hasSemicolon"),n=n.splitAfter("@hasDash");let a=n.filter(t=>t.wordCount()>5&&t.match("#Verb+").length>=2);if(a.found){let t=a.splitAfter("#Noun .* #Verb .* #Noun+");n=n.splitOn(t.eq(0))}return"number"==typeof e&&(n=n.get(e)),new t(n.list,this,this.world)},t};var cn=function(t){class e extends t{constructor(t,e,r){super(t,e,r),this.contracted=null}expand(){return this.list.forEach(t=>{let e=t.terms(),r=e[0].isTitleCase();e.forEach((t,r)=>{t.set(t.implicit||t.text),t.implicit=void 0,r<e.length-1&&""===t.post&&(t.post+=" ")}),r&&e[0].toTitleCase()}),this}}return t.prototype.contractions=function(t){let r=this.match("@hasContraction+");return"number"==typeof t&&(r=r.get(t)),new e(r.list,this,this.world)},t.prototype.expanded=t.prototype.isExpanded,t.prototype.contracted=t.prototype.isContracted,t};var hn=function(t){const e=function(t){let e=t.splitAfter("@hasComma").splitOn("(and|or) not?").not("(and|or) not?"),r=t.match("[.] (and|or)",0);return{things:e,conjunction:t.match("(and|or) not?"),beforeLast:r,hasOxford:r.has("@hasComma")}};class r extends t{conjunctions(){return this.match("(and|or)")}parts(){return this.splitAfter("@hasComma").splitOn("(and|or) not?")}items(){return e(this).things}add(t){return this.forEach(r=>{let n=e(r).beforeLast;n.append(t),n.termList(0).addPunctuation(",")}),this}remove(t){return this.items().if(t).remove()}hasOxfordComma(){return this.filter(t=>e(t).hasOxford)}addOxfordComma(){let t=this.items(),e=t.eq(t.length-2);return e.found&&!1===e.has("@hasComma")&&e.post(", "),this}removeOxfordComma(){let t=this.items(),e=t.eq(t.length-2);return e.found&&!0===e.has("@hasComma")&&e.post(" "),this}}return r.prototype.things=r.prototype.items,t.prototype.lists=function(t){let e=this.if("@hasComma+ .? (and|or) not? ."),n=e.match("(#Noun|#Adjective|#Determiner|#Article)+ #Conjunction not? (#Article|#Determiner)? #Adjective? #Noun+").if("#Noun"),i=e.match("(#Adjective|#Adverb)+ #Conjunction not? #Adverb? #Adjective+"),s=e.match("(#Verb|#Adverb)+ #Conjunction not? #Adverb? #Verb+"),o=n.concat(i);return o=o.concat(s),o=o.if("@hasComma"),"number"==typeof t&&(o=e.get(t)),new r(o.list,this,this.world)},t};const fn={hour:"an",heir:"an",heirloom:"an",honest:"an",honour:"an",honor:"an",uber:"an"},pn={a:!0,e:!0,f:!0,h:!0,i:!0,l:!0,m:!0,n:!0,o:!0,r:!0,s:!0,x:!0},dn=[/^onc?e/i,/^u[bcfhjkqrstn][aeiou]/i,/^eul/i];const mn={isSingular:[/(ax|test)is$/i,/(octop|vir|radi|nucle|fung|cact|stimul)us$/i,/(octop|vir)i$/i,/(rl)f$/i,/(alias|status)$/i,/(bu)s$/i,/(al|ad|at|er|et|ed|ad)o$/i,/(ti)um$/i,/(ti)a$/i,/sis$/i,/(?:(^f)fe|(lr)f)$/i,/hive$/i,/(^aeiouy|qu)y$/i,/(x|ch|ss|sh|z)$/i,/(matr|vert|ind|cort)(ix|ex)$/i,/(m|l)ouse$/i,/(m|l)ice$/i,/(antenn|formul|nebul|vertebr|vit)a$/i,/.sis$/i,/^(?!talis|.*hu)(.*)man$/i],isPlural:[/(antenn|formul|nebul|vertebr|vit)ae$/i,/(octop|vir|radi|nucle|fung|cact|stimul)i$/i,/men$/i,/.tia$/i,/(m|l)ice$/i]},gn=/s$/;const bn={he:"his",she:"hers",they:"theirs",we:"ours",i:"mine",you:"yours",her:"hers",their:"theirs",our:"ours",my:"mine",your:"yours"};const vn=function(t){return!0===t.has("#Plural")||!0!==t.has("(#Pronoun|#Place|#Value|#Person|#Uncountable|#Month|#WeekDay|#Holiday|#Possessive)")},yn=function(t){if(t.has("#Person")||t.has("#Place"))return"";if(t.has("#Plural"))return"the";let e=t.text("normal").trim();if(fn.hasOwnProperty(e))return fn[e];let r=e.substr(0,1);if(t.has("^@isAcronym")&&pn.hasOwnProperty(r))return"an";for(let t=0;t<dn.length;t++)if(dn[t].test(e))return"a";return/^[aeiou]/i.test(e)?"an":"a"},An=function(t){return!mn.isSingular.find(e=>e.test(t))&&(!0===gn.test(t)||(!!mn.isPlural.find(e=>e.test(t))||null))},wn=function(t){let e=t.text("text").trim();return bn.hasOwnProperty(e)?(t.replaceWith(bn[e],!0),void t.tag("Possessive","toPossessive")):/s$/.test(e)?(e+="'",t.replaceWith(e,!0),void t.tag("Possessive","toPossessive")):(e+="'s",t.replaceWith(e,!0),void t.tag("Possessive","toPossessive"))},xn=function(t){let e={main:t};if(t.has("#Noun (of|by|for) .")){let r=t.splitAfter("[#Noun+]",0);e.main=r.eq(0),e.post=r.eq(1)}return e};const Pn={json:function(t){let e=null;"number"==typeof t&&(e=t,t=null),t=t||{text:!0,normal:!0,trim:!0,terms:!0};let r=[];return this.forEach(e=>{let n=e.json(t)[0];n.article=yn(e),r.push(n)}),null!==e?r[e]:r},adjectives:function(){let t=this.lookAhead("^(that|who|which)? (was|is|will)? be? #Adverb? #Adjective+");return t=t.concat(this.lookBehind("#Adjective+ #Adverb?$")),t=t.match("#Adjective"),t.sort("index")},isPlural:function(){return this.if("#Plural")},hasPlural:function(){return this.filter(t=>vn(t))},toPlural:function(t){let e=this.world.transforms.toPlural;return this.forEach(r=>{if(r.has("#Plural")||!1===vn(r))return;let n=xn(r).main,i=n.text("reduced");if((n.has("#Singular")||!0!==An(i))&&(i=e(i,this.world),n.replace(i).tag("#Plural"),t)){let t=n.lookBefore("(an|a) #Adjective?$").not("#Adjective");!0===t.found&&t.remove()}}),this},toSingular:function(t){let e=this.world.transforms.toSingular;return this.forEach(r=>{if(r.has("^#Singular+$")||!1===vn(r))return;let n=xn(r).main,i=n.text("reduced");if((n.has("#Plural")||!0===An(i))&&(i=e(i,this.world),n.replace(i).tag("#Singular"),t)){let t=r,e=r.lookBefore("#Adjective");e.found&&(t=e);let n=yn(t);t.insertBefore(n)}}),this},toPossessive:function(){return this.forEach(t=>{wn(t)}),this}};var jn=function(t){class e extends t{}return Object.assign(e.prototype,Pn),t.prototype.nouns=function(t,r={}){let n=this.match("(#City && @hasComma) (#Region|#Country)"),i=this.not(n).splitAfter("@hasComma");i=i.concat(n);let s=i.quotations();return s.found&&(i=i.splitOn(s.eq(0))),i=i.match("#Noun+ (of|by)? the? #Noun+?"),!0!==r.keep_anaphora&&(i=i.not("#Pronoun"),i=i.not("(there|these)"),i=i.not("(#Month|#WeekDay)"),i=i.not("(my|our|your|their|her|his)")),i=i.not("(of|for|by|the)$"),"number"==typeof t&&(i=i.get(t)),new e(i.list,this,this.world)},t};const En=/\(/,On=/\)/;var Cn=function(t){class e extends t{unwrap(){return this.list.forEach(t=>{let e=t.terms(0);e.pre=e.pre.replace(En,"");let r=t.lastTerm();r.post=r.post.replace(On,"")}),this}}return t.prototype.parentheses=function(t){let r=[];return this.list.forEach(t=>{let e=t.terms();for(let n=0;n<e.length;n+=1){const i=e[n];if(En.test(i.pre))for(let s=n;s<e.length;s+=1)if(On.test(e[s].post)){let e=s-n+1;r.push(t.buildFrom(i.id,e)),n=s;break}}}),"number"==typeof t?(r=r[t]?[r[t]]:[],new e(r,this,this.world)):new e(r,this,this.world)},t};var Fn=function(t){class e extends t{constructor(t,e,r){super(t,e,r),this.contracted=null}strip(){return this.list.forEach(t=>{t.terms().forEach(t=>{let e=t.text.replace(/'s$/,"");t.set(e||t.text)})}),this}}return t.prototype.possessives=function(t){let r=this.match("#Noun+? #Possessive");return"number"==typeof t&&(r=r.get(t)),new e(r.list,this,this.world)},t};const Tn={'"':'"',""":""","'":"'","“":"”","‘":"’","‟":"”","‛":"’","„":"”","⹂":"”","‚":"’","«":"»","‹":"›","‵":"′","‶":"″","‷":"‴","〝":"〞","`":"´","〟":"〞"},kn=RegExp("("+Object.keys(Tn).join("|")+")");var Nn=function(t){class e extends t{unwrap(){return this}}return t.prototype.quotations=function(t){let r=[];return this.list.forEach(t=>{let e=t.terms();for(let n=0;n<e.length;n+=1){const i=e[n];if(kn.test(i.pre)){let s=(i.pre.match(kn)||[])[0],o=Tn[s];for(let s=n;s<e.length;s+=1)if(-1!==e[s].post.indexOf(o)){let e=s-n+1;r.push(t.buildFrom(i.id,e)),n=s;break}}}}),"number"==typeof t?(r=r[t]?[r[t]]:[],new e(r,this,this.world)):new e(r,this,this.world)},t.prototype.quotes=t.prototype.quotations,t};var $n=function(t,e){let r=t.verb,n=r.text("reduced");if(r.has("#Infinitive"))return n;let i=null;return r.has("#PastTense")?i="PastTense":r.has("#Gerund")?i="Gerund":r.has("#PresentTense")?i="PresentTense":r.has("#Participle")?i="Participle":r.has("#Actor")&&(i="Actor"),e.transforms.toInfinitive(n,e,i)};var Vn=function(t){let e=t.verb;if(e.has("(are|were|does)")||t.auxiliary.has("(are|were|does)"))return!0;let r=function(t){return t.lookBehind("#Noun+").last()}(e);return!r.has("(he|she|many|both)")&&(!!r.has("(we|they|you|i)")||!r.has("#Person")&&(!!r.has("#Plural")||!r.has("#Singular")&&(!e.has("(is|am|do|was)")&&(!(t.auxiliary.has("(is|am|do|was)")&&!t.negative.found)&&null))))};const In=$n,Bn=Vn;var zn=function(t){let e=t.lookBehind(),r=e.nouns(null,{keep_anaphora:!0}).last();return r.found||(r=e.match("(that|this|each)").last(),r=r.tag("#Noun").nouns()),r};const Sn=zn;const Dn=Vn;const Mn=$n,_n=t=>{let e=!1,r=Dn(t),n=t.negative.found;t.verb.lookBehind("i (#Adverb|#Verb)?$").found&&(e=!0);let i={PastTense:"was",PresentTense:"is",FutureTense:"will be",Infinitive:"is",Gerund:"being",Actor:"",PerfectTense:"been",Pluperfect:"been"};return r&&(i.PastTense="were",i.PresentTense="are",i.Infinitive="are"),!0===e&&(i.PastTense="was",i.PresentTense="am",i.Infinitive="am"),n&&(i.PastTense+=" not",i.PresentTense+=" not",i.FutureTense="will not be",i.Infinitive+=" not",i.PerfectTense="not "+i.PerfectTense,i.Pluperfect="not "+i.Pluperfect,i.Gerund="not "+i.Gerund),i},Gn=function(t){let e=t.verb.text();return{PastTense:e+" have",PresentTense:e,FutureTense:e,Infinitive:e}},Ln=Vn;var qn=function(t,e){let r=t.verb;if(r.has("#Copula")||"be"===r.out("normal")&&t.auxiliary.has("will"))return _n(t);if(t.auxiliary.has("are")&&r.has("#Gerund")){let r=t.original.clone(),n=r.clone().replace("are","were"),i=r.clone().replace("are","will be"),s=Mn(t,e);return{PastTense:n.text(),PresentTense:r.text(),FutureTense:i.text(),Infinitive:s}}if(r.has("#Modal"))return Gn(t);let n=Mn(t,e);if(!n)return{};let i=e.transforms.conjugate(n,e);i.Infinitive=n;let s=Ln(t);!0===s&&(i.PresentTense=i.Infinitive);let o=t.verb.termList(0).hasHyphen();if(t.particle.found){let e=t.particle.text(),r=!0===o?"-":" ";Object.keys(i).forEach(t=>i[t]+=r+e)}const l=t.negative.found;return i.FutureTense=i.FutureTense||"will "+i.Infinitive,l&&(i.PastTense="did not "+i.Infinitive,i.FutureTense="will not "+i.Infinitive,s?(i.PresentTense="do not "+i.Infinitive,i.Infinitive="do not "+i.Infinitive):(i.PresentTense="does not "+i.Infinitive,i.Infinitive="does not "+i.Infinitive),i.Gerund="not "+i.Gerund),i};const Wn=qn;var Un={useParticiple:function(t){return!!t.auxiliary.has("(could|should|would|may|can|must)")||(!!t.auxiliary.has("am .+? being")||!!t.auxiliary.has("had .+? been"))},toParticiple:function(t,e){if(t.auxiliary.has("(have|had)")&&t.verb.has("#Participle"))return;let r=Wn(t,e),n=r.Participle||r.PastTense;n&&t.verb.replaceWith(n,!1),t.auxiliary.has("am .+? being")&&(t.auxiliary.remove("am"),t.auxiliary.replace("being","have been")),t.auxiliary.has("have")||t.auxiliary.append("have"),t.verb.tag("Participle","toParticiple"),t.auxiliary.replace("can","could"),t.auxiliary.replace("be have","have been"),t.auxiliary.replace("not have","have not"),t.auxiliary.tag("Auxiliary")}};const Hn=function(t,e){let r=t.verb;if(!t.negative.found){if(t.auxiliary.found)return t.auxiliary.eq(0).append("not"),void(t.auxiliary.has("#Modal have not")&&t.auxiliary.replace("have not","not have"));if(r.has("(#Copula|will|has|had|do)"))r.append("not");else{if(r.has("#PastTense")){let n=In(t,e);return r.replaceWith(n,!0),void r.prepend("did not")}if(r.has("#PresentTense")){let n=In(t,e);return r.replaceWith(n,!0),void(Bn(t)?r.prepend("do not"):r.prepend("does not"))}if(r.has("#Gerund")){let n=In(t,e);return r.replaceWith(n,!0),void r.prepend("not")}Bn(t)?r.prepend("does not"):r.prepend("do not")}}},Rn=function(t){let e={adverb:t.match("#Adverb+"),negative:t.match("#Negative"),auxiliary:t.match("#Auxiliary+").not("(#Negative|#Adverb)"),particle:t.match("#Particle"),verb:t.match("#Verb+").not("(#Adverb|#Negative|#Auxiliary|#Particle)"),original:t,subject:Sn(t)};if(e.verb.has("(#PresentTense|#PastTense|#Infinitive) #Gerund$")&&(e.verb=e.verb.not("#Gerund$")),!e.verb.found)return Object.keys(e).forEach(t=>{e[t]=e[t].not(".")}),e.verb=t,e;if(e.adverb&&e.adverb.found){let r=e.adverb.text("reduced")+"$";t.has(r)&&(e.adverbAfter=!0)}return e},Qn=Vn,Zn=zn,Jn=qn,{toParticiple:Yn,useParticiple:Kn}=Un,Xn=function(t){return t.auxiliary.remove("(will|are|am|being)"),t.auxiliary.remove("(did|does)"),t.auxiliary.remove("(had|has|have)"),t.particle.remove(),t.negative.remove(),t};const ti={json:function(t){let e=null;"number"==typeof t&&(e=t,t=null),t=t||{text:!0,normal:!0,trim:!0,terms:!0};let r=[];return this.forEach(e=>{let n=e.json(t)[0],i=Rn(e);n.parts={},Object.keys(i).forEach(t=>{i[t]&&"Doc"===i[t].isA?n.parts[t]=i[t].text("normal"):n.parts[t]=i[t]}),n.isNegative=e.has("#Negative"),n.conjugations=Jn(i,this.world),r.push(n)}),null!==e?r[e]:r},adverbs:function(){let t=[];this.forEach(e=>{let r=Rn(e).adverb;r.found&&(t=t.concat(r.list))});let e=this.lookBehind("#Adverb+$");return e.found&&(t=e.list.concat(t)),e=this.lookAhead("^#Adverb+"),e.found&&(t=t.concat(e.list)),this.buildFrom(t)},isPlural:function(){let t=[];return this.forEach(e=>{let r=Rn(e);!0===Qn(r,this.world)&&t.push(e.list[0])}),this.buildFrom(t)},isSingular:function(){let t=[];return this.forEach(e=>{let r=Rn(e);!1===Qn(r,this.world)&&t.push(e.list[0])}),this.buildFrom(t)},conjugate:function(){let t=[];return this.forEach(e=>{let r=Rn(e),n=Jn(r,this.world);t.push(n)}),t},toPastTense:function(){return this.forEach(t=>{let e=Rn(t);if(Kn(e))return void Yn(e,this.world);if(t.has("#Imperative"))return;if(t.has("be")&&t.lookBehind("to$").found)return;if(e.verb.has("#Gerund")&&e.auxiliary.has("(is|will|was)"))return void t.replace("is","was");let r=Jn(e,this.world).PastTense;r&&(e=Xn(e),e.verb.replaceWith(r,!1),e.auxiliary.remove("(do|did|will)"))}),this},toPresentTense:function(){return this.forEach(t=>{if(t.has("#Imperative"))return;let e=Rn(t),r=Jn(e,this.world),n=r.PresentTense;if(t.lookBehind("(i|we) (#Adverb|#Verb)?$").found&&(n=r.Infinitive),n){if(e.auxiliary.has("(have|had) been"))return e.auxiliary.replace("(have|had) been","am being"),void(r.Particle&&(n=r.Particle||r.PastTense));e.verb.replaceWith(n,!1),e.verb.tag("PresentTense"),e=Xn(e),e.auxiliary.remove("#Modal"),e.auxiliary.remove("(do|did|will)")}}),this},toFutureTense:function(){return this.forEach(t=>{let e=Rn(t);if(Kn(e))return;if(t.has("#Imperative"))return;let r=Jn(e,this.world).FutureTense;r&&(e=Xn(e),e.auxiliary.remove("#Modal"),e.verb.replaceWith(r,!1),e.verb.tag("FutureTense"),e.auxiliary.remove("(do|did|will)"))}),this},toInfinitive:function(){return this.forEach(t=>{let e=Rn(t),r=Jn(e,this.world).Infinitive;r&&(t.replaceWith(r,!1),t.tag("Infinitive"))}),this},toGerund:function(){return this.forEach(t=>{let e=Rn(t),r=Jn(e,this.world).Gerund;r&&(t.replaceWith(r,!1),t.tag("Gerund"))}),this},toParticiple:function(){return this.forEach(t=>{let e=Rn(t),r=!e.auxiliary.found;Yn(e,this.world),r&&(e.verb.prepend(e.auxiliary.text()),e.auxiliary.remove())}),this},isNegative:function(){return this.if("#Negative")},isPositive:function(){return this.ifNo("#Negative")},isImperative:function(){return this.if("#Imperative")},toNegative:function(){return this.list.forEach(t=>{let e=this.buildFrom([t]),r=Rn(e);Hn(r,e.world)}),this},toPositive:function(){let t=this.match("do not #Verb");return t.found&&t.remove("do not"),this.remove("#Negative")},subject:function(){let t=[];return this.forEach(e=>{let r=Zn(e);r.list[0]&&t.push(r.list[0])}),this.buildFrom(t)}};const ei=tn,ri=[on,an,un,cn,hn,jn,Cn,Fn,Nn,function(t){class e extends t{}return Object.assign(e.prototype,ti),e.prototype.negate=e.prototype.toNegative,t.prototype.verbs=function(t){let r=this.match("(#Adverb|#Auxiliary|#Verb|#Negative|#Particle)+");r=r.not("^#Adverb+"),r=r.not("#Adverb+$");let n=r.match("(#Adverb && @hasComma) #Adverb"),i=r.not(n).splitAfter("@hasComma");return i=i.concat(n),i.sort("index"),i=i.if("#Verb"),i.has("(is|was)$")&&(i=i.splitBefore("(is|was)$")),i.has("#PresentTense #Adverb #PresentTense")&&(i=i.splitBefore("#Adverb #PresentTense")),"number"==typeof t&&(i=i.get(t)),new e(i.list,this,this.world)},t},function(t){class e extends t{}return t.prototype.people=function(t){let r=this.splitAfter("@hasComma");return r=r.match("#Person+"),"number"==typeof t&&(r=r.get(t)),new e(r.list,this,this.world)},t}];const ni={misc:Kr,selections:tn},ii=sn,si=Te,oi=function(t){return Object.keys(ei).forEach(e=>t.prototype[e]=ei[e]),ri.forEach(e=>e(t)),t};class li{constructor(t,e,r){this.list=t,Object.defineProperty(this,"from",{enumerable:!1,value:e,writable:!0}),void 0===r&&void 0!==e&&(r=e.world),Object.defineProperty(this,"world",{enumerable:!1,value:r,writable:!0}),Object.defineProperty(this,"_cache",{enumerable:!1,writable:!0,value:{}}),Object.defineProperty(this,"found",{get:()=>this.list.length>0}),Object.defineProperty(this,"length",{get:()=>this.list.length}),Object.defineProperty(this,"isA",{get:()=>"Doc"})}tagger(){return ii(this)}pool(){return this.list.length>0?this.list[0].pool:this.all().list[0].pool}}li.prototype.buildFrom=function(t){return t=t.map(t=>t.clone(!0)),new li(t,this,this.world)},li.prototype.fromText=function(t){let e=si(t,this.world,this.pool());return this.buildFrom(e)},Object.assign(li.prototype,ni.misc),Object.assign(li.prototype,ni.selections),oi(li);const ai={untag:"unTag",and:"match",notIf:"ifNo",only:"if",onlyIf:"if"};Object.keys(ai).forEach(t=>li.prototype[t]=li.prototype[ai[t]]);const ui=Te,ci=Ie,hi=li,fi=ne,pi=it,di=se,mi=sn,gi=qt;return function t(e){let r=e;const n=function(t="",e){e&&r.addWords(e);let n=ui(t,r),i=new hi(n,null,r);return i.tagger(),i};return n.tokenize=function(t="",e){let n=r;e&&(n=n.clone(),n.words={},n.addWords(e));let i=ui(t,n),s=new hi(i,null,n);return(e||s.world.taggers.length>0)&&mi(s),s},n.extend=function(t){return t(hi,r,this,fi,pi,di),this},n.fromJSON=function(t){let e=ci(t,r);return new hi(e,null,r)},n.clone=function(){return t(r.clone())},n.verbose=function(t=!0){return r.verbose(t),this},n.world=function(){return r},n.parseMatch=function(t,e){return gi(t,e)},n.version="13.11.4",n.import=n.load,n.plugin=n.extend,n}(new fr)}));