Putting together VS Code extension, express, tensorflow.js, and a text toxicity classifier into a simple project.
Just for fun. :P
-
client
: Activate the VS Code extension by initializing the express server and establishing a connection with the language server. -
server
: Language server responsible for validating the text document and reporting back the diagnostics to the client. It also includes a simple express server that classifies text toxicity through POST requests.
- Open this example in VS Code 1.43+
- In the terminal, execute
yarn run init && yarn run build:fast
F5
to start debugging
Open a text file with some content or type stuff.
VS Code will detect whether text contains toxic content such as threatening language, insults, obscenities, identity-based hate, or sexually explicit language.
Note: The model will be loaded on the first time a text document is opened. This operation takes a few seconds.
Execute the following command if you run into issues when loading the model:
$ npm rebuild @tensorflow/tfjs-node --build-from-source
Then, build the packages with yarn
again.