-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgibberish.min.js
1 lines (1 loc) · 4.93 KB
/
gibberish.min.js
1
var matrix={thresh:0.04,mat:[[-8.57,-3.94,-3.22,-3.05,-6.05,-4.7,-3.99,-6.71,-3.25,-7.06,-4.51,-2.5,-3.64,-1.57,-7.98,-3.89,-9.82,-2.3,-2.35,-1.94,-4.54,-3.87,-4.71,-6.56,-3.65,-6.64,-2.71],[-2.55,-5.14,-6.05,-6.22,-1.17,-8.56,-8.81,-8.49,-3.33,-5,-8.81,-2.14,-6.12,-6.81,-2.15,-8.31,-8.9,-2.72,-3.79,-4.7,-2.14,-6.32,-7.68,-8.9,-2.36,-8.9,-4.74],[-2.09,-9.4,-3.85,-7.68,-1.74,-8.79,-9.58,-1.91,-2.93,-9.49,-3.34,-3.28,-8.52,-8.84,-1.6,-9.49,-6.39,-3.38,-5.84,-2.39,-3.22,-9.49,-8.84,-9.58,-4.62,-8.3,-3.87],[-3.72,-7.42,-7.89,-4.56,-1.97,-6.8,-5.43,-6.75,-2.46,-6.28,-7.67,-4.56,-5.52,-5.95,-3.12,-8.38,-8.14,-3.62,-3.68,-7.19,-3.99,-5.57,-7.08,-9.93,-4.61,-9.75,-0.54],[-3.1,-6.33,-3.71,-2.41,-3.73,-4.56,-4.96,-6.34,-4.47,-8.04,-7.01,-3.44,-3.75,-2.39,-5.28,-4.43,-6.27,-1.98,-2.52,-3.73,-6.05,-4.12,-4.72,-4.45,-4.54,-7.73,-1.13],[-2.76,-7.91,-7.53,-8.49,-2.45,-2.93,-7.61,-8.54,-2.45,-9.03,-8.73,-3.75,-8.84,-7.67,-1.9,-8.31,-9.37,-2.36,-5.93,-3.32,-3.51,-9.37,-7.8,-9.37,-6.14,-9.37,-1],[-2.68,-8.56,-8.08,-6.89,-1.96,-7.92,-4.62,-2.22,-2.86,-9.15,-8.56,-3.36,-6.08,-3.74,-2.83,-7.95,-9.05,-2.55,-4.06,-4.94,-3.49,-9.15,-7.58,-9.15,-5.88,-8.62,-1.03],[-1.89,-7.39,-8.05,-7.54,-0.73,-7.86,-9.59,-8.78,-2,-10.1,-7.89,-6.64,-6.26,-6.71,-2.56,-9.25,-10.1,-4.57,-6.22,-3.76,-4.62,-9.54,-7.38,-10.28,-5.02,-10.19,-2.36],[-3.71,-4.72,-2.78,-3.22,-3.17,-3.9,-3.68,-9.12,-6.42,-10.32,-5.24,-3.08,-3.17,-1.31,-2.66,-4.92,-7.9,-3.41,-2.05,-2.1,-6.51,-3.82,-9.67,-6.17,-10.41,-5.51,-3.79],[-2.34,-6.1,-6.04,-6.51,-1.42,-6.25,-6.17,-6.33,-5.51,-6.51,-6.25,-6.41,-6.33,-6.51,-1.28,-6.41,-6.33,-6.1,-6.1,-6.25,-1.1,-6.51,-6.25,-6.51,-6.51,-6.51,-4.86],[-3.62,-7.05,-6.06,-7.67,-1.21,-6.29,-6.82,-3.63,-1.79,-7.81,-7.49,-3.89,-6.04,-2.35,-3.84,-7.55,-7.98,-5.48,-3,-6.69,-3.74,-7.24,-5.44,-8.08,-4.68,-8.08,-1.43],[-2.27,-6.57,-5.75,-2.86,-1.78,-4.14,-6.84,-7.74,-2.18,-9.7,-4.96,-2.07,-5.06,-6.49,-2.45,-5.6,-9.7,-5.65,-3.88,-3.86,-3.82,-5.09,-5.47,-9.88,-2.33,-8.6,-2.04],[-1.75,-3.68,-6.56,-8.44,-1.37,-6.41,-9.34,-8.24,-2.44,-9.17,-8.9,-6.21,-3.64,-5.66,-2.23,-2.7,-9.43,-5.5,-3.54,-6.91,-3.47,-9.25,-8.07,-9.43,-3.42,-9.43,-1.9],[-3.41,-6.73,-3.09,-1.74,-2.5,-4.82,-2.11,-6.81,-3.3,-6.25,-4.92,-4.63,-5.99,-4.67,-2.88,-7.6,-6.86,-7.19,-3.05,-2.26,-4.9,-5.35,-7.15,-7.45,-4.55,-8.81,-1.47],[-5.08,-5.14,-4.28,-4.09,-5.76,-2.17,-5.29,-6.09,-4.47,-6.91,-4.43,-3.23,-2.82,-1.77,-3.52,-3.95,-8.99,-2.17,-3.37,-3.12,-2.21,-3.55,-3.14,-6.66,-5.51,-7.7,-2.21],[-2.14,-7.65,-6.52,-8.5,-1.73,-6.5,-7.79,-3.64,-2.65,-8.45,-7.86,-2.39,-6.36,-7.29,-2.12,-2.79,-9.2,-1.79,-3.85,-3.29,-3.2,-9.2,-7.08,-9.2,-4.99,-9.2,-2.94],[-6.18,-6.18,-6.18,-6.18,-6.18,-6.18,-6.18,-6.18,-6.18,-6.18,-6.18,-6.18,-6.18,-6.18,-6.18,-6.18,-6.18,-6.18,-6.18,-6.18,-0.06,-6.18,-6.18,-6.18,-6.18,-6.18,-5.54],[-2.57,-5.99,-4.32,-3.73,-1.42,-5.36,-4.33,-6.03,-2.36,-9.41,-4.85,-4.67,-3.75,-3.92,-2.32,-5.41,-9.04,-3.64,-2.9,-3.23,-3.98,-4.91,-6.26,-10.14,-3.26,-8.07,-1.73],[-3.21,-6.33,-4.09,-7.59,-2.16,-6.18,-7.85,-2.92,-2.78,-9.55,-4.55,-4.71,-4.59,-6.24,-2.97,-3.85,-7.01,-8.24,-2.81,-2.12,-3.26,-7.87,-5.38,-10.38,-5.2,-9.91,-0.99],[-3.17,-8.22,-5.88,-9.53,-2.34,-7.17,-8.48,-1.11,-2.37,-10.46,-9.69,-4.42,-6.03,-7.22,-2.34,-8.16,-10.72,-3.46,-3.68,-4.03,-3.9,-9.56,-5.18,-10.13,-4.2,-7.98,-1.58],[-3.69,-3.73,-3.25,-4.02,-3.28,-5.02,-3.19,-7.8,-3.73,-9.35,-6.21,-2.26,-3.41,-2.09,-6.1,-3.1,-8.95,-1.91,-1.97,-1.96,-9.27,-6.78,-9.35,-7.32,-7.37,-5.27,-3.27],[-2.47,-8.47,-8.56,-7.87,-0.52,-8.56,-8.3,-8.47,-1.74,-8.47,-7.92,-5.44,-8.56,-4.57,-2.79,-8.56,-8.56,-6.27,-4.41,-7.97,-6.29,-8.38,-8.03,-8.47,-5.26,-8.56,-3.12],[-1.6,-7.6,-7.64,-5.34,-1.89,-6.84,-8.11,-1.62,-1.76,-8.87,-7,-5.47,-8.18,-3.22,-2.52,-8.29,-9.21,-4.57,-4.24,-5.65,-7.56,-9.21,-7.31,-9.21,-6.88,-9.03,-2.17],[-2.25,-6.9,-2.03,-6.49,-2.46,-5.83,-6.9,-4.31,-2.07,-6.9,-6.9,-6.43,-6.72,-6.9,-4.46,-1.5,-6.37,-4.64,-5.77,-1.87,-4.37,-4.35,-6.8,-4.47,-5.18,-6.9,-2.56],[-3.87,-6.08,-5.61,-6.15,-2.92,-5.83,-7,-7.32,-3.83,-8.86,-7.45,-4.75,-4.45,-5.45,-2.23,-4.74,-9.04,-5.75,-3.13,-4.23,-7.04,-7.65,-6.23,-7.7,-8.16,-7.73,-0.38],[-2.53,-6,-5.91,-4.69,-0.93,-5.91,-6,-3.2,-2.34,-6,-5.67,-3.89,-4,-5.01,-1.74,-6,-6,-6,-5.82,-5.91,-3.12,-5.67,-5.91,-6,-4.57,-3.77,-3.17],[-2.15,-3.13,-3.2,-3.55,-3.83,-3.26,-4.13,-2.78,-2.75,-5.69,-5.27,-3.78,-3.35,-3.81,-2.64,-3.37,-6.24,-3.68,-2.7,-1.86,-4.47,-4.92,-2.8,-7.78,-4.7,-8.49,-3.29]]},Gibberish={data:matrix,acceptedChars:"abcdefghijklmnopqrstuvwxyz ",pos:{},avgTransitionProb:function(d){for(var e=0,f=0,g=this.nGram(2,d),h=g.next();!h.done;){var j=h.value[0],k=h.value[1];e+=this.data.mat[this.pos[j]][this.pos[k]],f+=1,h=g.next()}return Math.exp(e/(f||1))},isGibberish:function(d){return this.avgTransitionProb(d)<=this.data.thresh},nGram:function*(d,e){for(var f=this.normalize(e),g=0;g<=f.length-d;g++)yield f.slice(g,g+d).join("")},normalize:function(d){var e=this.acceptedChars;return d.split("").reduce(function(f,g){return g=g.toLowerCase(),0<=e.indexOf(g)&&f.push(g),f},[])}};Gibberish.pos=function(d){var e={};for(i in d)e[d[i]]=i;return e}(Gibberish.acceptedChars);