Paknevis.js is a npm package to detect or censor persian swears and bad words. Suitable for use in chat programs, comment sections, and entries where you want to be free of inappropriate text content.
You can use it in both CommonJS and ESM modules:
import { Paknevis } from "paknevis";
Or
const { Paknevis } = require("paknevis");
Also you can use it in most modern browsers:
<script type="module">
import { Paknevis } from 'public/js/paknevis/esm/paknevis.js';
...
</script>
Basic usage: You can find this file in
examples/example.js
.
const { Paknevis } = require('paknevis');
const text = "این یک فحش است : تخمی";
Paknevis.hasBadWords(text); // returns true.
Paknevis.censor(text); // returns "این یک فحش است"
With extra words:
const { Paknevis } = require('paknevis');
const text = "این یک فحش است : بازاری";
Paknevis.hasBadWords(text, ["بازاری"]); // returns true.
Paknevis.censor(text, ["بازاری"]); // returns "این یک فحش است"
With censor character:
const { Paknevis } = require('paknevis.js');
const text = "این یک فحش است : تخمی";
Paknevis.hasBadWords(text); // returns true.
Paknevis.censor(text, "*"); // returns "* این یک فحش است"
You can test code's functionality by jest
package in Node.js.
npm run test
Feel free to open an issue and contribute to the code, and if you like the code, give it a star!