aboutsummaryrefslogtreecommitdiff
path: root/update/dict.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-01-08 21:47:45 +0100
committerMinteck <contact@minteck.org>2022-01-08 21:47:45 +0100
commitbe6c790e43be36cfa6669110c7064a67ad3c4623 (patch)
tree3e81dd5a8caaf3f9c9db6b21f858167f01983119 /update/dict.js
parentac2dea4a23ca72001e41c1dbf66ff1a0d01e217c (diff)
downloadponyfind-be6c790e43be36cfa6669110c7064a67ad3c4623.tar.gz
ponyfind-be6c790e43be36cfa6669110c7064a67ad3c4623.tar.bz2
ponyfind-be6c790e43be36cfa6669110c7064a67ad3c4623.zip
Update
Diffstat (limited to 'update/dict.js')
-rw-r--r--update/dict.js32
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