React Text Toxicity
Detect toxicity in text using React.
It's based on this model: https://github.com/tensorflow/tfjs-models/tree/master/toxicity
Getting started
yarn add react-text-toxicity
Import as:
;
Use it as:
const predictions = ;
- text - Text to predict
- options
- threshold Prediction threshold (0.9 as default)
- delay Delay in milliseconds applied to debounce multiple changes (300ms as default)
Example
import React Fragment useState from "react";import useTextToxicity from "react-text-toxicity"; { const style = margin: 10 ; if !predictions return <div =>Loading predictions...</div>; return <div => predictions </div> ;} { const value setValue = ; const predictions = ; return <div => <div> <div>Write something</div> <textarea = = = /> </div> value && <Toxicity = /> </div> ;}