diff --git a/src/lib/datasource-utils/preprocess.ts b/src/lib/datasource-utils/preprocess.ts index dcb1056..419bb8f 100644 --- a/src/lib/datasource-utils/preprocess.ts +++ b/src/lib/datasource-utils/preprocess.ts @@ -13,17 +13,7 @@ function preprocess(data): AddressEntry[] { let words = []; let expanded = []; let useLookup = false; - let t; - - if (data.lookup && data.words) { - // compact with dictionary and lookup - useLookup = true; - lookup = data.lookup.split('|'); - words = data.words.split('|'); - data = data.data; - } - - t = text => { + let t = text => { function repl(m) { let ch = m.charCodeAt(0); return words[ch < 97 ? ch - 65 : 26 + ch - 97]; @@ -37,6 +27,14 @@ function preprocess(data): AddressEntry[] { return text.replace(/[A-Z]/ig, repl); }; + if (data.lookup && data.words) { + // compact with dictionary and lookup + useLookup = true; + lookup = data.lookup.split('|'); + words = data.words.split('|'); + data = data.data; + } + if (!data[0].length) { // non-compacted database return data;