From 8b18d5d8bddfb74d3fe71c03340481c188f681b3 Mon Sep 17 00:00:00 2001 From: Sneed Group Holder Date: Fri, 6 Dec 2024 20:22:40 -0600 Subject: [PATCH] Merge LibSi(e)ve with JS++ --- jspp.js | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/jspp.js b/jspp.js index 7a52ce1..50d44b4 100644 --- a/jspp.js +++ b/jspp.js @@ -14,16 +14,40 @@ class JSPlusPlus { async isToxic(sentences) { // Load the model. Users optionally pass in a threshold and an array of // labels to include. - const gen = new JSPlusPlus.General - gen.require("https://cdn.jsdelivr.net/npm/@tensorflow/tfjs") - gen.require("https://cdn.jsdelivr.net/npm/@tensorflow-models/toxicity") + const gen = new JSPlusPlus.General + gen.require("https://cdn.jsdelivr.net/npm/@tensorflow/tfjs") + gen.require("https://cdn.jsdelivr.net/npm/@tensorflow-models/toxicity") let threshold = 0.9; let t = await toxicity.load(threshold).then(model => { return model.classify(sentences).then(predictions => { return predictions }); }); - return t + return t + } + + isPrime = num => { + for(let i = 2, s = Math.sqrt(num); i <= s; i++) { + if(num % i === 0) return false; + } + return num > 1; + } + + sieve(siveTo) { + let primes = [] + siveTo = Number(siveTo) + + for (var i = 1; i < siveTo; i++) { + if (isPrime(i)) { + primes.push(i) + } + } + + if (isPrime(siveTo)) { + primes.push(siveTo) + } + + return primes } async asyncSleep(ms) {