diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2024-04-16 01:55:02 +0300 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2024-04-16 01:55:02 +0300 |
| commit | 6248d2cf7a2214ac32628bc58248694108b4d8bf (patch) | |
| tree | 138d22974b783ce2285417f21ae0c4b83de2b245 /pieces | |
| parent | 3894db0824bbb0023bce8402f1c4f578504fb8ce (diff) | |
| download | oseine-6248d2cf7a2214ac32628bc58248694108b4d8bf.tar.gz oseine-6248d2cf7a2214ac32628bc58248694108b4d8bf.tar.bz2 oseine-6248d2cf7a2214ac32628bc58248694108b4d8bf.zip | |
optimize weighted_partial match
Diffstat (limited to 'pieces')
| -rw-r--r-- | pieces/prepare.js (renamed from pieces/prepare-streams.js) | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/pieces/prepare-streams.js b/pieces/prepare.js index ee7ba8e..65ccee1 100644 --- a/pieces/prepare-streams.js +++ b/pieces/prepare.js @@ -31,6 +31,8 @@ const kb = require('../utils/kb-util.js'); /** create entity file from url + * used for entities like 'linked-words', 'synonyms', etc. + * * @param {string} entity: use the entity name * @param {string} url: prepared entity json-file in remote server */ @@ -50,6 +52,14 @@ function create(entity, url) { ); } +function get_data_structure() { + // data structure is an array of `{ url:.., expiration:.., path:.. }` objects +} + +function set_data_structure(node) { + +} + function load_products(url) { request(url, @@ -58,6 +68,15 @@ function load_products(url) { // body is a ready json-string; no need to parse and (re-)stringify json = JSON.parse(body); newJson = []; + + // TODO: + // + attach handle synonyms + // + mark brand-names + // + attach category-names and SAP-categories + // + construct combo words + // + remove non-important words + // + normalize popularity + json.forEach( p => { newJson.push({ id: p.id, @@ -65,11 +84,19 @@ function load_products(url) { kb: kb.keyboardize(kb.clean(p.w)) }); }); + try { - fs.writeFileSync(`${__dirname}/../data/products.json`, JSON.stringify(newJson), 'utf-8'); - // file written successfully + + fs.writeFileSync( + `${__dirname}/../data/products.json`, + JSON.stringify(newJson), + 'utf-8' + ); + return true; // file written successfully + } catch (err) { console.error(err); + return false; } } } |
