Update jspp.js

This commit is contained in:
Sam Sneed 2024-05-31 22:47:24 +00:00 committed by GitHub
parent 24acc782d3
commit 37b034f067
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -18,17 +18,15 @@ class JSPlusPlus {
gen.require("https://cdn.jsdelivr.net/npm/@tensorflow/tfjs") gen.require("https://cdn.jsdelivr.net/npm/@tensorflow/tfjs")
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 toxics = []
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") { toxics = classified.results.match
var toxic = classified.results.match
}
}); });
}); });
}); });
return toxic return toxics;
} }
async asyncSleep(ms) { async asyncSleep(ms) {