You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6 lines
412 KiB
JavaScript

4 years ago
!function(window,undefined){function makeClass(){return function(T){return this instanceof arguments.callee?void("function"==typeof this.init&&this.init.apply(this,T&&T.callee?T:arguments)):new arguments.callee(arguments)}}function printProgress(T,E,S){process&&process.stdout&&(process.stdout.clearLine(),process.stdout.cursorTo(0),process.stdout.write(T+E+"%"+(S?"\n":"")))}function is(T,E){return get(T)===E}function ok(T,S){if(get(T)!=S)throw TypeError("Expected "+(S?S.toUpperCase():S+E)+", but received "+(T?get(T).toUpperCase():T+E));return!0}function isNum(T){return!isNaN(parseFloat(T))&&isFinite(T)}function okeys(T){var E=[];for(var S in T)E.push(S);return E}function err(){for(var T="[RiTa] "+arguments[0],E=1;E<arguments.length;E++)T+="\n"+arguments[E];throw Error(T)}function warn(){if(!RiTa.SILENT&&console&&arguments&&arguments.length){console.warn("[WARN] "+arguments[0]);for(var T=1;T<arguments.length;T++)console.warn(arguments[T])}}function log(){!RiTa.SILENT&&console&&console.log.apply(console,arguments)}function strOk(T){return typeof T===S&&T.length>0}function trim(T){return strOk(T)?T.replace(/^\s\s*/,"").replace(/\s\s*$/,""):T}function last(T){return T&&T.length?T.charAt(T.length-1):E}function extend(T,E){for(var S=0;S<E.length;S++)T.push(E[S])}function endsWith(T,E){return!!is(T,S)&&new RegExp(E+"$").test(T)}function startsWith(T,E){return!!is(T,S)&&new RegExp("^"+E).test(T)}function equalsIgnoreCase(T,E){return!(!is(T,S)||!is(E,S))&&T.toLowerCase()===E.toLowerCase()}function isNode(){return"undefined"!=typeof module&&module.exports}function shuffle(T){for(var E=T.slice(),S=E.length,A=S;A--;){var e=parseInt(Math.random()*S),n=E[A];E[A]=E[e],E[e]=n}return E}function inArray(T,E){return!!T&&T.indexOf(E)>-1}function escapeRegExp(T){return T.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")}function get(T){if("undefined"!=typeof T)return{}.toString.call(T).match(/\s([a-zA-Z]+)/)[1].toLowerCase()}function tagForPENN(T){if(!T||!T.length)return EA;var E=is(T,S)?RiTa.tokenize(T):T;return PosTagger.tag(E)}function tagForWordNet(T){var E,S=tagForPENN(T);if(T&&S.length){for(var A=0;A<S.length;A++)E=S[A],S[A]="-",PosTagger.isNoun(E)?S[A]="n":PosTagger.isVerb(E)?S[A]="v":PosTagger.isAdverb(E)?S[A]="r":PosTagger.isAdj(E)&&(S[A]="a");return S}return EA}function initFeatureMap(T){T._features?["tokens","stresses","phonemes","syllables","pos"].forEach(function(E){delete T._features[E]}):T._features={},T._features.text=T.text()}function checkPluralNoLex(T){for(var E=[categoryUM_A,categoryON_A,categoryO_I,categoryUS_I,categoryIX_ICES],S=0;S<E.length;S++)if(E[S].indexOf(T)>-1)return!0;var A=categoryIRR.indexOf(T);return A%2===0}function _dict(){return{a:["ey1","dt"],able:["ey1 b-ah-l","jj"],about:["ah b-aw1-t","in jj rb rp rbr"],above:["ah b-ah1-v","in jj rb"],act:["ae1-k-t","nn vbp vb"],add:["ae1-d","vb vbp"],afraid:["ah f-r-ey1-d","jj"],after:["ae1-f t-er","in rb rp"],again:["ah g-eh1-n","rb"],against:["ah g-eh1-n-s-t","in"],age:["ey1-jh","nn vb vbp"],ago:["ah g-ow1","rb in"],agree:["ah g-r-iy1","vb vbp"],air:["eh1-r","nn vb"],all:["ao1-l","dt rb pdt"],allow:["ah l-aw1","vb vbp"],also:["ao1-l s-ow","rb ."],always:["ao1-l w-ey-z","rb"],am:["ae1-m","vbp rb"],among:["ah m-ah1-ng","in"],an:["ae1-n","dt cc jj nnp"],and:["ae1-n-d","cc jj rb nnp"],anger:["ae1-ng g-er","nn vb vbp"],animal:["ae1 n-ah m-ah-l","nn jj"],answer:["ae1-n s-er","nn vb vbp"],any:["eh1 n-iy","dt rb"],appear:["ah p-ih1-r","vb vbp"],apple:["ae1 p-ah-l","nn"],are:["aa1-r","vbp nnp"],area:["eh1 r-iy ah","nn"],arm:["aa1-r-m","nn vb"],arrange:["er ey1-n-jh","vb vbp"],arrive:["er ay1-v","vb vbp"],art:["aa1-r-t","nn"],as:["ae1-z","in nnp jj rb"],ask:["ae1-s-k","vb vbp"],at:["ae1-t","in rb rp"],atom:["ae1 t-ah-m","nn"],baby:["b-ey1 b-iy","nn uh"],back:["b-ae1-k","rb in jj nn rp vb vbp"],bad:["b-ae1-d","jj nn rb"],ball:["b-ao1-l","nn vb"],band:["b-ae1-n-d","nn vb"],bank:["b-ae1-ng-k","nn vbp vb"],bar:["b-aa1-r","nn vb vbp"],base:["b-ey1-s","nn vbp jj vb"],basic:["b-ey1 s-ih-k","jj nn"],bat:["b-ae1-t","nn vb"],be:["b-iy1","vb"],bear:["b-eh1-r","vb nn vbp"],beat:["b-iy1-t","vb
yet:["y-eh1-t","rb cc"],you:["y-uw1","prp rp"],young:["y-ah1-ng","jj"],your:["y-ao1-r","prp$"]}}for(var E="",SP=" ",EA=[],N="number",S="string",O="object",A="array",B="boolean",R="regexp",F="function",BN="\n",FEATURES=["tokens","stresses","phonemes","syllables","pos","text"],RiTa={VERSION:"1.3.11",SPLIT_CONTRACTIONS:!1,JAVA:1,JS:2,NODE:3,DATA_LOADED:"DataLoaded",INTERNAL:"Internal",UNKNOWN:"Unknown",FIRST_PERSON:1,SECOND_PERSON:2,THIRD_PERSON:3,PAST_TENSE:4,PRESENT_TENSE:5,FUTURE_TENSE:6,SINGULAR:7,PLURAL:8,NORMAL:9,FEATURE_DELIM:":",STRESSED:"1",UNSTRESSED:"0",PHONEME_BOUNDARY:"-",WORD_BOUNDARY:" ",SYLLABLE_BOUNDARY:"/",SENTENCE_BOUNDARY:"|",VOWELS:"aeiou",ABBREVIATIONS:["Adm.","Capt.","Cmdr.","Col.","Dr.","Gen.","Gov.","Lt.","Maj.","Messrs.","Mr.","Mrs.","Ms.","Prof.","Rep.","Reps.","Rev.","Sen.","Sens.","Sgt.","Sr.","St.","a.k.a.","c.f.","i.e.","e.g.","vs.","v.","Jan.","Feb.","Mar.","Apr.","Mar.","Jun.","Jul.","Aug.","Sept.","Oct.","Nov.","Dec."],LEX_WARN:"A minimal Lexicon is currently in use. For word features outside the lexicon, use a larger version of RiTa.",LTS_WARN:"No LTS-rules found: features/tagging may be inaccurate!",INFINITIVE:1,GERUND:2,IMPERATIVE:3,BARE_INFINITIVE:4,SUBJUNCTIVE:5,SILENT:!1,LANCASTER:"Lancaster",PORTER:"Porter",PLING:"Pling",NON_BREAKING_SPACE:"<sp/>",PARAGRAPH_BREAK:"<p/>",LINE_BREAK:"<br/>",STOP_WORDS:[".",",","the","and","a","of",'"',"in","i",":","you","is","to","that",")","(","it","for","on","!","have","with","?","this","be","...","not","are","as","was","but","or","from","my","at","if","they","your","all","he","by","one","me","what","so","can","will","do","an","about","we","just","would","there","no","like","out","his","has","up","more","who","when","don't","some","had","them","any","their","it's","only",";","which","i'm","been","other","were","how","then","now","her","than","she","well","also","us","very","because","am","here","could","even","him","into","our","much","too","did","should","over","want","these","may","where","most","many","those","does","why","please","off","going","its","i've","down","that's","can't","you're","didn't","another","around","must","few","doesn't","every","yes","each","maybe","i'll","away","doing","oh","else","isn't","he's","there's","hi","won't","ok","they're","yeah","mine","we're","what's","shall","she's","hello","okay","here's","-","less"],stemmers:{},random:function(){var T=Math.random();return arguments.length?1===arguments.length?T*arguments[0]:T*(arguments[1]-arguments[0])+arguments[0]:T},randomItem:function(T){return T[Math.floor(Math.random()*T.length)]},distance:function(T,E,S,A){var e=T-S,n=E-A;return Math.sqrt(e*e+n*n)},getPosTags:function(T,E){return E?tagForWordNet(T):tagForPENN(T)},getPosTagsInline:function(T,A){if(!T||!T.length)return E;A=A||"/",T=is(T,S)?RiTa.tokenize(T):T;for(var e=E,n=RiTa.getPosTags(T),t=0;t<T.length;t++)e+=T[t],RiTa.isPunctuation(T[t])||(e+=A+n[t]),e+=SP;return e.trim()},getPresentParticiple:function(T){return Conjugator().getPresentParticiple(T)},getPastParticiple:function(T){return Conjugator().getPastParticiple(T)},concordance:function(T,E){return Concorder(T,E).concordance()},kwic:function(T,E,S){return wordCount=S&&S.wordCount||4,Concorder(T,S).kwic(E,wordCount)},conjugate:function(T,E){return Conjugator().conjugate(T,E)},upperCaseFirst:function(T){return T.charAt(0).toUpperCase()+T.substring(1)},pluralize:function(T){if(!strOk(T))return E;var S,A,e=PLURAL_RULES;if(inArray(MODALS,T.toLowerCase()))return T;for(S=0;S<e.length;S++)if(A=e[S],A.applies(T.toLowerCase()))return A.fire(T);return DEFAULT_PLURAL_RULE.fire(T)},singularize:function(T){if(!strOk(T))return E;var S,A,e=SINGULAR_RULES;if(inArray(MODALS,T.toLowerCase()))return T;for(S=e.length;S--;)if(A=e[S],A.applies(T.toLowerCase()))return A.fire(T);return this.stem(T,"Pling")},trim:function(T){return trim(T)},tokenize:function(T,A){return is(T,S)?A?T.split(A):(T=trim(T),T=T.replace(/([\\?!\"\u201C\\.,;:@#$%&])/g," $1 "),T=T.replace(/\\.\\.\\./g," ... "),T=T.replace(/\\s+/g,SP),T=T.replace(/,([^0-9])/g," , $1"),T=T.replace(/([^.])([.])([\])}>\"']*)\\s*$/g,"
return this._text.length},match:function(T){return this._text.match(T)||[]},slice:function(T,S){return this._text.slice(T,S)||E},insertChar:function(T,E){var S=this.text();if(T>S.length||T<-S.length)return warn("RiString.insertChar: bad index="+T),this;T=T<0?T+=S.length:T;var A=S.substring(0,T),e=S.substring(T);return E&&(A+=E),this.text(A+e)},removeChar:function(T){var E=this.text();return T>E.length||T<-E.length?(warn("RiString.removeChar: bad index="+T),this):(T=T<0?T+=E.length:T,this.text(this._text.substring(0,T).concat(this._text.substring(T+1))),this)},replaceChar:function(T,E){var S=this.text();if(T>S.length||T<-S.length)return warn("RiString.replaceChar: bad index="+T),this;T=T<0?T+=S.length:T,S=this.text();var A=S.substring(0,T),e=S.substring(T+1);return E&&(A+=E),this.text(A+e)},replaceFirst:function(T,E){if(T&&!is(T,S)&&T.global){var A="";T.ignoreCase&&(A+="i"),T.multiline&&(A+="m"),T.sticky&&(A+="y"),T=new RegExp(T.source,A)}return this._text=this._text.replace(T,E),this},replaceAll:function(T,E){var A="g";return T&&(E||""===E)&&(!is(T,S)&&T.source?(T.ignoreCase&&(A+="i"),T.multiline&&(A+="m"),T.sticky&&(A+="y"),T=T.source):T=escapeRegExp(T),this._text=this._text.replace(new RegExp(T,A),E)),this},removeWord:function(T){return this.replaceWord(T,E)},insertWord:function(T,E){var S=this.words();return T<0&&(T+=S.length),E&&E.length>=0&&T>=0&&T<S.length&&(S[T]=E+SP+S[T],this.text(RiTa.untokenize(S))),this},toCharArray:function(){return this._text.split(RiTa.E)},replaceWord:function(T,S){var A=this.words();return T<0&&(T+=A.length),(S||S===E)&&T>=0&&T<A.length&&(A[T]=S,this.text(RiTa.untokenize(A))),this},split:function(T,E){for(var S=this._text.split(T,E),A=[],e=0;e<S.length;e++)S[e]&&A.push(new RiString(S[e]));return A},startsWith:function(T){return 0===this.indexOf(T)},substr:function(T,E){return this._text.substr(T,E)},substring:function(T,E){return this._text.substring(T,E)},toLowerCase:function(){return this.text(this._text.toLowerCase())},toString:function(){return"["+this._text+"]"},toUpperCase:function(){return this.text(this._text.toUpperCase())},trim:function(){return this.text(trim(this._text))},charAt:function(T){return this._text.charAt(T)},concat:function(T){return this._text.concat(T.text())}};var RiGrammar=makeClass(),OR_PATT=/\s*\|\s*/,STRIP_TICKS=/`([^`]*)`/g,PROB_PATT=/(.*[^\s])\s*\[([0-9.]+)\](.*)/;RiGrammar.START_RULE="<start>",RiGrammar.EXEC_PATT=/(.*?)(`[^`]+?\(.*?\);?`)(.*)/,RiGrammar.prototype={init:function(T){this._rules={},this.execDisabled=!1,T&&(is(T,S)||is(T,O)&&typeof T.loadStrings!==F)&&this.load(T)},ready:function(T){return okeys(this._rules).length>0},loadFrom:function(T,E){RiTa.loadStrings(T,function(T){T=T.join(BN),this.load(T),is(E,F)&&E(T)}.bind(this))},load:function(T){if(this.reset(),is(T,S)){if("undefined"!=typeof YAML)try{T=YAML.parse(T)}catch(E){warn("YAML parsing failed, trying JSON")}if(!is(T,O))try{T=JSON.parse(T)}catch(E){var A=E}}if(!A&&is(T,O)){for(var e in T)this.addRule(e,T[e]);return this}if("undefined"!=typeof YAML)err("Grammar appears to be invalid JSON/YAML, please check it! (http://jsonlint.com/ or http://yamllint.com/)",T);else{var n=RiTa.env()===RiTa.NODE,t=n?"require":"include",r=n?"YAML = require('yamljs')":'<script src="yaml.min.js"></script>';err("Grammar appears to be invalid JSON, please check it at http://jsonlint.com/. If you are using YAML, be sure to "+t+" yamljs (https://github.com/jeremyfa/yaml.js), e.g. "+r,T)}},addRule:function(T,E,S){var e=!1;S=S||1,e&&log('addRule: "'+T+'" : "'+E+'" ['+get(E)+"]");var n=E;is(E,A)||(n=E.split(OR_PATT));for(var t=0;t<n.length;t++){var r=n[t],i=S,s=PROB_PATT.exec(r);if(s){if(e)for(log("Found weight for "+r),t=0;t<s.length;t++)log(" "+t+") '"+s[t]+"'");r=s[1]+s[3],i=s[2],e&&log("weight="+i+" rule='"+r+"'")}if(this.hasRule(T)){e&&log("rule exists");var a=this._rules[T];a[r]=i}else{var o={};o[r]=i,this._rules[T]=o,e&&log("added rule: "+T)}}return this},removeRule:function(T){return delete this._rules[T],this},reset:function(){return this._rules={},this},doRule:function(T){var S=function(T){var E,S,A=!1,
RiTa.stemmers.Pling=function(){function T(T,E){return T.substring(0,T.length-E.length)}function E(T){return T.indexOf("h")>0||T.indexOf("j")>0||T.indexOf("k")>0||T.indexOf("w")>0||T.indexOf("y")>0||T.indexOf("z")>0||T.indexOf("ou")>0||T.indexOf("sh")>0||T.indexOf("ch")>0||T._endsWith("aus")}function S(T){return T.indexOf("ph")>0||T.indexOf("y")>0&&T._endsWith("nges")}function A(A){if(categoryIRR._arrayContains(A)){var e,n=categoryIRR.indexOf(A);return n%2==0&&(e=categoryIRR[n+1]),e}return categoryON_A._arrayContains(A)?T(A,"a")+"on":categoryUM_A._arrayContains(A)?T(A,"a")+"um":categoryIX_ICES._arrayContains(A)?T(A,"ices")+"ix":categoryO_I._arrayContains(A)?T(A,"i")+"o":categorySE_SES._arrayContains(A)?T(A,"s"):categoryIS_ES._arrayContains(A)||A._endsWith("theses")?T(A,"es")+"is":categoryUS_I._arrayContains(A)?T(A,"i")+"us":A._endsWith("uses")&&(categoryUS_I._arrayContains(T(A,"uses")+"i")||"genuses"===A||"corpuses"===A)?T(A,"es"):categoryEX_ICES._arrayContains(A)?T(A,"ices")+"ex":A._endsWith("ois")||A._endsWith("itis")||category00._arrayContains(A)||categoryICS._arrayContains(A)?A:A._endsWith("ina")?T(A,"en"):A._endsWith("ae")&&"pleae"!==A?T(A,"e"):A._endsWith("ata")?T(A,"ta"):A._endsWith("trices")?T(A,"trices")+"trix":!A._endsWith("us")||A._endsWith("eaus")||A._endsWith("ieus")||E(A)||categoryU_US._arrayContains(A)?A._endsWith("teeth")?T(A,"teeth")+"tooth":A._endsWith("geese")?T(A,"geese")+"goose":A._endsWith("feet")?T(A,"feet")+"foot":A._endsWith("zoa")?T(A,"zoa")+"zoon":A._endsWith("men")?T(A,"men")+"man":A._endsWith("inis")?T(A,"inis")+"ini":A._endsWith("children")?T(A,"ren"):A._endsWith("eaux")?T(A,"x"):A._endsWith("ieux")?T(A,"x"):A._endsWith("nges")&&S(A)?T(A,"nges")+"nx":A._endsWith("shes")||A._endsWith("ches")&&!categoryCHE_CHES._arrayContains(A)?T(A,"es"):!A._endsWith("sses")||categorySSE_SSES._arrayContains(A)||A._endsWith("mousses")?A._endsWith("xes")&&"axes"!==A?T(A,"es"):A._endsWith("nives")||A._endsWith("lives")&&!A._endsWith("olives")||A._endsWith("wives")?T(A,"ves")+"fe":A._endsWith("alves")&&!A._endsWith("valves")||A._endsWith("olves")&&!A._endsWith("solves")||A._endsWith("eaves")&&!A._endsWith("heaves")&&!A._endsWith("weaves")||A._endsWith("arves")||A._endsWith("shelves")||A._endsWith("selves")?T(A,"ves")+"f":A._endsWith("ies")&&!categoryIE_IES._arrayContains(A)?T(A,"ies")+"y":A._endsWith("oes")&&!categoryOE_OES._arrayContains(A)?T(A,"es"):A._endsWith("ses")||A._endsWith("zes")?T(A,"es"):!A._endsWith("s")||A._endsWith("ss")||A._endsWith("is")?A:T(A,"s"):T(A,"es"):A}return function(T){return A(T.toLowerCase())}}(),Array.prototype._arrayContains=function(T){return this.indexOf(T)>-1},String.prototype._endsWith=function(T){return this.indexOf(T,this.length-T.length)!==-1};var MinEditDist={_min3:function(T,E,S){var A=T;return E<A&&(A=E),S<A&&(A=S),A},_computeRawArray:function(T,E){var S,A,e,n,t,r,i,s=[];if(!T.length)return E.length;if(!E.length)return T.length;for(n=0,r=T.length;n<=r;n++)s[n]=[],s[n][0]=n;for(t=0,i=E.length;t<=i;t++)s[0][t]=t;for(n=1,r=T.length;n<=r;n++)for(S=T[n-1],t=1,i=E.length;t<=i;t++)A=E[t-1],e=S===A?0:1,s[n][t]=this._min3(s[n-1][t]+1,s[n][t-1]+1,s[n-1][t-1]+e);return s[T.length][E.length]},computeRaw:function(T,E){if(is(T,A))return this._computeRawArray(T,E);if(!T.length&&!E.length)return 0;var S,e,n,t,r,i=[],s=T.length,a=E.length;if(!s)return a;if(!a)return s;for(S=0;S<=s;S++)i[S]=[],i[S][0]=S;for(e=0;e<=a;e++)i[0][e]=e;for(S=1;S<=s;S++)for(t=T.charAt(S-1),e=1;e<=a;e++)r=E.charAt(e-1),n=t==r?0:1,i[S][e]=this._min3(i[S-1][e]+1,i[S][e-1]+1,i[S-1][e-1]+n);return i[s][a]},computeAdjusted:function(T,E){var e=get(T),n=get(T);if(e===n){if(n===S)return T.length||E.length?this.computeRaw(T,E)/Math.max(T.length,E.length):0;if(n===A)return T.length||E.length?this._computeRawArray(T,E)/Math.max(T.length,E.length):0}err("Unexpected args: "+T+"/"+E)}},Concorder=makeClass();Concorder.prototype={init:function(T,E){this.model=null,this.wordsToIgnore=[],this.ignoreCase=!1,this.ignoreStopWords=!1,this.ignorePunctuation=!1,E&&(E.ignoreCase&&(this.ignoreCase=!0),E.ignoreStopWords&&(this.ignoreStopWord
name:"PAST_PARTICIPLE",defaultRule:RE(ANY_STEM,0,"ed",2),rules:PAST_PARTICIPLE_RULES,doubling:!0},PRESENT_PARTICIPLE_RULESET={name:"ING_FORM",defaultRule:RE(ANY_STEM,0,"ing",2),rules:ING_FORM_RULES,doubling:!0},PAST_TENSE_RULESET={name:"PAST_TENSE",defaultRule:RE(ANY_STEM,0,"ed",2),rules:PAST_TENSE_RULES,doubling:!0},PRESENT_TENSE_RULESET={name:"PRESENT_TENSE",defaultRule:RE(ANY_STEM,0,"s",2),rules:PRESENT_TENSE_RULES,doubling:!1};RiTa.SILENT||isNode()||!console||console.log("[INFO] RiTaJS.version ["+RiTa.VERSION+"]");var LetterToSound=makeClass();LetterToSound.prototype={init:function(){this.warnedForNoLTS=!1,this.letterIndex={},this.fval_buff=[],this.stateMachine=null,this.numStates=0;for(var T=0;T<LetterToSound.RULES.length;T++)this.parseAndAdd(LetterToSound.RULES[T])},_createState:function(T,E){if("STATE"===T){var S=parseInt(E.nextToken()),A=E.nextToken(),e=parseInt(E.nextToken()),n=parseInt(E.nextToken());return new DecisionState(S,A.charAt(0),e,n)}if("PHONE"===T)return new FinalState(E.nextToken());throw Error("Unexpected type: "+T)},parseAndAdd:function(T){var E=new StringTokenizer(T,SP),S=E.nextToken();if("STATE"===S||"PHONE"===S)this.stateMachine[this.numStates++]=this._createState(S,E);else if("INDEX"===S){var A=parseInt(E.nextToken());if(A!=this.numStates)throw Error("Bad INDEX in file.");var e=E.nextToken();this.letterIndex[e]=A}else"TOTAL"==S&&(this.stateMachine=[],this.stateMachineSize=parseInt(E.nextToken()))},getPhones:function(T,A){var e,n,t=[];if(A=A||"-",is(T,S)){if(!T.length)return E;T=RiTa.tokenize(T)}for(e=0;e<T.length;e++)n=this._computePhones(T[e]),t[e]=n?n.join(A):E;if(t=t.join(A).replace(/ax/g,"ah"),t.replace("/0/g",""),t.length>0&&t.indexOf("1")===-1&&t.indexOf(" ")===-1){n=t.split("-"),t="";for(var e=0;e<n.length;e++)/[aeiou]/.test(n[e])&&(n[e]+="1"),t+=n[e]+"-";n.length>1&&(t=t.substring(0,t.length-1))}return t},_computePhones:function(T){var S,A,e,n,t,r,i,s=[],a=4;if(!T||!T.length||RiTa.isPunctuation(T))return null;if(!LetterToSound.RULES)return this.warnedForNoLTS||(this.warnedForNoLTS=!0,console.warn("[WARN] No LTS-rules found: for word features outside the lexicon, use a larger version of RiTa.")),null;if(T=T.toLowerCase(),isNum(T)){T=T.length>1?T.split(E):[T];for(var o=0;o<T.length;o++){if(S=parseInt(T[o]),S<0||S>9)throw Error("Attempt to pass multi-digit number to LTS: '"+T+"'");s.push(RiString._phones.digits[S])}return s}e="000#"+T.trim()+"#000",A=e.split(E);for(var h=0;h<T.length;h++){for(var l=0;l<a;l++)this.fval_buff[l]=A[h+l],this.fval_buff[l+a]=A[l+h+1+a];if(i=T.charAt(h),t=this.letterIndex[i],!isNum(t))return warn("Unable to generate LTS for '"+T+"'\n No LTS index for character: '"+i+"', isDigit="+isNum(i)+", isPunct="+RiTa.isPunctuation(i)),null;for(r=parseInt(t),n=this.getState(r);!(n instanceof FinalState);)r=n.getNextState(this.fval_buff),n=this.getState(r);n.append(s)}return s},getState:function(T){if(is(T,N)){var E=null;return E=is(this.stateMachine[T],S)?this.getState(this.stateMachine[T]):this.stateMachine[T]}var A=new StringTokenizer(T," ");return this.getState(A.nextToken(),A)}};var DecisionState=makeClass();DecisionState.TYPE=1,DecisionState.prototype={init:function(T,E,S,A){this.c=E,this.index=T,this.qtrue=S,this.qfalse=A},type:function(){return"DecisionState"},getNextState:function(T){return T[this.index]==this.c?this.qtrue:this.qfalse}};var FinalState=makeClass();FinalState.TYPE=2,FinalState.prototype={init:function(T){if(this.phoneList=[],"epsilon"===T)this.phoneList=null;else if(is(T,A))this.phoneList=T;else{var E=T.indexOf("-");E!=-1?(this.phoneList[0]=T.substring(0,E),this.phoneList[1]=T.substring(E+1)):this.phoneList[0]=T}},type:function(){return"FinalState"},append:function(T){if(this.phoneList)for(var E=0;E<this.phoneList.length;E++)T.push(this.phoneList[E])}},LetterToSound.RULES=["TOTAL 13100","INDEX 0 a","STATE 4 r 2 1","STATE 6 0 4 3","STATE 3 e 6 5","STATE 4 u 8 7","STATE 4 y 10 9","STATE 3 w 12 11","STATE 5 t 14 13","STATE 3 e 16 15","STATE 3 e 18 17","STATE 4 # 20 19","STATE 3 w 22 21","STATE 1 0 24 23","STATE 5 e 26 25","STATE 5 n 28 27","STATE
RiTa.lexicon=RiLexicon();for(var funs=okeys(RiTa.lexicon),i=0;i<funs.length;i++)if(!startsWith(funs[i],"_")){var f=RiTa.lexicon[funs[i]];is(f,F)&&(RiTa[funs[i]]=f.bind(RiTa.lexicon))}if(window){window.RiTa=RiTa,window.RiString=RiString,window.RiGrammar=RiGrammar,window.RiMarkov=RiMarkov,window.RiWordNet=RiWordNet,window.RiLexicon=RiLexicon,window.RiTaEvent=RiTaEvent;var rlfuns=okeys()}else if("undefined"!=typeof module){module.exports.RiTa=RiTa,module.exports.RiString=RiString,module.exports.RiGrammar=RiGrammar,module.exports.RiMarkov=RiMarkov,module.exports.RiWordNet=RiWordNet,module.exports.RiLexicon=RiLexicon,module.exports.RiTaEvent=RiTaEvent;for(var funs=okeys(RiTa),i=0;i<funs.length;i++)startsWith(funs[i],"_")||(module.exports[funs[i]]=RiTa[funs[i]])}}("undefined"!=typeof window?window:null);