Skip to content

Commit

Permalink
Add profanities to the list
Browse files Browse the repository at this point in the history
  • Loading branch information
Christophe Roger committed Oct 1, 2017
1 parent 6872a2f commit f8b5148
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 24 deletions.
45 changes: 25 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,42 @@ var list = require('french-badwords-list'),
**french-badwords-list** has been succesfully tested with [leo-profanity](https://www.npmjs.com/package/leo-profanity)

```javascript
// Usage example with leo-profanity
var leoProfanity = require('leo-profanity');
var frenchBadwordsList = require('../liste-gros-mots');
// Usage example with leo-profanity
var leoProfanity = require('leo-profanity');
var frenchBadwordsList = require('../liste-gros-mots');

// Only keep french badwords
leoProfanity.clearList();
leoProfanity.add(frenchBadwordsList.array);
// Only keep french badwords
leoProfanity.clearList();
leoProfanity.add(frenchBadwordsList.array);

// output: true
console.log(leoProfanity.check('Bordel de merde'));
// output: true
console.log(leoProfanity.check('Bordel de merde'));

// output: ****** de *****
console.log(leoProfanity.clean('Bordel de merde'));
// output: ****** de *****
console.log(leoProfanity.clean('Bordel de merde'));

// output: ****** de *****
console.log(leoProfanity.clean('B0rdel de m3rd3'));
// output: ****** de *****
console.log(leoProfanity.clean('B0rdel de m3rd3'));
```

### Code Example with **bad-words**

**french-badwords-list** has been succesfully tested with [bad-words](https://www.npmjs.com/package/bad-words)

```javascript
// Usage example with leo-profanity
var BadWords = require('bad-words');
const frenchBadwords = require('french-badwords-list');
// Usage example with leo-profanity
var BadWords = require('bad-words');
const frenchBadwords = require('french-badwords-list');

// Only keep french badwords
var badwords = new BadWords({ placeHolder: 'x', emptyList: true});
badwords.addWords(frenchBadwordsList.array);
// Only keep french badwords
var badwords = new BadWords({ placeHolder: 'x', emptyList: true});
badwords.addWords(frenchBadwordsList.array);

// output: xxxxxx de xxxxx
badwords.clean('B0rdel de m3rd3'));
// output: xxxxxx de xxxxx
badwords.clean('B0rdel de m3rd3'));

// output: true
badwords.isProfane('B0rdel de m3rd3'));
```

## Motivation
Expand Down Expand Up @@ -92,6 +95,8 @@ npm test
- v1.0.3 / Sep 18 2017:
- Updated french bad words list
- Tests now use chai
- v1.0.4 / 0ct 02 2017: Add french bad words to the list


## License

Expand Down
2 changes: 1 addition & 1 deletion lib/array.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/object.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/regexp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "french-badwords-list",
"version": "1.0.3",
"version": "1.0.4",
"author": "Christophe ROGER <darwiinc@live.fr>",
"license": "MIT",
"description": "A highly consumable list of french bad (profanity) words (forked from badwords-list)",
Expand Down
16 changes: 16 additions & 0 deletions test/bad-words-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,20 @@ describe('bad-words filter', function(){

filter.clean('bordel de merde').should.be.equal('xxxxxx de xxxxx');
});

it("should return true for 'conne' input", function(){
var list = require('../lib/index');
var filter = new Filter({ placeHolder: 'x', emptyList: true});
filter.addWords(list.array);

filter.isProfane('conne').should.be.true;
});

it("should return false for 'bonjour' input", function(){
var list = require('../lib/index');
var filter = new Filter({ emptyList: true});
filter.addWords(list.array);

filter.isProfane('bonjour').should.be.false;
});
});
7 changes: 7 additions & 0 deletions test/leo-profanity-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@ describe('leo-profanity filter', function () {
filter.check('bordel de merde').should.be.true;
})

it("should return true for 'conne' word", function () {
var list = require('../lib/index');
filter.clearList();
filter.add(list.array);

filter.check('conne').should.be.true;
})
});

0 comments on commit f8b5148

Please sign in to comment.