Comparing version 2.0.3 to 2.1.0
@@ -1,11 +0,11 @@ | ||
/* efrt trie-compression v2.0.2 github.com/nlp-compromise/efrt - MIT */ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.unpack = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
const BASE = 36; | ||
/* efrt trie-compression v2.0.3 github.com/nlp-compromise/efrt - MIT */ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.unpack = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(_dereq_,module,exports){ | ||
'use strict' | ||
const BASE = 36 | ||
const seq = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; | ||
const seq = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' | ||
const cache = seq.split('').reduce(function(h, c, i) { | ||
h[c] = i; | ||
return h; | ||
}, {}); | ||
h[c] = i | ||
return h | ||
}, {}) | ||
@@ -15,39 +15,534 @@ // 0, 1, 2, ..., A, B, C, ..., 00, 01, ... AA, AB, AC, ..., AAA, AAB, ... | ||
if (seq[n] !== undefined) { | ||
return seq[n]; | ||
return seq[n] | ||
} | ||
let places = 1; | ||
let range = BASE; | ||
let s = ''; | ||
let places = 1 | ||
let range = BASE | ||
let s = '' | ||
for (; n >= range; n -= range, places++, range *= BASE) { | ||
for (; n >= range; n -= range, places++, range *= BASE) {} | ||
while (places--) { | ||
const d = n % BASE | ||
s = String.fromCharCode((d < 10 ? 48 : 55) + d) + s | ||
n = (n - d) / BASE | ||
} | ||
return s | ||
} | ||
const fromAlphaCode = function(s) { | ||
if (cache[s] !== undefined) { | ||
return cache[s] | ||
} | ||
let n = 0 | ||
let places = 1 | ||
let range = BASE | ||
let pow = 1 | ||
for (; places < s.length; n += range, places++, range *= BASE) {} | ||
for (let i = s.length - 1; i >= 0; i--, pow *= BASE) { | ||
let d = s.charCodeAt(i) - 48 | ||
if (d > 10) { | ||
d -= 7 | ||
} | ||
n += d * pow | ||
} | ||
return n | ||
} | ||
module.exports = { | ||
toAlphaCode: toAlphaCode, | ||
fromAlphaCode: fromAlphaCode | ||
} | ||
},{}],2:[function(_dereq_,module,exports){ | ||
const unpack = _dereq_('./unpack') | ||
module.exports = function(str) { | ||
//turn the weird string into a key-value object again | ||
const obj = str.split('|').reduce((h, s) => { | ||
const arr = s.split('¦') | ||
h[arr[0]] = arr[1] | ||
return h | ||
}, {}) | ||
const all = {} | ||
Object.keys(obj).forEach(function(cat) { | ||
const arr = unpack(obj[cat]) | ||
//special case, for botched-boolean | ||
if (cat === 'true') { | ||
cat = true | ||
} | ||
for (let i = 0; i < arr.length; i++) { | ||
const k = arr[i] | ||
if (all.hasOwnProperty(k) === true) { | ||
if (Array.isArray(all[k]) === false) { | ||
all[k] = [all[k], cat] | ||
} else { | ||
all[k].push(cat) | ||
} | ||
} else { | ||
all[k] = cat | ||
} | ||
} | ||
}) | ||
return all | ||
} | ||
},{"./unpack":4}],3:[function(_dereq_,module,exports){ | ||
const encoding = _dereq_('../encoding') | ||
//the symbols are at the top of the array. | ||
module.exports = function(t) { | ||
//... process these lines | ||
const reSymbol = new RegExp('([0-9A-Z]+):([0-9A-Z]+)') | ||
for (let i = 0; i < t.nodes.length; i++) { | ||
const m = reSymbol.exec(t.nodes[i]) | ||
if (!m) { | ||
t.symCount = i | ||
break | ||
} | ||
t.syms[encoding.fromAlphaCode(m[1])] = encoding.fromAlphaCode(m[2]) | ||
} | ||
//remove from main node list | ||
t.nodes = t.nodes.slice(t.symCount, t.nodes.length) | ||
} | ||
},{"../encoding":1}],4:[function(_dereq_,module,exports){ | ||
const parseSymbols = _dereq_('./symbols') | ||
const encoding = _dereq_('../encoding') | ||
// References are either absolute (symbol) or relative (1 - based) | ||
const indexFromRef = function(trie, ref, index) { | ||
const dnode = encoding.fromAlphaCode(ref) | ||
if (dnode < trie.symCount) { | ||
return trie.syms[dnode] | ||
} | ||
return index + dnode + 1 - trie.symCount | ||
} | ||
const toArray = function(trie) { | ||
const all = [] | ||
const crawl = (index, pref) => { | ||
let node = trie.nodes[index] | ||
if (node[0] === '!') { | ||
all.push(pref) | ||
node = node.slice(1) //ok, we tried. remove it. | ||
} | ||
const matches = node.split(/([A-Z0-9,]+)/g) | ||
for (let i = 0; i < matches.length; i += 2) { | ||
const str = matches[i] | ||
const ref = matches[i + 1] | ||
if (!str) { | ||
continue | ||
} | ||
const have = pref + str | ||
//branch's end | ||
if (ref === ',' || ref === undefined) { | ||
all.push(have) | ||
continue | ||
} | ||
const newIndex = indexFromRef(trie, ref, index) | ||
crawl(newIndex, have) | ||
} | ||
} | ||
crawl(0, '') | ||
return all | ||
} | ||
//PackedTrie - Trie traversal of the Trie packed-string representation. | ||
const unpack = function(str) { | ||
const trie = { | ||
nodes: str.split(';'), //that's all ;)! | ||
syms: [], | ||
symCount: 0 | ||
} | ||
//process symbols, if they have them | ||
if (str.match(':')) { | ||
parseSymbols(trie) | ||
} | ||
return toArray(trie) | ||
} | ||
module.exports = unpack | ||
},{"../encoding":1,"./symbols":3}]},{},[2])(2) | ||
}); | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.unpack = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(_dereq_,module,exports){ | ||
'use strict' | ||
const BASE = 36 | ||
const seq = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' | ||
const cache = seq.split('').reduce(function(h, c, i) { | ||
h[c] = i | ||
return h | ||
}, {}) | ||
// 0, 1, 2, ..., A, B, C, ..., 00, 01, ... AA, AB, AC, ..., AAA, AAB, ... | ||
const toAlphaCode = function(n) { | ||
if (seq[n] !== undefined) { | ||
return seq[n] | ||
} | ||
let places = 1 | ||
let range = BASE | ||
let s = '' | ||
for (; n >= range; n -= range, places++, range *= BASE) {} | ||
while (places--) { | ||
const d = n % BASE; | ||
s = String.fromCharCode((d < 10 ? 48 : 55) + d) + s; | ||
n = (n - d) / BASE; | ||
const d = n % BASE | ||
s = String.fromCharCode((d < 10 ? 48 : 55) + d) + s | ||
n = (n - d) / BASE | ||
} | ||
return s; | ||
}; | ||
return s | ||
} | ||
const fromAlphaCode = function(s) { | ||
if (cache[s] !== undefined) { | ||
return cache[s] | ||
} | ||
let n = 0 | ||
let places = 1 | ||
let range = BASE | ||
let pow = 1 | ||
for (; places < s.length; n += range, places++, range *= BASE) {} | ||
for (let i = s.length - 1; i >= 0; i--, pow *= BASE) { | ||
let d = s.charCodeAt(i) - 48 | ||
if (d > 10) { | ||
d -= 7 | ||
} | ||
n += d * pow | ||
} | ||
return n | ||
} | ||
module.exports = { | ||
toAlphaCode: toAlphaCode, | ||
fromAlphaCode: fromAlphaCode | ||
} | ||
},{}],2:[function(_dereq_,module,exports){ | ||
const unpack = _dereq_('./unpack') | ||
module.exports = function(str) { | ||
//turn the weird string into a key-value object again | ||
const obj = str.split('|').reduce((h, s) => { | ||
const arr = s.split('¦') | ||
h[arr[0]] = arr[1] | ||
return h | ||
}, {}) | ||
const all = {} | ||
Object.keys(obj).forEach(function(cat) { | ||
const arr = unpack(obj[cat]) | ||
//special case, for botched-boolean | ||
if (cat === 'true') { | ||
cat = true | ||
} | ||
for (let i = 0; i < arr.length; i++) { | ||
const k = arr[i] | ||
if (all.hasOwnProperty(k) === true) { | ||
if (Array.isArray(all[k]) === false) { | ||
all[k] = [all[k], cat] | ||
} else { | ||
all[k].push(cat) | ||
} | ||
} else { | ||
all[k] = cat | ||
} | ||
} | ||
}) | ||
return all | ||
} | ||
},{"./unpack":4}],3:[function(_dereq_,module,exports){ | ||
const encoding = _dereq_('../encoding') | ||
//the symbols are at the top of the array. | ||
module.exports = function(t) { | ||
//... process these lines | ||
const reSymbol = new RegExp('([0-9A-Z]+):([0-9A-Z]+)') | ||
for (let i = 0; i < t.nodes.length; i++) { | ||
const m = reSymbol.exec(t.nodes[i]) | ||
if (!m) { | ||
t.symCount = i | ||
break | ||
} | ||
t.syms[encoding.fromAlphaCode(m[1])] = encoding.fromAlphaCode(m[2]) | ||
} | ||
//remove from main node list | ||
t.nodes = t.nodes.slice(t.symCount, t.nodes.length) | ||
} | ||
},{"../encoding":1}],4:[function(_dereq_,module,exports){ | ||
const parseSymbols = _dereq_('./symbols') | ||
const encoding = _dereq_('../encoding') | ||
// References are either absolute (symbol) or relative (1 - based) | ||
const indexFromRef = function(trie, ref, index) { | ||
const dnode = encoding.fromAlphaCode(ref) | ||
if (dnode < trie.symCount) { | ||
return trie.syms[dnode] | ||
} | ||
return index + dnode + 1 - trie.symCount | ||
} | ||
const toArray = function(trie) { | ||
const all = [] | ||
const crawl = (index, pref) => { | ||
let node = trie.nodes[index] | ||
if (node[0] === '!') { | ||
all.push(pref) | ||
node = node.slice(1) //ok, we tried. remove it. | ||
} | ||
const matches = node.split(/([A-Z0-9,]+)/g) | ||
for (let i = 0; i < matches.length; i += 2) { | ||
const str = matches[i] | ||
const ref = matches[i + 1] | ||
if (!str) { | ||
continue | ||
} | ||
const have = pref + str | ||
//branch's end | ||
if (ref === ',' || ref === undefined) { | ||
all.push(have) | ||
continue | ||
} | ||
const newIndex = indexFromRef(trie, ref, index) | ||
crawl(newIndex, have) | ||
} | ||
} | ||
crawl(0, '') | ||
return all | ||
} | ||
//PackedTrie - Trie traversal of the Trie packed-string representation. | ||
const unpack = function(str) { | ||
const trie = { | ||
nodes: str.split(';'), //that's all ;)! | ||
syms: [], | ||
symCount: 0 | ||
} | ||
//process symbols, if they have them | ||
if (str.match(':')) { | ||
parseSymbols(trie) | ||
} | ||
return toArray(trie) | ||
} | ||
module.exports = unpack | ||
},{"../encoding":1,"./symbols":3}]},{},[2])(2) | ||
}); | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.unpack = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(_dereq_,module,exports){ | ||
'use strict' | ||
const BASE = 36 | ||
const seq = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' | ||
const cache = seq.split('').reduce(function(h, c, i) { | ||
h[c] = i | ||
return h | ||
}, {}) | ||
// 0, 1, 2, ..., A, B, C, ..., 00, 01, ... AA, AB, AC, ..., AAA, AAB, ... | ||
const toAlphaCode = function(n) { | ||
if (seq[n] !== undefined) { | ||
return seq[n] | ||
} | ||
let places = 1 | ||
let range = BASE | ||
let s = '' | ||
for (; n >= range; n -= range, places++, range *= BASE) {} | ||
while (places--) { | ||
const d = n % BASE | ||
s = String.fromCharCode((d < 10 ? 48 : 55) + d) + s | ||
n = (n - d) / BASE | ||
} | ||
return s | ||
} | ||
const fromAlphaCode = function(s) { | ||
if (cache[s] !== undefined) { | ||
return cache[s]; | ||
return cache[s] | ||
} | ||
let n = 0; | ||
let places = 1; | ||
let range = BASE; | ||
let pow = 1; | ||
let n = 0 | ||
let places = 1 | ||
let range = BASE | ||
let pow = 1 | ||
for (; places < s.length; n += range, places++, range *= BASE) { | ||
for (; places < s.length; n += range, places++, range *= BASE) {} | ||
for (let i = s.length - 1; i >= 0; i--, pow *= BASE) { | ||
let d = s.charCodeAt(i) - 48 | ||
if (d > 10) { | ||
d -= 7 | ||
} | ||
n += d * pow | ||
} | ||
return n | ||
} | ||
module.exports = { | ||
toAlphaCode: toAlphaCode, | ||
fromAlphaCode: fromAlphaCode | ||
} | ||
},{}],2:[function(_dereq_,module,exports){ | ||
const unpack = _dereq_('./unpack') | ||
module.exports = function(str) { | ||
//turn the weird string into a key-value object again | ||
const obj = str.split('|').reduce((h, s) => { | ||
const arr = s.split('¦') | ||
h[arr[0]] = arr[1] | ||
return h | ||
}, {}) | ||
const all = {} | ||
Object.keys(obj).forEach(function(cat) { | ||
const arr = unpack(obj[cat]) | ||
//special case, for botched-boolean | ||
if (cat === 'true') { | ||
cat = true | ||
} | ||
for (let i = 0; i < arr.length; i++) { | ||
const k = arr[i] | ||
if (all.hasOwnProperty(k) === true) { | ||
if (Array.isArray(all[k]) === false) { | ||
all[k] = [all[k], cat] | ||
} else { | ||
all[k].push(cat) | ||
} | ||
} else { | ||
all[k] = cat | ||
} | ||
} | ||
}) | ||
return all | ||
} | ||
},{"./unpack":4}],3:[function(_dereq_,module,exports){ | ||
const encoding = _dereq_('../encoding') | ||
//the symbols are at the top of the array. | ||
module.exports = function(t) { | ||
//... process these lines | ||
const reSymbol = new RegExp('([0-9A-Z]+):([0-9A-Z]+)') | ||
for (let i = 0; i < t.nodes.length; i++) { | ||
const m = reSymbol.exec(t.nodes[i]) | ||
if (!m) { | ||
t.symCount = i | ||
break | ||
} | ||
t.syms[encoding.fromAlphaCode(m[1])] = encoding.fromAlphaCode(m[2]) | ||
} | ||
//remove from main node list | ||
t.nodes = t.nodes.slice(t.symCount, t.nodes.length) | ||
} | ||
},{"../encoding":1}],4:[function(_dereq_,module,exports){ | ||
const parseSymbols = _dereq_('./symbols') | ||
const encoding = _dereq_('../encoding') | ||
// References are either absolute (symbol) or relative (1 - based) | ||
const indexFromRef = function(trie, ref, index) { | ||
const dnode = encoding.fromAlphaCode(ref) | ||
if (dnode < trie.symCount) { | ||
return trie.syms[dnode] | ||
} | ||
return index + dnode + 1 - trie.symCount | ||
} | ||
const toArray = function(trie) { | ||
const all = [] | ||
const crawl = (index, pref) => { | ||
let node = trie.nodes[index] | ||
if (node[0] === '!') { | ||
all.push(pref) | ||
node = node.slice(1) //ok, we tried. remove it. | ||
} | ||
const matches = node.split(/([A-Z0-9,]+)/g) | ||
for (let i = 0; i < matches.length; i += 2) { | ||
const str = matches[i] | ||
const ref = matches[i + 1] | ||
if (!str) { | ||
continue | ||
} | ||
const have = pref + str | ||
//branch's end | ||
if (ref === ',' || ref === undefined) { | ||
all.push(have) | ||
continue | ||
} | ||
const newIndex = indexFromRef(trie, ref, index) | ||
crawl(newIndex, have) | ||
} | ||
} | ||
crawl(0, '') | ||
return all | ||
} | ||
//PackedTrie - Trie traversal of the Trie packed-string representation. | ||
const unpack = function(str) { | ||
const trie = { | ||
nodes: str.split(';'), //that's all ;)! | ||
syms: [], | ||
symCount: 0 | ||
} | ||
//process symbols, if they have them | ||
if (str.match(':')) { | ||
parseSymbols(trie) | ||
} | ||
return toArray(trie) | ||
} | ||
module.exports = unpack | ||
},{"../encoding":1,"./symbols":3}]},{},[2])(2) | ||
}); | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.unpack = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(_dereq_,module,exports){ | ||
'use strict' | ||
const BASE = 36 | ||
const seq = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' | ||
const cache = seq.split('').reduce(function(h, c, i) { | ||
h[c] = i | ||
return h | ||
}, {}) | ||
// 0, 1, 2, ..., A, B, C, ..., 00, 01, ... AA, AB, AC, ..., AAA, AAB, ... | ||
const toAlphaCode = function(n) { | ||
if (seq[n] !== undefined) { | ||
return seq[n] | ||
} | ||
let places = 1 | ||
let range = BASE | ||
let s = '' | ||
for (; n >= range; n -= range, places++, range *= BASE) {} | ||
while (places--) { | ||
const d = n % BASE | ||
s = String.fromCharCode((d < 10 ? 48 : 55) + d) + s | ||
n = (n - d) / BASE | ||
} | ||
return s | ||
} | ||
const fromAlphaCode = function(s) { | ||
if (cache[s] !== undefined) { | ||
return cache[s] | ||
} | ||
let n = 0 | ||
let places = 1 | ||
let range = BASE | ||
let pow = 1 | ||
for (; places < s.length; n += range, places++, range *= BASE) {} | ||
for (let i = s.length - 1; i >= 0; i--, pow *= BASE) { | ||
let d = s.charCodeAt(i) - 48; | ||
let d = s.charCodeAt(i) - 48 | ||
if (d > 10) { | ||
d -= 7; | ||
d -= 7 | ||
} | ||
n += d * pow; | ||
n += d * pow | ||
} | ||
return n; | ||
}; | ||
return n | ||
} | ||
@@ -57,41 +552,39 @@ module.exports = { | ||
fromAlphaCode: fromAlphaCode | ||
}; | ||
} | ||
},{}],2:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
const unpack = _dereq_('./unpack'); | ||
const unpack = _dereq_('./unpack') | ||
module.exports = function(str) { | ||
//turn the weird string into a key-value object again | ||
let obj = str.split('|').reduce((h, s) => { | ||
let arr = s.split('¦'); | ||
h[arr[0]] = arr[1]; | ||
return h; | ||
}, {}); | ||
let all = {}; | ||
const obj = str.split('|').reduce((h, s) => { | ||
const arr = s.split('¦') | ||
h[arr[0]] = arr[1] | ||
return h | ||
}, {}) | ||
const all = {} | ||
Object.keys(obj).forEach(function(cat) { | ||
let arr = unpack(obj[cat]); | ||
const arr = unpack(obj[cat]) | ||
//special case, for botched-boolean | ||
if (cat === 'true') { | ||
cat = true; | ||
cat = true | ||
} | ||
for (var i = 0; i < arr.length; i++) { | ||
let k = arr[i]; | ||
for (let i = 0; i < arr.length; i++) { | ||
const k = arr[i] | ||
if (all.hasOwnProperty(k) === true) { | ||
if (Array.isArray(all[k]) === false) { | ||
all[k] = [all[k], cat]; | ||
all[k] = [all[k], cat] | ||
} else { | ||
all[k].push(cat); | ||
all[k].push(cat) | ||
} | ||
} else { | ||
all[k] = cat; | ||
all[k] = cat | ||
} | ||
} | ||
}); | ||
return all; | ||
}; | ||
}) | ||
return all | ||
} | ||
},{"./unpack":4}],3:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
const encoding = _dereq_('../encoding'); | ||
const encoding = _dereq_('../encoding') | ||
@@ -101,76 +594,75 @@ //the symbols are at the top of the array. | ||
//... process these lines | ||
const reSymbol = new RegExp('([0-9A-Z]+):([0-9A-Z]+)'); | ||
for(let i = 0; i < t.nodes.length; i++) { | ||
const m = reSymbol.exec(t.nodes[i]); | ||
const reSymbol = new RegExp('([0-9A-Z]+):([0-9A-Z]+)') | ||
for (let i = 0; i < t.nodes.length; i++) { | ||
const m = reSymbol.exec(t.nodes[i]) | ||
if (!m) { | ||
t.symCount = i; | ||
break; | ||
t.symCount = i | ||
break | ||
} | ||
t.syms[encoding.fromAlphaCode(m[1])] = encoding.fromAlphaCode(m[2]); | ||
t.syms[encoding.fromAlphaCode(m[1])] = encoding.fromAlphaCode(m[2]) | ||
} | ||
//remove from main node list | ||
t.nodes = t.nodes.slice(t.symCount, t.nodes.length); | ||
}; | ||
t.nodes = t.nodes.slice(t.symCount, t.nodes.length) | ||
} | ||
},{"../encoding":1}],4:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
const parseSymbols = _dereq_('./symbols'); | ||
const encoding = _dereq_('../encoding'); | ||
const parseSymbols = _dereq_('./symbols') | ||
const encoding = _dereq_('../encoding') | ||
// References are either absolute (symbol) or relative (1 - based) | ||
const indexFromRef = function(trie, ref, index) { | ||
const dnode = encoding.fromAlphaCode(ref); | ||
const dnode = encoding.fromAlphaCode(ref) | ||
if (dnode < trie.symCount) { | ||
return trie.syms[dnode]; | ||
return trie.syms[dnode] | ||
} | ||
return index + dnode + 1 - trie.symCount; | ||
}; | ||
return index + dnode + 1 - trie.symCount | ||
} | ||
const toArray = function(trie) { | ||
let all = []; | ||
const all = [] | ||
const crawl = (index, pref) => { | ||
let node = trie.nodes[index]; | ||
let node = trie.nodes[index] | ||
if (node[0] === '!') { | ||
all.push(pref); | ||
node = node.slice(1); //ok, we tried. remove it. | ||
all.push(pref) | ||
node = node.slice(1) //ok, we tried. remove it. | ||
} | ||
let matches = node.split(/([A-Z0-9,]+)/g); | ||
const matches = node.split(/([A-Z0-9,]+)/g) | ||
for (let i = 0; i < matches.length; i += 2) { | ||
let str = matches[i]; | ||
let ref = matches[i + 1]; | ||
const str = matches[i] | ||
const ref = matches[i + 1] | ||
if (!str) { | ||
continue; | ||
continue | ||
} | ||
let have = pref + str; | ||
const have = pref + str | ||
//branch's end | ||
if (ref === ',' || ref === undefined) { | ||
all.push(have); | ||
continue; | ||
all.push(have) | ||
continue | ||
} | ||
let newIndex = indexFromRef(trie, ref, index); | ||
crawl(newIndex, have); | ||
const newIndex = indexFromRef(trie, ref, index) | ||
crawl(newIndex, have) | ||
} | ||
}; | ||
crawl(0, ''); | ||
return all; | ||
}; | ||
} | ||
crawl(0, '') | ||
return all | ||
} | ||
//PackedTrie - Trie traversal of the Trie packed-string representation. | ||
const unpack = function(str) { | ||
let trie = { | ||
const trie = { | ||
nodes: str.split(';'), //that's all ;)! | ||
syms: [], | ||
symCount: 0 | ||
}; | ||
} | ||
//process symbols, if they have them | ||
if (str.match(':')) { | ||
parseSymbols(trie); | ||
parseSymbols(trie) | ||
} | ||
return toArray(trie); | ||
}; | ||
return toArray(trie) | ||
} | ||
module.exports = unpack; | ||
module.exports = unpack | ||
},{"../encoding":1,"./symbols":3}]},{},[2])(2) | ||
}); | ||
}); |
@@ -1,2 +0,6 @@ | ||
/* efrt trie-compression v2.0.2 github.com/nlp-compromise/efrt - MIT */ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.efrt=t()}}(function(){var t;return function t(n,e,o){function r(s,u){if(!e[s]){if(!n[s]){var f="function"==typeof require&&require;if(!u&&f)return f(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var a=e[s]={exports:{}};n[s][0].call(a.exports,function(t){var e=n[s][1][t];return r(e?e:t)},a,a.exports,t,n,e,o)}return e[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(t,n,e){"use strict";var o=36,r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",i=r.split("").reduce(function(t,n,e){return t[n]=e,t},{}),s=function(t){if(void 0!==r[t])return r[t];for(var n=1,e=o,i="";t>=e;t-=e,n++,e*=o);for(;n--;){var s=t%o;i=String.fromCharCode((s<10?48:55)+s)+i,t=(t-s)/o}return i},u=function(t){if(void 0!==i[t])return i[t];for(var n=0,e=1,r=o,s=1;e<t.length;n+=r,e++,r*=o);for(var u=t.length-1;u>=0;u--,s*=o){var f=t.charCodeAt(u)-48;f>10&&(f-=7),n+=f*s}return n};n.exports={toAlphaCode:s,fromAlphaCode:u}},{}],2:[function(n,e,o){(function(o){"use strict";var r={pack:n("./pack/index"),unpack:n("./unpack/index")};"undefined"!=typeof self?self.efrt=r:"undefined"!=typeof window?window.efrt=r:"undefined"!=typeof o&&(o.efrt=r),"function"==typeof t&&t.amd&&t(r),"undefined"!=typeof e&&(e.exports=r)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./pack/index":5,"./unpack/index":9}],3:[function(t,n,e){"use strict";var o=function(t,n){for(var e=Math.min(t.length,n.length);e>0;){var o=t.slice(0,e);if(o===n.slice(0,e))return o;e-=1}return""},r=function(t){t.sort();for(var n=1;n<t.length;n++)t[n-1]===t[n]&&t.splice(n,1)};n.exports={commonPrefix:o,unique:r}},{}],4:[function(t,n,e){"use strict";var o=function(){this.counts={}},r={init:function(t){void 0===this.counts[t]&&(this.counts[t]=0)},add:function(t,n){void 0===n&&(n=1),this.init(t),this.counts[t]+=n},countOf:function(t){return this.init(t),this.counts[t]},highest:function(t){for(var n=[],e=Object.keys(this.counts),o=0;o<e.length;o++){var r=e[o];n.push([r,this.counts[r]])}return n.sort(function(t,n){return n[1]-t[1]}),t&&(n=n.slice(0,t)),n}};Object.keys(r).forEach(function(t){o.prototype[t]=r[t]}),n.exports=o},{}],5:[function(t,n,e){"use strict";var o=t("./trie"),r=function(t){return"[object Array]"===Object.prototype.toString.call(t)},i=function(t){return null===t||void 0===t?{}:"string"==typeof t?t.split(/ +/g).reduce(function(t,n){return t[n]=!0,t},{}):r(t)?t.reduce(function(t,n){return t[n]=!0,t},{}):t},s=function(t){t=i(t);var n=Object.keys(t).reduce(function(n,e){var o=t[e];if(r(o)){for(var i=0;i<o.length;i++)n[o[i]]=n[o[i]]||[],n[o[i]].push(e);return n}return n.hasOwnProperty(o)===!1&&Object.defineProperty(n,o,{writable:!0,enumerable:!0,configurable:!0,value:[]}),n[o].push(e),n},{});return Object.keys(n).forEach(function(t){var e=new o(n[t]);n[t]=e.pack()}),Object.keys(n).map(function(t){return t+"¦"+n[t]}).join("|")};n.exports=s},{"./trie":8}],6:[function(t,n,e){"use strict";var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=t("./fns"),i=t("./pack"),s=new RegExp("[0-9A-Z,;!:|¦]");n.exports={insertWords:function(t){if(void 0!==t){"string"==typeof t&&(t=t.split(/[^a-zA-Z]+/));for(var n=0;n<t.length;n++)t[n]=t[n].toLowerCase();r.unique(t);for(var e=0;e<t.length;e++)null===t[e].match(s)&&this.insert(t[e])}},insert:function(t){this._insert(t,this.root);var n=this.lastWord;this.lastWord=t;var e=r.commonPrefix(t,n);if(e!==n){var o=this.uniqueNode(n,t,this.root);o&&this.combineSuffixNode(o)}},_insert:function(t,n){var e=void 0,i=void 0;if(0!==t.length){for(var s=Object.keys(n),u=0;u<s.length;u++){var f=s[u];if(e=r.commonPrefix(t,f),0!==e.length){if(f===e&&"object"===o(n[f]))return void this._insert(t.slice(e.length),n[f]);if(f===t&&"number"==typeof n[f])return;return i={},i[f.slice(e.length)]=n[f],this.addTerminal(i,t=t.slice(e.length)),delete n[f],n[e]=i,void this.wordCount++}}this.addTerminal(n,t),this.wordCount++}},addTerminal:function(t,n){if(n.length<=1)return void(t[n]=1);var e={};t[n[0]]=e,this.addTerminal(e,n.slice(1))},nodeProps:function(t,n){var e=[];for(var r in t)""!==r&&"_"!==r[0]&&(n&&"object"!==o(t[r])||e.push(r));return e.sort(),e},optimize:function(){this.combineSuffixNode(this.root),this.prepDFS(),this.countDegree(this.root),this.prepDFS(),this.collapseChains(this.root)},combineSuffixNode:function(t){if(t._c)return t;var n=[];this.isTerminal(t)&&n.push("!");for(var e=this.nodeProps(t),r=0;r<e.length;r++){var i=e[r];"object"===o(t[i])?(t[i]=this.combineSuffixNode(t[i]),n.push(i),n.push(t[i]._c)):n.push(i)}n=n.join("-");var s=this.suffixes[n];return s?s:(this.suffixes[n]=t,t._c=this.cNext++,t)},prepDFS:function(){this.vCur++},visited:function(t){return t._v===this.vCur||(t._v=this.vCur,!1)},countDegree:function(t){if(void 0===t._d&&(t._d=0),t._d++,!this.visited(t))for(var n=this.nodeProps(t,!0),e=0;e<n.length;e++)this.countDegree(t[n[e]])},collapseChains:function(t){var n=void 0,e=void 0,r=void 0,i=void 0;if(!this.visited(t)){for(e=this.nodeProps(t),i=0;i<e.length;i++)n=e[i],r=t[n],"object"===("undefined"==typeof r?"undefined":o(r))&&(this.collapseChains(r),void 0===r._g||1!==r._d&&1!==r._g.length||(delete t[n],n+=r._g,t[n]=r[r._g]));1!==e.length||this.isTerminal(t)||(t._g=n)}},isTerminal:function(t){return!!t[""]},uniqueNode:function(t,n,e){for(var o=this.nodeProps(e,!0),r=0;r<o.length;r++){var i=o[r];if(i===t.slice(0,i.length))return i!==n.slice(0,i.length)?e[i]:this.uniqueNode(t.slice(i.length),n.slice(i.length),e[i])}},pack:function(){return i(this)}}},{"./fns":3,"./pack":7}],7:[function(t,n,e){"use strict";var o=t("./histogram"),r=t("../encoding"),i={NODE_SEP:";",KEY_VAL:":",STRING_SEP:",",TERMINAL_PREFIX:"!",BASE:36},s=function(t,n){var e="",o="";t.isTerminal(n)&&(e+=i.TERMINAL_PREFIX);for(var s=t.nodeProps(n),u=0;u<s.length;u++){var f=s[u];if("number"!=typeof n[f])if(t.syms[n[f]._n])e+=o+f+t.syms[n[f]._n],o="";else{var c=r.toAlphaCode(n._n-n[f]._n-1+t.symCount);n[f]._g&&c.length>=n[f]._g.length&&1===n[n[f]._g]?(c=n[f]._g,e+=o+f+c,o=i.STRING_SEP):(e+=o+f+c,o="")}else e+=o+f,o=i.STRING_SEP}return e},u=function t(n,e){if(!n.visited(e))for(var o=n.nodeProps(e,!0),s=0;s<o.length;s++){var u=o[s],f=e._n-e[u]._n-1;f<i.BASE&&n.histRel.add(f),n.histAbs.add(e[u]._n,r.toAlphaCode(f).length-1),t(n,e[u])}},f=function(t){t.histAbs=t.histAbs.highest(i.BASE);var n=[];n[-1]=0;for(var e=0,o=0,s=3+r.toAlphaCode(t.nodeCount).length,u=0;u<i.BASE&&void 0!==t.histAbs[u];u++)n[u]=t.histAbs[u][1]-s-t.histRel.countOf(i.BASE-u-1)+n[u-1],n[u]>=e&&(e=n[u],o=u+1);return o},c=function t(n,e){if(void 0===e._n){for(var o=n.nodeProps(e,!0),r=0;r<o.length;r++)t(n,e[o[r]]);e._n=n.pos++,n.nodes.unshift(e)}},a=function(t){t.nodes=[],t.nodeCount=0,t.syms={},t.symCount=0,t.pos=0,t.optimize(),t.histAbs=new o,t.histRel=new o,c(t,t.root),t.nodeCount=t.nodes.length,t.prepDFS(),u(t,t.root),t.symCount=f(t);for(var n=0;n<t.symCount;n++)t.syms[t.histAbs[n][0]]=r.toAlphaCode(n);for(var e=0;e<t.nodeCount;e++)t.nodes[e]=s(t,t.nodes[e]);for(var a=t.symCount-1;a>=0;a--)t.nodes.unshift(r.toAlphaCode(a)+i.KEY_VAL+r.toAlphaCode(t.nodeCount-t.histAbs[a][0]-1));return t.nodes.join(i.NODE_SEP)};n.exports=a},{"../encoding":1,"./histogram":4}],8:[function(t,n,e){"use strict";var o=t("./methods"),r=function(t){this.root={},this.lastWord="",this.suffixes={},this.suffixCounts={},this.cNext=1,this.wordCount=0,this.insertWords(t),this.vCur=0};Object.keys(o).forEach(function(t){r.prototype[t]=o[t]}),n.exports=r},{"./methods":6}],9:[function(t,n,e){"use strict";var o=t("./unpack");n.exports=function(t){var n=t.split("|").reduce(function(t,n){var e=n.split("¦");return t[e[0]]=e[1],t},{}),e={};return Object.keys(n).forEach(function(t){var r=o(n[t]);"true"===t&&(t=!0);for(var i=0;i<r.length;i++){var s=r[i];e.hasOwnProperty(s)===!0?Array.isArray(e[s])===!1?e[s]=[e[s],t]:e[s].push(t):e[s]=t}}),e}},{"./unpack":11}],10:[function(t,n,e){"use strict";var o=t("../encoding");n.exports=function(t){for(var n=new RegExp("([0-9A-Z]+):([0-9A-Z]+)"),e=0;e<t.nodes.length;e++){var r=n.exec(t.nodes[e]);if(!r){t.symCount=e;break}t.syms[o.fromAlphaCode(r[1])]=o.fromAlphaCode(r[2])}t.nodes=t.nodes.slice(t.symCount,t.nodes.length)}},{"../encoding":1}],11:[function(t,n,e){"use strict";var o=t("./symbols"),r=t("../encoding"),i=function(t,n,e){var o=r.fromAlphaCode(n);return o<t.symCount?t.syms[o]:e+o+1-t.symCount},s=function(t){var n=[],e=function e(o,r){var s=t.nodes[o];"!"===s[0]&&(n.push(r),s=s.slice(1));for(var u=s.split(/([A-Z0-9,]+)/g),f=0;f<u.length;f+=2){var c=u[f],a=u[f+1];if(c){var d=r+c;if(","!==a&&void 0!==a){var h=i(t,a,o);e(h,d)}else n.push(d)}}};return e(0,""),n},u=function(t){var n={nodes:t.split(";"),syms:[],symCount:0};return t.match(":")&&o(n),s(n)};n.exports=u},{"../encoding":1,"./symbols":10}]},{},[2])(2)}); | ||
/* efrt v2.1.0 | ||
github.com/nlp-compromise/efrt | ||
MIT | ||
*/ | ||
!function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).efrt=t()}(function(){return function t(n,e,o){function r(s,u){if(!e[s]){if(!n[s]){var f="function"==typeof require&&require;if(!u&&f)return f(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=e[s]={exports:{}};n[s][0].call(h.exports,function(t){return r(n[s][1][t]||t)},h,h.exports,t,n,e,o)}return e[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(t,n,e){"use strict";var o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",r=o.split("").reduce(function(t,n,e){return t[n]=e,t},{});n.exports={toAlphaCode:function(t){if(void 0!==o[t])return o[t];for(var n=1,e=36,r="";t>=e;t-=e,n++,e*=36);for(;n--;){var i=t%36;r=String.fromCharCode((i<10?48:55)+i)+r,t=(t-i)/36}return r},fromAlphaCode:function(t){if(void 0!==r[t])return r[t];for(var n=0,e=1,o=36,i=1;e<t.length;n+=o,e++,o*=36);for(var s=t.length-1;s>=0;s--,i*=36){var u=t.charCodeAt(s)-48;u>10&&(u-=7),n+=u*i}return n}}},{}],2:[function(t,n,e){(function(e){"use strict";var o={pack:t("./pack/index"),unpack:t("./unpack/index")};"undefined"!=typeof self?self.efrt=o:"undefined"!=typeof window?window.efrt=o:void 0!==e&&(e.efrt=o),void 0!==n&&(n.exports=o)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./pack/index":5,"./unpack/index":9}],3:[function(t,n,e){"use strict";n.exports={commonPrefix:function(t,n){for(var e=Math.min(t.length,n.length);e>0;){var o=t.slice(0,e);if(o===n.slice(0,e))return o;e-=1}return""},unique:function(t){t.sort();for(var n=1;n<t.length;n++)t[n-1]===t[n]&&t.splice(n,1)}}},{}],4:[function(t,n,e){"use strict";var o=function(){this.counts={}},r={init:function(t){void 0===this.counts[t]&&(this.counts[t]=0)},add:function(t,n){void 0===n&&(n=1),this.init(t),this.counts[t]+=n},countOf:function(t){return this.init(t),this.counts[t]},highest:function(t){for(var n=[],e=Object.keys(this.counts),o=0;o<e.length;o++){var r=e[o];n.push([r,this.counts[r]])}return n.sort(function(t,n){return n[1]-t[1]}),t&&(n=n.slice(0,t)),n}};Object.keys(r).forEach(function(t){o.prototype[t]=r[t]}),n.exports=o},{}],5:[function(t,n,e){"use strict";var o=t("./trie"),r=function(t){return"[object Array]"===Object.prototype.toString.call(t)};n.exports=function(t){var n;t=null==(n=t)?{}:"string"==typeof n?n.split(/ +/g).reduce(function(t,n){return t[n]=!0,t},{}):r(n)?n.reduce(function(t,n){return t[n]=!0,t},{}):n;var e=Object.keys(t).reduce(function(n,e){var o=t[e];if(r(o)){for(var i=0;i<o.length;i++)n[o[i]]=n[o[i]]||[],n[o[i]].push(e);return n}return!1===n.hasOwnProperty(o)&&Object.defineProperty(n,o,{writable:!0,enumerable:!0,configurable:!0,value:[]}),n[o].push(e),n},{});return Object.keys(e).forEach(function(t){var n=new o(e[t]);e[t]=n.pack()}),Object.keys(e).map(function(t){return t+"¦"+e[t]}).join("|")}},{"./trie":8}],6:[function(t,n,e){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var r=t("./fns"),i=t("./pack"),s=new RegExp("[0-9A-Z,;!:|¦]");n.exports={insertWords:function(t){if(void 0!==t){"string"==typeof t&&(t=t.split(/[^a-zA-Z]+/));for(var n=0;n<t.length;n++)t[n]=t[n].toLowerCase();r.unique(t);for(var e=0;e<t.length;e++)null===t[e].match(s)&&this.insert(t[e])}},insert:function(t){this._insert(t,this.root);var n=this.lastWord;if(this.lastWord=t,r.commonPrefix(t,n)!==n){var e=this.uniqueNode(n,t,this.root);e&&this.combineSuffixNode(e)}},_insert:function(t,n){var e,i;if(0!==t.length){for(var s=Object.keys(n),u=0;u<s.length;u++){var f=s[u];if(0!==(e=r.commonPrefix(t,f)).length){if(f===e&&"object"===o(n[f]))return void this._insert(t.slice(e.length),n[f]);if(f===t&&"number"==typeof n[f])return;return(i={})[f.slice(e.length)]=n[f],this.addTerminal(i,t=t.slice(e.length)),delete n[f],n[e]=i,void this.wordCount++}}this.addTerminal(n,t),this.wordCount++}},addTerminal:function(t,n){if(n.length<=1)t[n]=1;else{var e={};t[n[0]]=e,this.addTerminal(e,n.slice(1))}},nodeProps:function(t,n){var e=[];for(var r in t)""!==r&&"_"!==r[0]&&(n&&"object"!==o(t[r])||e.push(r));return e.sort(),e},optimize:function(){this.combineSuffixNode(this.root),this.prepDFS(),this.countDegree(this.root),this.prepDFS(),this.collapseChains(this.root)},combineSuffixNode:function(t){if(t._c)return t;var n=[];this.isTerminal(t)&&n.push("!");for(var e=this.nodeProps(t),r=0;r<e.length;r++){var i=e[r];"object"===o(t[i])?(t[i]=this.combineSuffixNode(t[i]),n.push(i),n.push(t[i]._c)):n.push(i)}return n=n.join("-"),this.suffixes[n]||(this.suffixes[n]=t,t._c=this.cNext++,t)},prepDFS:function(){this.vCur++},visited:function(t){return t._v===this.vCur||(t._v=this.vCur,!1)},countDegree:function(t){if(void 0===t._d&&(t._d=0),t._d++,!this.visited(t))for(var n=this.nodeProps(t,!0),e=0;e<n.length;e++)this.countDegree(t[n[e]])},collapseChains:function(t){var n,e,r,i;if(!this.visited(t)){for(e=this.nodeProps(t),i=0;i<e.length;i++)"object"===o(r=t[n=e[i]])&&(this.collapseChains(r),void 0===r._g||1!==r._d&&1!==r._g.length||(delete t[n],t[n+=r._g]=r[r._g]));1!==e.length||this.isTerminal(t)||(t._g=n)}},isTerminal:function(t){return!!t[""]},uniqueNode:function(t,n,e){for(var o=this.nodeProps(e,!0),r=0;r<o.length;r++){var i=o[r];if(i===t.slice(0,i.length))return i!==n.slice(0,i.length)?e[i]:this.uniqueNode(t.slice(i.length),n.slice(i.length),e[i])}},pack:function(){return i(this)}}},{"./fns":3,"./pack":7}],7:[function(t,n,e){"use strict";var o=t("./histogram"),r=t("../encoding"),i=function(t,n){var e="",o="";t.isTerminal(n)&&(e+="!");for(var i=t.nodeProps(n),s=0;s<i.length;s++){var u=i[s];if("number"!=typeof n[u])if(t.syms[n[u]._n])e+=o+u+t.syms[n[u]._n],o="";else{var f=r.toAlphaCode(n._n-n[u]._n-1+t.symCount);n[u]._g&&f.length>=n[u]._g.length&&1===n[n[u]._g]?(e+=o+u+(f=n[u]._g),o=","):(e+=o+u+f,o="")}else e+=o+u,o=","}return e};n.exports=function(t){t.nodes=[],t.nodeCount=0,t.syms={},t.symCount=0,t.pos=0,t.optimize(),t.histAbs=new o,t.histRel=new o,function t(n,e){if(void 0===e._n){for(var o=n.nodeProps(e,!0),r=0;r<o.length;r++)t(n,e[o[r]]);e._n=n.pos++,n.nodes.unshift(e)}}(t,t.root),t.nodeCount=t.nodes.length,t.prepDFS(),function t(n,e){if(!n.visited(e))for(var o=n.nodeProps(e,!0),i=0;i<o.length;i++){var s=o[i],u=e._n-e[s]._n-1;u<36&&n.histRel.add(u),n.histAbs.add(e[s]._n,r.toAlphaCode(u).length-1),t(n,e[s])}}(t,t.root),t.symCount=function(t){t.histAbs=t.histAbs.highest(36);var n=[];n[-1]=0;for(var e=0,o=0,i=3+r.toAlphaCode(t.nodeCount).length,s=0;s<36&&void 0!==t.histAbs[s];s++)n[s]=t.histAbs[s][1]-i-t.histRel.countOf(36-s-1)+n[s-1],n[s]>=e&&(e=n[s],o=s+1);return o}(t);for(var n=0;n<t.symCount;n++)t.syms[t.histAbs[n][0]]=r.toAlphaCode(n);for(var e=0;e<t.nodeCount;e++)t.nodes[e]=i(t,t.nodes[e]);for(var s=t.symCount-1;s>=0;s--)t.nodes.unshift(r.toAlphaCode(s)+":"+r.toAlphaCode(t.nodeCount-t.histAbs[s][0]-1));return t.nodes.join(";")}},{"../encoding":1,"./histogram":4}],8:[function(t,n,e){"use strict";var o=t("./methods"),r=function(t){this.root={},this.lastWord="",this.suffixes={},this.suffixCounts={},this.cNext=1,this.wordCount=0,this.insertWords(t),this.vCur=0};Object.keys(o).forEach(function(t){r.prototype[t]=o[t]}),n.exports=r},{"./methods":6}],9:[function(t,n,e){"use strict";var o=t("./unpack");n.exports=function(t){var n=t.split("|").reduce(function(t,n){var e=n.split("¦");return t[e[0]]=e[1],t},{}),e={};return Object.keys(n).forEach(function(t){var r=o(n[t]);"true"===t&&(t=!0);for(var i=0;i<r.length;i++){var s=r[i];!0===e.hasOwnProperty(s)?!1===Array.isArray(e[s])?e[s]=[e[s],t]:e[s].push(t):e[s]=t}}),e}},{"./unpack":11}],10:[function(t,n,e){"use strict";var o=t("../encoding");n.exports=function(t){for(var n=new RegExp("([0-9A-Z]+):([0-9A-Z]+)"),e=0;e<t.nodes.length;e++){var r=n.exec(t.nodes[e]);if(!r){t.symCount=e;break}t.syms[o.fromAlphaCode(r[1])]=o.fromAlphaCode(r[2])}t.nodes=t.nodes.slice(t.symCount,t.nodes.length)}},{"../encoding":1}],11:[function(t,n,e){"use strict";var o=t("./symbols"),r=t("../encoding"),i=function(t,n,e){var o=r.fromAlphaCode(n);return o<t.symCount?t.syms[o]:e+o+1-t.symCount};n.exports=function(t){var n={nodes:t.split(";"),syms:[],symCount:0};return t.match(":")&&o(n),function(t){var n=[];return function e(o,r){var s=t.nodes[o];"!"===s[0]&&(n.push(r),s=s.slice(1));for(var u=s.split(/([A-Z0-9,]+)/g),f=0;f<u.length;f+=2){var c=u[f],h=u[f+1];if(c){var a=r+c;","!==h&&void 0!==h?e(i(t,h,o),a):n.push(a)}}}(0,""),n}(n)}},{"../encoding":1,"./symbols":10}]},{},[2])(2)}),function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).efrt=t()}(function(){return function t(n,e,o){function r(s,u){if(!e[s]){if(!n[s]){var f="function"==typeof require&&require;if(!u&&f)return f(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=e[s]={exports:{}};n[s][0].call(h.exports,function(t){return r(n[s][1][t]||t)},h,h.exports,t,n,e,o)}return e[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(t,n,e){"use strict";var o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",r=o.split("").reduce(function(t,n,e){return t[n]=e,t},{});n.exports={toAlphaCode:function(t){if(void 0!==o[t])return o[t];for(var n=1,e=36,r="";t>=e;t-=e,n++,e*=36);for(;n--;){var i=t%36;r=String.fromCharCode((i<10?48:55)+i)+r,t=(t-i)/36}return r},fromAlphaCode:function(t){if(void 0!==r[t])return r[t];for(var n=0,e=1,o=36,i=1;e<t.length;n+=o,e++,o*=36);for(var s=t.length-1;s>=0;s--,i*=36){var u=t.charCodeAt(s)-48;u>10&&(u-=7),n+=u*i}return n}}},{}],2:[function(t,n,e){(function(e){"use strict";var o={pack:t("./pack/index"),unpack:t("./unpack/index")};"undefined"!=typeof self?self.efrt=o:"undefined"!=typeof window?window.efrt=o:void 0!==e&&(e.efrt=o),void 0!==n&&(n.exports=o)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./pack/index":5,"./unpack/index":9}],3:[function(t,n,e){"use strict";n.exports={commonPrefix:function(t,n){for(var e=Math.min(t.length,n.length);e>0;){var o=t.slice(0,e);if(o===n.slice(0,e))return o;e-=1}return""},unique:function(t){t.sort();for(var n=1;n<t.length;n++)t[n-1]===t[n]&&t.splice(n,1)}}},{}],4:[function(t,n,e){"use strict";var o=function(){this.counts={}},r={init:function(t){void 0===this.counts[t]&&(this.counts[t]=0)},add:function(t,n){void 0===n&&(n=1),this.init(t),this.counts[t]+=n},countOf:function(t){return this.init(t),this.counts[t]},highest:function(t){for(var n=[],e=Object.keys(this.counts),o=0;o<e.length;o++){var r=e[o];n.push([r,this.counts[r]])}return n.sort(function(t,n){return n[1]-t[1]}),t&&(n=n.slice(0,t)),n}};Object.keys(r).forEach(function(t){o.prototype[t]=r[t]}),n.exports=o},{}],5:[function(t,n,e){"use strict";var o=t("./trie"),r=function(t){return"[object Array]"===Object.prototype.toString.call(t)};n.exports=function(t){var n;t=null==(n=t)?{}:"string"==typeof n?n.split(/ +/g).reduce(function(t,n){return t[n]=!0,t},{}):r(n)?n.reduce(function(t,n){return t[n]=!0,t},{}):n;var e=Object.keys(t).reduce(function(n,e){var o=t[e];if(r(o)){for(var i=0;i<o.length;i++)n[o[i]]=n[o[i]]||[],n[o[i]].push(e);return n}return!1===n.hasOwnProperty(o)&&Object.defineProperty(n,o,{writable:!0,enumerable:!0,configurable:!0,value:[]}),n[o].push(e),n},{});return Object.keys(e).forEach(function(t){var n=new o(e[t]);e[t]=n.pack()}),Object.keys(e).map(function(t){return t+"¦"+e[t]}).join("|")}},{"./trie":8}],6:[function(t,n,e){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var r=t("./fns"),i=t("./pack"),s=new RegExp("[0-9A-Z,;!:|¦]");n.exports={insertWords:function(t){if(void 0!==t){"string"==typeof t&&(t=t.split(/[^a-zA-Z]+/));for(var n=0;n<t.length;n++)t[n]=t[n].toLowerCase();r.unique(t);for(var e=0;e<t.length;e++)null===t[e].match(s)&&this.insert(t[e])}},insert:function(t){this._insert(t,this.root);var n=this.lastWord;if(this.lastWord=t,r.commonPrefix(t,n)!==n){var e=this.uniqueNode(n,t,this.root);e&&this.combineSuffixNode(e)}},_insert:function(t,n){var e,i;if(0!==t.length){for(var s=Object.keys(n),u=0;u<s.length;u++){var f=s[u];if(0!==(e=r.commonPrefix(t,f)).length){if(f===e&&"object"===o(n[f]))return void this._insert(t.slice(e.length),n[f]);if(f===t&&"number"==typeof n[f])return;return(i={})[f.slice(e.length)]=n[f],this.addTerminal(i,t=t.slice(e.length)),delete n[f],n[e]=i,void this.wordCount++}}this.addTerminal(n,t),this.wordCount++}},addTerminal:function(t,n){if(n.length<=1)t[n]=1;else{var e={};t[n[0]]=e,this.addTerminal(e,n.slice(1))}},nodeProps:function(t,n){var e=[];for(var r in t)""!==r&&"_"!==r[0]&&(n&&"object"!==o(t[r])||e.push(r));return e.sort(),e},optimize:function(){this.combineSuffixNode(this.root),this.prepDFS(),this.countDegree(this.root),this.prepDFS(),this.collapseChains(this.root)},combineSuffixNode:function(t){if(t._c)return t;var n=[];this.isTerminal(t)&&n.push("!");for(var e=this.nodeProps(t),r=0;r<e.length;r++){var i=e[r];"object"===o(t[i])?(t[i]=this.combineSuffixNode(t[i]),n.push(i),n.push(t[i]._c)):n.push(i)}return n=n.join("-"),this.suffixes[n]||(this.suffixes[n]=t,t._c=this.cNext++,t)},prepDFS:function(){this.vCur++},visited:function(t){return t._v===this.vCur||(t._v=this.vCur,!1)},countDegree:function(t){if(void 0===t._d&&(t._d=0),t._d++,!this.visited(t))for(var n=this.nodeProps(t,!0),e=0;e<n.length;e++)this.countDegree(t[n[e]])},collapseChains:function(t){var n,e,r,i;if(!this.visited(t)){for(e=this.nodeProps(t),i=0;i<e.length;i++)"object"===o(r=t[n=e[i]])&&(this.collapseChains(r),void 0===r._g||1!==r._d&&1!==r._g.length||(delete t[n],t[n+=r._g]=r[r._g]));1!==e.length||this.isTerminal(t)||(t._g=n)}},isTerminal:function(t){return!!t[""]},uniqueNode:function(t,n,e){for(var o=this.nodeProps(e,!0),r=0;r<o.length;r++){var i=o[r];if(i===t.slice(0,i.length))return i!==n.slice(0,i.length)?e[i]:this.uniqueNode(t.slice(i.length),n.slice(i.length),e[i])}},pack:function(){return i(this)}}},{"./fns":3,"./pack":7}],7:[function(t,n,e){"use strict";var o=t("./histogram"),r=t("../encoding"),i=function(t,n){var e="",o="";t.isTerminal(n)&&(e+="!");for(var i=t.nodeProps(n),s=0;s<i.length;s++){var u=i[s];if("number"!=typeof n[u])if(t.syms[n[u]._n])e+=o+u+t.syms[n[u]._n],o="";else{var f=r.toAlphaCode(n._n-n[u]._n-1+t.symCount);n[u]._g&&f.length>=n[u]._g.length&&1===n[n[u]._g]?(e+=o+u+(f=n[u]._g),o=","):(e+=o+u+f,o="")}else e+=o+u,o=","}return e};n.exports=function(t){t.nodes=[],t.nodeCount=0,t.syms={},t.symCount=0,t.pos=0,t.optimize(),t.histAbs=new o,t.histRel=new o,function t(n,e){if(void 0===e._n){for(var o=n.nodeProps(e,!0),r=0;r<o.length;r++)t(n,e[o[r]]);e._n=n.pos++,n.nodes.unshift(e)}}(t,t.root),t.nodeCount=t.nodes.length,t.prepDFS(),function t(n,e){if(!n.visited(e))for(var o=n.nodeProps(e,!0),i=0;i<o.length;i++){var s=o[i],u=e._n-e[s]._n-1;u<36&&n.histRel.add(u),n.histAbs.add(e[s]._n,r.toAlphaCode(u).length-1),t(n,e[s])}}(t,t.root),t.symCount=function(t){t.histAbs=t.histAbs.highest(36);var n=[];n[-1]=0;for(var e=0,o=0,i=3+r.toAlphaCode(t.nodeCount).length,s=0;s<36&&void 0!==t.histAbs[s];s++)n[s]=t.histAbs[s][1]-i-t.histRel.countOf(36-s-1)+n[s-1],n[s]>=e&&(e=n[s],o=s+1);return o}(t);for(var n=0;n<t.symCount;n++)t.syms[t.histAbs[n][0]]=r.toAlphaCode(n);for(var e=0;e<t.nodeCount;e++)t.nodes[e]=i(t,t.nodes[e]);for(var s=t.symCount-1;s>=0;s--)t.nodes.unshift(r.toAlphaCode(s)+":"+r.toAlphaCode(t.nodeCount-t.histAbs[s][0]-1));return t.nodes.join(";")}},{"../encoding":1,"./histogram":4}],8:[function(t,n,e){"use strict";var o=t("./methods"),r=function(t){this.root={},this.lastWord="",this.suffixes={},this.suffixCounts={},this.cNext=1,this.wordCount=0,this.insertWords(t),this.vCur=0};Object.keys(o).forEach(function(t){r.prototype[t]=o[t]}),n.exports=r},{"./methods":6}],9:[function(t,n,e){"use strict";var o=t("./unpack");n.exports=function(t){var n=t.split("|").reduce(function(t,n){var e=n.split("¦");return t[e[0]]=e[1],t},{}),e={};return Object.keys(n).forEach(function(t){var r=o(n[t]);"true"===t&&(t=!0);for(var i=0;i<r.length;i++){var s=r[i];!0===e.hasOwnProperty(s)?!1===Array.isArray(e[s])?e[s]=[e[s],t]:e[s].push(t):e[s]=t}}),e}},{"./unpack":11}],10:[function(t,n,e){"use strict";var o=t("../encoding");n.exports=function(t){for(var n=new RegExp("([0-9A-Z]+):([0-9A-Z]+)"),e=0;e<t.nodes.length;e++){var r=n.exec(t.nodes[e]);if(!r){t.symCount=e;break}t.syms[o.fromAlphaCode(r[1])]=o.fromAlphaCode(r[2])}t.nodes=t.nodes.slice(t.symCount,t.nodes.length)}},{"../encoding":1}],11:[function(t,n,e){"use strict";var o=t("./symbols"),r=t("../encoding"),i=function(t,n,e){var o=r.fromAlphaCode(n);return o<t.symCount?t.syms[o]:e+o+1-t.symCount};n.exports=function(t){var n={nodes:t.split(";"),syms:[],symCount:0};return t.match(":")&&o(n),function(t){var n=[];return function e(o,r){var s=t.nodes[o];"!"===s[0]&&(n.push(r),s=s.slice(1));for(var u=s.split(/([A-Z0-9,]+)/g),f=0;f<u.length;f+=2){var c=u[f],h=u[f+1];if(c){var a=r+c;","!==h&&void 0!==h?e(i(t,h,o),a):n.push(a)}}}(0,""),n}(n)}},{"../encoding":1,"./symbols":10}]},{},[2])(2)}),function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).efrt=t()}(function(){return function t(n,e,o){function r(s,u){if(!e[s]){if(!n[s]){var f="function"==typeof require&&require;if(!u&&f)return f(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=e[s]={exports:{}};n[s][0].call(h.exports,function(t){return r(n[s][1][t]||t)},h,h.exports,t,n,e,o)}return e[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(t,n,e){"use strict";var o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",r=o.split("").reduce(function(t,n,e){return t[n]=e,t},{});n.exports={toAlphaCode:function(t){if(void 0!==o[t])return o[t];for(var n=1,e=36,r="";t>=e;t-=e,n++,e*=36);for(;n--;){var i=t%36;r=String.fromCharCode((i<10?48:55)+i)+r,t=(t-i)/36}return r},fromAlphaCode:function(t){if(void 0!==r[t])return r[t];for(var n=0,e=1,o=36,i=1;e<t.length;n+=o,e++,o*=36);for(var s=t.length-1;s>=0;s--,i*=36){var u=t.charCodeAt(s)-48;u>10&&(u-=7),n+=u*i}return n}}},{}],2:[function(t,n,e){(function(e){"use strict";var o={pack:t("./pack/index"),unpack:t("./unpack/index")};"undefined"!=typeof self?self.efrt=o:"undefined"!=typeof window?window.efrt=o:void 0!==e&&(e.efrt=o),void 0!==n&&(n.exports=o)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./pack/index":5,"./unpack/index":9}],3:[function(t,n,e){"use strict";n.exports={commonPrefix:function(t,n){for(var e=Math.min(t.length,n.length);e>0;){var o=t.slice(0,e);if(o===n.slice(0,e))return o;e-=1}return""},unique:function(t){t.sort();for(var n=1;n<t.length;n++)t[n-1]===t[n]&&t.splice(n,1)}}},{}],4:[function(t,n,e){"use strict";var o=function(){this.counts={}},r={init:function(t){void 0===this.counts[t]&&(this.counts[t]=0)},add:function(t,n){void 0===n&&(n=1),this.init(t),this.counts[t]+=n},countOf:function(t){return this.init(t),this.counts[t]},highest:function(t){for(var n=[],e=Object.keys(this.counts),o=0;o<e.length;o++){var r=e[o];n.push([r,this.counts[r]])}return n.sort(function(t,n){return n[1]-t[1]}),t&&(n=n.slice(0,t)),n}};Object.keys(r).forEach(function(t){o.prototype[t]=r[t]}),n.exports=o},{}],5:[function(t,n,e){"use strict";var o=t("./trie"),r=function(t){return"[object Array]"===Object.prototype.toString.call(t)};n.exports=function(t){var n;t=null==(n=t)?{}:"string"==typeof n?n.split(/ +/g).reduce(function(t,n){return t[n]=!0,t},{}):r(n)?n.reduce(function(t,n){return t[n]=!0,t},{}):n;var e=Object.keys(t).reduce(function(n,e){var o=t[e];if(r(o)){for(var i=0;i<o.length;i++)n[o[i]]=n[o[i]]||[],n[o[i]].push(e);return n}return!1===n.hasOwnProperty(o)&&Object.defineProperty(n,o,{writable:!0,enumerable:!0,configurable:!0,value:[]}),n[o].push(e),n},{});return Object.keys(e).forEach(function(t){var n=new o(e[t]);e[t]=n.pack()}),Object.keys(e).map(function(t){return t+"¦"+e[t]}).join("|")}},{"./trie":8}],6:[function(t,n,e){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var r=t("./fns"),i=t("./pack"),s=new RegExp("[0-9A-Z,;!:|¦]");n.exports={insertWords:function(t){if(void 0!==t){"string"==typeof t&&(t=t.split(/[^a-zA-Z]+/));for(var n=0;n<t.length;n++)t[n]=t[n].toLowerCase();r.unique(t);for(var e=0;e<t.length;e++)null===t[e].match(s)&&this.insert(t[e])}},insert:function(t){this._insert(t,this.root);var n=this.lastWord;if(this.lastWord=t,r.commonPrefix(t,n)!==n){var e=this.uniqueNode(n,t,this.root);e&&this.combineSuffixNode(e)}},_insert:function(t,n){var e,i;if(0!==t.length){for(var s=Object.keys(n),u=0;u<s.length;u++){var f=s[u];if(0!==(e=r.commonPrefix(t,f)).length){if(f===e&&"object"===o(n[f]))return void this._insert(t.slice(e.length),n[f]);if(f===t&&"number"==typeof n[f])return;return(i={})[f.slice(e.length)]=n[f],this.addTerminal(i,t=t.slice(e.length)),delete n[f],n[e]=i,void this.wordCount++}}this.addTerminal(n,t),this.wordCount++}},addTerminal:function(t,n){if(n.length<=1)t[n]=1;else{var e={};t[n[0]]=e,this.addTerminal(e,n.slice(1))}},nodeProps:function(t,n){var e=[];for(var r in t)""!==r&&"_"!==r[0]&&(n&&"object"!==o(t[r])||e.push(r));return e.sort(),e},optimize:function(){this.combineSuffixNode(this.root),this.prepDFS(),this.countDegree(this.root),this.prepDFS(),this.collapseChains(this.root)},combineSuffixNode:function(t){if(t._c)return t;var n=[];this.isTerminal(t)&&n.push("!");for(var e=this.nodeProps(t),r=0;r<e.length;r++){var i=e[r];"object"===o(t[i])?(t[i]=this.combineSuffixNode(t[i]),n.push(i),n.push(t[i]._c)):n.push(i)}return n=n.join("-"),this.suffixes[n]||(this.suffixes[n]=t,t._c=this.cNext++,t)},prepDFS:function(){this.vCur++},visited:function(t){return t._v===this.vCur||(t._v=this.vCur,!1)},countDegree:function(t){if(void 0===t._d&&(t._d=0),t._d++,!this.visited(t))for(var n=this.nodeProps(t,!0),e=0;e<n.length;e++)this.countDegree(t[n[e]])},collapseChains:function(t){var n,e,r,i;if(!this.visited(t)){for(e=this.nodeProps(t),i=0;i<e.length;i++)"object"===o(r=t[n=e[i]])&&(this.collapseChains(r),void 0===r._g||1!==r._d&&1!==r._g.length||(delete t[n],t[n+=r._g]=r[r._g]));1!==e.length||this.isTerminal(t)||(t._g=n)}},isTerminal:function(t){return!!t[""]},uniqueNode:function(t,n,e){for(var o=this.nodeProps(e,!0),r=0;r<o.length;r++){var i=o[r];if(i===t.slice(0,i.length))return i!==n.slice(0,i.length)?e[i]:this.uniqueNode(t.slice(i.length),n.slice(i.length),e[i])}},pack:function(){return i(this)}}},{"./fns":3,"./pack":7}],7:[function(t,n,e){"use strict";var o=t("./histogram"),r=t("../encoding"),i=function(t,n){var e="",o="";t.isTerminal(n)&&(e+="!");for(var i=t.nodeProps(n),s=0;s<i.length;s++){var u=i[s];if("number"!=typeof n[u])if(t.syms[n[u]._n])e+=o+u+t.syms[n[u]._n],o="";else{var f=r.toAlphaCode(n._n-n[u]._n-1+t.symCount);n[u]._g&&f.length>=n[u]._g.length&&1===n[n[u]._g]?(e+=o+u+(f=n[u]._g),o=","):(e+=o+u+f,o="")}else e+=o+u,o=","}return e};n.exports=function(t){t.nodes=[],t.nodeCount=0,t.syms={},t.symCount=0,t.pos=0,t.optimize(),t.histAbs=new o,t.histRel=new o,function t(n,e){if(void 0===e._n){for(var o=n.nodeProps(e,!0),r=0;r<o.length;r++)t(n,e[o[r]]);e._n=n.pos++,n.nodes.unshift(e)}}(t,t.root),t.nodeCount=t.nodes.length,t.prepDFS(),function t(n,e){if(!n.visited(e))for(var o=n.nodeProps(e,!0),i=0;i<o.length;i++){var s=o[i],u=e._n-e[s]._n-1;u<36&&n.histRel.add(u),n.histAbs.add(e[s]._n,r.toAlphaCode(u).length-1),t(n,e[s])}}(t,t.root),t.symCount=function(t){t.histAbs=t.histAbs.highest(36);var n=[];n[-1]=0;for(var e=0,o=0,i=3+r.toAlphaCode(t.nodeCount).length,s=0;s<36&&void 0!==t.histAbs[s];s++)n[s]=t.histAbs[s][1]-i-t.histRel.countOf(36-s-1)+n[s-1],n[s]>=e&&(e=n[s],o=s+1);return o}(t);for(var n=0;n<t.symCount;n++)t.syms[t.histAbs[n][0]]=r.toAlphaCode(n);for(var e=0;e<t.nodeCount;e++)t.nodes[e]=i(t,t.nodes[e]);for(var s=t.symCount-1;s>=0;s--)t.nodes.unshift(r.toAlphaCode(s)+":"+r.toAlphaCode(t.nodeCount-t.histAbs[s][0]-1));return t.nodes.join(";")}},{"../encoding":1,"./histogram":4}],8:[function(t,n,e){"use strict";var o=t("./methods"),r=function(t){this.root={},this.lastWord="",this.suffixes={},this.suffixCounts={},this.cNext=1,this.wordCount=0,this.insertWords(t),this.vCur=0};Object.keys(o).forEach(function(t){r.prototype[t]=o[t]}),n.exports=r},{"./methods":6}],9:[function(t,n,e){"use strict";var o=t("./unpack");n.exports=function(t){var n=t.split("|").reduce(function(t,n){var e=n.split("¦");return t[e[0]]=e[1],t},{}),e={};return Object.keys(n).forEach(function(t){var r=o(n[t]);"true"===t&&(t=!0);for(var i=0;i<r.length;i++){var s=r[i];!0===e.hasOwnProperty(s)?!1===Array.isArray(e[s])?e[s]=[e[s],t]:e[s].push(t):e[s]=t}}),e}},{"./unpack":11}],10:[function(t,n,e){"use strict";var o=t("../encoding");n.exports=function(t){for(var n=new RegExp("([0-9A-Z]+):([0-9A-Z]+)"),e=0;e<t.nodes.length;e++){var r=n.exec(t.nodes[e]);if(!r){t.symCount=e;break}t.syms[o.fromAlphaCode(r[1])]=o.fromAlphaCode(r[2])}t.nodes=t.nodes.slice(t.symCount,t.nodes.length)}},{"../encoding":1}],11:[function(t,n,e){"use strict";var o=t("./symbols"),r=t("../encoding"),i=function(t,n,e){var o=r.fromAlphaCode(n);return o<t.symCount?t.syms[o]:e+o+1-t.symCount};n.exports=function(t){var n={nodes:t.split(";"),syms:[],symCount:0};return t.match(":")&&o(n),function(t){var n=[];return function e(o,r){var s=t.nodes[o];"!"===s[0]&&(n.push(r),s=s.slice(1));for(var u=s.split(/([A-Z0-9,]+)/g),f=0;f<u.length;f+=2){var c=u[f],h=u[f+1];if(c){var a=r+c;","!==h&&void 0!==h?e(i(t,h,o),a):n.push(a)}}}(0,""),n}(n)}},{"../encoding":1,"./symbols":10}]},{},[2])(2)}),function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).efrt=t()}(function(){return function t(n,e,o){function r(s,u){if(!e[s]){if(!n[s]){var f="function"==typeof require&&require;if(!u&&f)return f(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=e[s]={exports:{}};n[s][0].call(h.exports,function(t){return r(n[s][1][t]||t)},h,h.exports,t,n,e,o)}return e[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(t,n,e){"use strict";var o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",r=o.split("").reduce(function(t,n,e){return t[n]=e,t},{});n.exports={toAlphaCode:function(t){if(void 0!==o[t])return o[t];for(var n=1,e=36,r="";t>=e;t-=e,n++,e*=36);for(;n--;){var i=t%36;r=String.fromCharCode((i<10?48:55)+i)+r,t=(t-i)/36}return r},fromAlphaCode:function(t){if(void 0!==r[t])return r[t];for(var n=0,e=1,o=36,i=1;e<t.length;n+=o,e++,o*=36);for(var s=t.length-1;s>=0;s--,i*=36){var u=t.charCodeAt(s)-48;u>10&&(u-=7),n+=u*i}return n}}},{}],2:[function(t,n,e){(function(e){"use strict";var o={pack:t("./pack/index"),unpack:t("./unpack/index")};"undefined"!=typeof self?self.efrt=o:"undefined"!=typeof window?window.efrt=o:void 0!==e&&(e.efrt=o),void 0!==n&&(n.exports=o)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./pack/index":5,"./unpack/index":9}],3:[function(t,n,e){"use strict";n.exports={commonPrefix:function(t,n){for(var e=Math.min(t.length,n.length);e>0;){var o=t.slice(0,e);if(o===n.slice(0,e))return o;e-=1}return""},unique:function(t){t.sort();for(var n=1;n<t.length;n++)t[n-1]===t[n]&&t.splice(n,1)}}},{}],4:[function(t,n,e){"use strict";var o=function(){this.counts={}},r={init:function(t){void 0===this.counts[t]&&(this.counts[t]=0)},add:function(t,n){void 0===n&&(n=1),this.init(t),this.counts[t]+=n},countOf:function(t){return this.init(t),this.counts[t]},highest:function(t){for(var n=[],e=Object.keys(this.counts),o=0;o<e.length;o++){var r=e[o];n.push([r,this.counts[r]])}return n.sort(function(t,n){return n[1]-t[1]}),t&&(n=n.slice(0,t)),n}};Object.keys(r).forEach(function(t){o.prototype[t]=r[t]}),n.exports=o},{}],5:[function(t,n,e){"use strict";var o=t("./trie"),r=function(t){return"[object Array]"===Object.prototype.toString.call(t)};n.exports=function(t){var n;t=null==(n=t)?{}:"string"==typeof n?n.split(/ +/g).reduce(function(t,n){return t[n]=!0,t},{}):r(n)?n.reduce(function(t,n){return t[n]=!0,t},{}):n;var e=Object.keys(t).reduce(function(n,e){var o=t[e];if(r(o)){for(var i=0;i<o.length;i++)n[o[i]]=n[o[i]]||[],n[o[i]].push(e);return n}return!1===n.hasOwnProperty(o)&&Object.defineProperty(n,o,{writable:!0,enumerable:!0,configurable:!0,value:[]}),n[o].push(e),n},{});return Object.keys(e).forEach(function(t){var n=new o(e[t]);e[t]=n.pack()}),Object.keys(e).map(function(t){return t+"¦"+e[t]}).join("|")}},{"./trie":8}],6:[function(t,n,e){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var r=t("./fns"),i=t("./pack"),s=new RegExp("[0-9A-Z,;!:|¦]");n.exports={insertWords:function(t){if(void 0!==t){"string"==typeof t&&(t=t.split(/[^a-zA-Z]+/));for(var n=0;n<t.length;n++)t[n]=t[n].toLowerCase();r.unique(t);for(var e=0;e<t.length;e++)null===t[e].match(s)&&this.insert(t[e])}},insert:function(t){this._insert(t,this.root);var n=this.lastWord;if(this.lastWord=t,r.commonPrefix(t,n)!==n){var e=this.uniqueNode(n,t,this.root);e&&this.combineSuffixNode(e)}},_insert:function(t,n){var e,i;if(0!==t.length){for(var s=Object.keys(n),u=0;u<s.length;u++){var f=s[u];if(0!==(e=r.commonPrefix(t,f)).length){if(f===e&&"object"===o(n[f]))return void this._insert(t.slice(e.length),n[f]);if(f===t&&"number"==typeof n[f])return;return(i={})[f.slice(e.length)]=n[f],this.addTerminal(i,t=t.slice(e.length)),delete n[f],n[e]=i,void this.wordCount++}}this.addTerminal(n,t),this.wordCount++}},addTerminal:function(t,n){if(n.length<=1)t[n]=1;else{var e={};t[n[0]]=e,this.addTerminal(e,n.slice(1))}},nodeProps:function(t,n){var e=[];for(var r in t)""!==r&&"_"!==r[0]&&(n&&"object"!==o(t[r])||e.push(r));return e.sort(),e},optimize:function(){this.combineSuffixNode(this.root),this.prepDFS(),this.countDegree(this.root),this.prepDFS(),this.collapseChains(this.root)},combineSuffixNode:function(t){if(t._c)return t;var n=[];this.isTerminal(t)&&n.push("!");for(var e=this.nodeProps(t),r=0;r<e.length;r++){var i=e[r];"object"===o(t[i])?(t[i]=this.combineSuffixNode(t[i]),n.push(i),n.push(t[i]._c)):n.push(i)}return n=n.join("-"),this.suffixes[n]||(this.suffixes[n]=t,t._c=this.cNext++,t)},prepDFS:function(){this.vCur++},visited:function(t){return t._v===this.vCur||(t._v=this.vCur,!1)},countDegree:function(t){if(void 0===t._d&&(t._d=0),t._d++,!this.visited(t))for(var n=this.nodeProps(t,!0),e=0;e<n.length;e++)this.countDegree(t[n[e]])},collapseChains:function(t){var n,e,r,i;if(!this.visited(t)){for(e=this.nodeProps(t),i=0;i<e.length;i++)"object"===o(r=t[n=e[i]])&&(this.collapseChains(r),void 0===r._g||1!==r._d&&1!==r._g.length||(delete t[n],t[n+=r._g]=r[r._g]));1!==e.length||this.isTerminal(t)||(t._g=n)}},isTerminal:function(t){return!!t[""]},uniqueNode:function(t,n,e){for(var o=this.nodeProps(e,!0),r=0;r<o.length;r++){var i=o[r];if(i===t.slice(0,i.length))return i!==n.slice(0,i.length)?e[i]:this.uniqueNode(t.slice(i.length),n.slice(i.length),e[i])}},pack:function(){return i(this)}}},{"./fns":3,"./pack":7}],7:[function(t,n,e){"use strict";var o=t("./histogram"),r=t("../encoding"),i=function(t,n){var e="",o="";t.isTerminal(n)&&(e+="!");for(var i=t.nodeProps(n),s=0;s<i.length;s++){var u=i[s];if("number"!=typeof n[u])if(t.syms[n[u]._n])e+=o+u+t.syms[n[u]._n],o="";else{var f=r.toAlphaCode(n._n-n[u]._n-1+t.symCount);n[u]._g&&f.length>=n[u]._g.length&&1===n[n[u]._g]?(e+=o+u+(f=n[u]._g),o=","):(e+=o+u+f,o="")}else e+=o+u,o=","}return e};n.exports=function(t){t.nodes=[],t.nodeCount=0,t.syms={},t.symCount=0,t.pos=0,t.optimize(),t.histAbs=new o,t.histRel=new o,function t(n,e){if(void 0===e._n){for(var o=n.nodeProps(e,!0),r=0;r<o.length;r++)t(n,e[o[r]]);e._n=n.pos++,n.nodes.unshift(e)}}(t,t.root),t.nodeCount=t.nodes.length,t.prepDFS(),function t(n,e){if(!n.visited(e))for(var o=n.nodeProps(e,!0),i=0;i<o.length;i++){var s=o[i],u=e._n-e[s]._n-1;u<36&&n.histRel.add(u),n.histAbs.add(e[s]._n,r.toAlphaCode(u).length-1),t(n,e[s])}}(t,t.root),t.symCount=function(t){t.histAbs=t.histAbs.highest(36);var n=[];n[-1]=0;for(var e=0,o=0,i=3+r.toAlphaCode(t.nodeCount).length,s=0;s<36&&void 0!==t.histAbs[s];s++)n[s]=t.histAbs[s][1]-i-t.histRel.countOf(36-s-1)+n[s-1],n[s]>=e&&(e=n[s],o=s+1);return o}(t);for(var n=0;n<t.symCount;n++)t.syms[t.histAbs[n][0]]=r.toAlphaCode(n);for(var e=0;e<t.nodeCount;e++)t.nodes[e]=i(t,t.nodes[e]);for(var s=t.symCount-1;s>=0;s--)t.nodes.unshift(r.toAlphaCode(s)+":"+r.toAlphaCode(t.nodeCount-t.histAbs[s][0]-1));return t.nodes.join(";")}},{"../encoding":1,"./histogram":4}],8:[function(t,n,e){"use strict";var o=t("./methods"),r=function(t){this.root={},this.lastWord="",this.suffixes={},this.suffixCounts={},this.cNext=1,this.wordCount=0,this.insertWords(t),this.vCur=0};Object.keys(o).forEach(function(t){r.prototype[t]=o[t]}),n.exports=r},{"./methods":6}],9:[function(t,n,e){"use strict";var o=t("./unpack");n.exports=function(t){var n=t.split("|").reduce(function(t,n){var e=n.split("¦");return t[e[0]]=e[1],t},{}),e={};return Object.keys(n).forEach(function(t){var r=o(n[t]);"true"===t&&(t=!0);for(var i=0;i<r.length;i++){var s=r[i];!0===e.hasOwnProperty(s)?!1===Array.isArray(e[s])?e[s]=[e[s],t]:e[s].push(t):e[s]=t}}),e}},{"./unpack":11}],10:[function(t,n,e){"use strict";var o=t("../encoding");n.exports=function(t){for(var n=new RegExp("([0-9A-Z]+):([0-9A-Z]+)"),e=0;e<t.nodes.length;e++){var r=n.exec(t.nodes[e]);if(!r){t.symCount=e;break}t.syms[o.fromAlphaCode(r[1])]=o.fromAlphaCode(r[2])}t.nodes=t.nodes.slice(t.symCount,t.nodes.length)}},{"../encoding":1}],11:[function(t,n,e){"use strict";var o=t("./symbols"),r=t("../encoding"),i=function(t,n,e){var o=r.fromAlphaCode(n);return o<t.symCount?t.syms[o]:e+o+1-t.symCount};n.exports=function(t){var n={nodes:t.split(";"),syms:[],symCount:0};return t.match(":")&&o(n),function(t){var n=[];return function e(o,r){var s=t.nodes[o];"!"===s[0]&&(n.push(r),s=s.slice(1));for(var u=s.split(/([A-Z0-9,]+)/g),f=0;f<u.length;f+=2){var c=u[f],h=u[f+1];if(c){var a=r+c;","!==h&&void 0!==h?e(i(t,h,o),a):n.push(a)}}}(0,""),n}(n)}},{"../encoding":1,"./symbols":10}]},{},[2])(2)}); |
@@ -5,3 +5,3 @@ { | ||
"description": "neato compression of key-value data", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"main": "./builds/efrt.js", | ||
@@ -21,19 +21,27 @@ "repository": { | ||
], | ||
"prettier": { | ||
"trailingComma": "none", | ||
"tabWidth": 2, | ||
"semi": false, | ||
"singleQuote": true, | ||
"printWidth": 100 | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"amble": "0.0.4", | ||
"babel-preset-es2015": "6.9.0", | ||
"babelify": "7.3.0", | ||
"browserify": "13.0.1", | ||
"codacy-coverage": "^2.0.3", | ||
"@babel/core": "7.4.5", | ||
"@babel/preset-env": "7.4.5", | ||
"amble": "0.0.7", | ||
"babelify": "10.0.0", | ||
"browserify": "16.2.3", | ||
"codacy-coverage": "3.4.0", | ||
"derequire": "^2.0.3", | ||
"eslint": "^3.17.1", | ||
"eslint": "6.0.1", | ||
"gaze": "^1.1.2", | ||
"nyc": "^11.2.1", | ||
"shelljs": "^0.7.2", | ||
"tap-spec": "4.1.1", | ||
"tape": "4.6.0", | ||
"uglify-js": "2.7.0" | ||
"nyc": "14.1.1", | ||
"shelljs": "0.8.3", | ||
"tap-spec": "5.0.0", | ||
"tape": "4.10.2", | ||
"terser": "^4.0.0" | ||
}, | ||
"license": "MIT" | ||
} |
@@ -59,2 +59,4 @@ <div align="center"> | ||
<a href="https://monolithpl.github.io/trie-compiler/">Benchmarks!</a> | ||
<h3 align="center"> | ||
@@ -148,2 +150,4 @@ <a href="https://rawgit.com/nlp-compromise/efrt/master/demo/index.html">Demo!</a> | ||
Thanks to [John Resig](https://johnresig.com/) for his fun [trie-compression post](https://johnresig.com/blog/javascript-trie-performance-analysis/) on his blog, and [Wiktor Jakubczyc](https://github.com/monolithpl) for his performance analysis work | ||
MIT |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
235471
6026
152
14
60
1