New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

isprofanity

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isprofanity - npm Package Compare versions

Comparing version 1.0.11 to 1.0.12

34

isProfanity.js

@@ -19,4 +19,15 @@ fs = require('fs');

}
/**
* Stores a word and it's current rating
* @class
* @param {String} word The word as a string
* @param {Number} rating The Levenshtein distance provided by wangerFischer
* @param {String} closeWord The word tested against
*/
function Word(word,rating,closeWord){
this.word = String(word) || '';
this.sureness = 1 - Number(rating)/this.word.length || 0;
this.closestTo = String(closeWord)
}
/**
* Perform the Wagner-Fischer algorithm on the 2 inputs

@@ -56,4 +67,4 @@ * ( https://en.wikipedia.org/wiki/Wagner%E2%80%93Fischer_algorithm )

if(typeof(callback) != 'function') throw new Error('isProfanity Error: Valid callback not given...');
containsASwear = false;
blockedWords =[];
var containsASwear = false;
var blockedWords = new Array();
loadCSV(function(swears){

@@ -63,9 +74,20 @@ loadCSV(function(exceptions){

strings.forEach(function(word) {
WorstSwear = new Word();
mostlikelyexception = new Word();
swears.forEach(function(swear) {
x = wagnerFischer(swear.toLowerCase(),word.toLowerCase());
if(x < Math.floor(word.length/2) && exceptions.indexOf(word.toLowerCase()) === -1){
containsASwear = true;
blockedWords.push(word);
if(new Word(word,x).sureness > WorstSwear.sureness){
WorstSwear = new Word(word,x,swear);
}
}, this);
exceptions.forEach(function(exep) {
x = wagnerFischer(exep.toLowerCase(),word.toLowerCase());
if(new Word(word,x).sureness > mostlikelyexception.sureness){
mostlikelyexception = new Word(word,x,exep);
}
}, this);
if(WorstSwear.sureness > mostlikelyexception.sureness && WorstSwear.sureness > 0.2){
blockedWords.push(WorstSwear);
containsASwear = true;
}
}, this);

@@ -72,0 +94,0 @@ callback(containsASwear,blockedWords);

2

package.json
{
"name": "isprofanity",
"version": "1.0.11",
"version": "1.0.12",
"description": "A profanity checker which, unlike alternatives, uses the Wagner–Fischer algorithm in order to catch variations that you haven't thought of. ",

@@ -5,0 +5,0 @@ "main": "isProfanity.js",

@@ -45,4 +45,4 @@ # isProfanity

// t will equal true if it contains potential profanity and false if not
// blocked will be an array of the blocked words.
},'data/profanity.csv','data/exceptions.csv');
// blocked will be an array of the blocked words, how sure it is about them and what word they are closest to.
});
```

@@ -49,0 +49,0 @@ If you find any false positives, please share them.

var isprofanity = require('./isProfanity.js');
//var ta = ['Thanks for helping to solve the bug.','Thanks for helping me to create such a cool system :D',"That was a great game you played the other day.","Thanks for helping to test the thanks swear checker...","Thanks for helping to test thanks","RobinsonThomas Robinson was thanked by Joseph Crane \"thanks man.\" positive positive","Make Andy proud","Thanks for the holy water","Yay your on thanks!","Thanks for the hep testing thanks."];
var ta =['aww mate, what the bloom are you doing ?'];
var bwords = [];
var ta =['Thanks for engineering that solution.','Go f*** yourself.'];
ta.forEach(function(tstring) {
isprofanity(tstring,function(t,a){
a.forEach(function(e) {
bwords.push(e);
console.log(e);
}, this);
console.log(tstring+':'+t+':'+JSON.stringify(a));
});
}, this);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc