diff options
author | Minteck <contact@minteck.org> | 2022-01-08 21:47:45 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-01-08 21:47:45 +0100 |
commit | be6c790e43be36cfa6669110c7064a67ad3c4623 (patch) | |
tree | 3e81dd5a8caaf3f9c9db6b21f858167f01983119 /update/dict.js | |
parent | ac2dea4a23ca72001e41c1dbf66ff1a0d01e217c (diff) | |
download | ponyfind-be6c790e43be36cfa6669110c7064a67ad3c4623.tar.gz ponyfind-be6c790e43be36cfa6669110c7064a67ad3c4623.tar.bz2 ponyfind-be6c790e43be36cfa6669110c7064a67ad3c4623.zip |
Update
Diffstat (limited to 'update/dict.js')
-rw-r--r-- | update/dict.js | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/update/dict.js b/update/dict.js index 24eb400..88ec568 100644 --- a/update/dict.js +++ b/update/dict.js @@ -7,22 +7,26 @@ let search = { associations: [] } +global.knownAssociations = []; + for (let page of JSON.parse(fs.readFileSync("./data/pages.json").toString())) { - search.associations.push({ - title: page.query.toLowerCase().replace(/[^a-z]/gm, " ").replace(/\s\s+/g, " ").trim(), - endpoint: page.name - }); - search.associations.push({ - title: page.name.toLowerCase().replace(/[^a-z]/gm, " ").replace(/\s\s+/g, " ").trim(), - endpoint: page.name - }); + if (!knownAssociations.includes(page.name.toLowerCase().replace(/[^a-z]/gm, " ").replace(/\s\s+/g, " ").trim())) { + knownAssociations.push(page.name.toLowerCase().replace(/[^a-z]/gm, " ").replace(/\s\s+/g, " ").trim()); + search.associations.push({ + title: page.name.toLowerCase().replace(/[^a-z]/gm, " ").replace(/\s\s+/g, " ").trim(), + endpoint: page.name + }); + } if (typeof JSON.parse(fs.readFileSync("./data/data.json").toString())[page.name] !== "undefined") { for (let nick of JSON.parse(fs.readFileSync("./data/data.json").toString())[page.name].names) { - search.associations.push({ - title: nick.toLowerCase().replace(/[^a-z]/gm, " ").replace(/\s\s+/g, " ").trim(), - endpoint: page.name - }); + if (!knownAssociations.includes(nick.toLowerCase().replace(/[^a-z]/gm, " ").replace(/\s\s+/g, " ").trim())) { + knownAssociations.push(nick.toLowerCase().replace(/[^a-z]/gm, " ").replace(/\s\s+/g, " ").trim()); + search.associations.push({ + title: nick.toLowerCase().replace(/[^a-z]/gm, " ").replace(/\s\s+/g, " ").trim(), + endpoint: page.name + }); + } } } } @@ -32,4 +36,6 @@ for (let association of search.associations) { search.entries.push(association.title); } search.entries = [...new Set(search.entries)]; -fs.writeFileSync("./data/search.json", JSON.stringify(search, null, 4));
\ No newline at end of file +fs.writeFileSync("./data/search.json", JSON.stringify(search, null, 4)); + +console.log(JSON.parse(fs.readFileSync("./data/pages.json").toString()).length + " known characters");
\ No newline at end of file |