Currently, I am working on integrating a comment section into the website I designed for my university project.
My main objective is to determine whether a comment is toxic or not and then either display an alert or publish the comment.
To achieve this, I am utilizing a pretrained model from TensorFlow.js.
I am facing challenges in retrieving the 'predictions' array, which would allow me to verify if the model has classified the comment as toxic.
// Load Model
toxicity.load(threshold).then(model => {
// Input Comment as Model Input
var sentences = comment;
var modelOutput = new Object();
// Prediction
model.classify(sentences).then(predictions => {
modelOutput = predictions;
return modelOutput;
});
// Pass Prediction
console.log(modelOutput);
});
Thank you in anticipation.