Update jspp.js

This commit is contained in:
Sam Sneed 2024-05-31 22:13:31 +00:00 committed by GitHub
parent d4f7ba6de8
commit b87daef318
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

10
jspp.js
View file

@ -16,11 +16,11 @@ class JSPlusPlus {
// labels to include. // labels to include.
const gen = new JSPlusPlus.General const gen = new JSPlusPlus.General
gen.require("https://cdn.jsdelivr.net/npm/@tensorflow/tfjs") gen.require("https://cdn.jsdelivr.net/npm/@tensorflow/tfjs")
const t = gen.require("https://cdn.jsdelivr.net/npm/@tensorflow-models/toxicity") gen.require("https://cdn.jsdelivr.net/npm/@tensorflow-models/toxicity")
let threshold = 0.9; let threshold = 0.9;
let toxic = false let toxic = false
t.toxicity.load(threshold).then(model => { toxicity.load(threshold).then(model => {
model.classify(sentences).then(predictions => { model.classify(sentences).then(predictions => {
predictions.forEach(classified => { predictions.forEach(classified => {
if (classified.label == "toxicity") { if (classified.label == "toxicity") {
@ -335,9 +335,9 @@ class JSPlusPlus {
require(jsURI) { require(jsURI) {
try { try {
let req = JSPlusPlus.JSPlusPlus.readInternetText(jsURI); let jspp = new JSPlusPlus
let gen = new JSPlusPlus.General jspp.readInternetText(jsURI);
gen.exec(req); jspp.exec(req);
} catch { } catch {
console.log(`Error! (Using Node.JS/Bun?) console.log(`Error! (Using Node.JS/Bun?)