add psuedo-language analysis thing

This commit is contained in:
biglyderv 2025-01-30 21:00:26 -05:00
parent 55a0830579
commit 0552a81c72
2 changed files with 21 additions and 2 deletions

4
.gitignore vendored
View file

@ -1,2 +1,4 @@
users.json
users*.json
users*.json
test.txt
test*.txt

19
site.js
View file

@ -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;