From 0552a81c7251cde7af42402273f3b0eb6eb59ae9 Mon Sep 17 00:00:00 2001 From: biglyderv Date: Thu, 30 Jan 2025 21:00:26 -0500 Subject: [PATCH] add psuedo-language analysis thing --- .gitignore | 4 +++- site.js | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 108b922..a7a99a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ users.json -users*.json \ No newline at end of file +users*.json +test.txt +test*.txt \ No newline at end of file diff --git a/site.js b/site.js index b6b69e0..543184d 100644 --- a/site.js +++ b/site.js @@ -1,14 +1,31 @@ -import { writeFile } from "fs/promises"; +import { writeFile, readFile } from "fs/promises"; import { rankCalc } from "./rank.js"; let cache = {}; let site = process.env.site || 'darflen'; +let hh; + +async function textCollector(word, path, file) { + if (!hh) hh = await readFile(file,'utf8'); + + hh = hh.toLowerCase(); + + let words = hh.split(/[\n.]+/g).filter(x => word.length == 0 || ` ${x} `.includes(` ${word} `)) ; + words = words.join(' ').split(/[^a-zA-Z0-9']+/g); + words = [...new Set(words)]; + return words; +} async function siteCollector(user, path, site) { let users = []; let i = 1; let out = []; + + if (site.startsWith('text_')) { + return await textCollector(user, path, site.split('text_')[1]); + } + while (true) { let p;