-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdice.min.js
2 lines (2 loc) · 1.23 KB
/
dice.min.js
1
2
// dice.js v1.0.0 | github.com/chbk/dice.js
!function(){var t={multigramLength:2,matchMinimum:.5,split:function(t){for(var r=[],e=0;e<t.length-this.multigramLength+1;e++)r.push(t.substr(e,this.multigramLength));return r.sort()},overlap:function(t,r){for(var e=[],n=[],h=0;h<t.length;h++)e.push(this.split(t[h]));for(var h=0;h<r.length;h++)n.push(this.split(r[h]));for(var i=[],o=0;o<e.length;o++){i.push([]);for(var l=0;l<n.length;l++)i[o].push(this.coefficient(e[o],n[l]))}for(var f=[],h=0;h<t.length;h++)f.push(null);for(var s=0,u=i.length*i[0].length;u>s;){for(var g=[],o=0;o<i.length;o++){for(var a=i[o][0],p=0,l=1;l<i[o].length;l++)i[o][l]>a&&(a=i[o][l],p=l);g.push(p)}for(var l=0;l<i[0].length;l++){for(var a=i[0][l],v=0,o=1;o<i.length;o++)i[o][l]>a&&(a=i[o][l],v=o);if(g[v]==l){a>=this.matchMinimum&&(f[v]=l);for(var o=0;o<i.length;o++)i[o][l]=-1,s++;for(var m=0;m<i[0].length;m++)i[v][m]=-1,s++}}}return f},coefficient:function(t,r){if(t==r)return 1;var e=[],n=[];e="string"==typeof t?this.split(t):t,n="string"==typeof r?this.split(r):r;var h=0,i=e.length,o=n.length;if(1>i||1>o)return 0;for(var l=0,f=0;i>l&&o>f;)e[l]==n[f]?(h++,l++,f++):e[l]<n[f]?l++:f++;return 2*h/(i+o)}};"object"==typeof module&&module.exports?module.exports=t:this.dice=t}();