BrainJS / BrainJS/brain.js

Brain.js to detect bad words

Open
#931 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
14.9k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Hey there i wanted to train a model to detect badwords, i have tried downloading brain.js to train a model. I have my badwords dataset in json file. I wanted to know if i am going the right track .

```javascript
import brain from "brain.js";
import fs from "fs";

const a = [];
try {
const data = fs.readFileSync("BadWord.json", "utf8");
const parsedData = JSON.parse(data);
parsedData.known_links.forEach((word) => {
a.push({ input: word, output: true });
});

const net = new brain.recurrent.RNN();
net.train(a, {
log: true,
iterations: 5000,
learningRate: 0.0001
});

const netData = net.toJSON();
fs.writeFileSync("model.json", netData);

const b = net.run("goodWord");
console.log("Result of running model " + b);
} catch (err) {
console.error(err);
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.