Skip to content

Commit

Permalink
Add support for detecting profanities
Browse files Browse the repository at this point in the history
Previously, alex was only focussed on detecting phrasing which
might unconsciously be uttered without meaning to harm readers.

This update adds support for profanities and vulgar phrasing.

Closes GH-46.
  • Loading branch information
wooorm committed Feb 3, 2016
1 parent 89dd779 commit ac2c643
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions component.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"wooorm/retext": "^1.0.0",
"wooorm/retext-english": "^1.0.0",
"wooorm/retext-equality": "^1.5.0",
"wooorm/retext-profanities": "^1.0.0",
"wooorm/vfile-sort": "^1.0.0",
"wooorm/vfile": "^1.1.0"
},
Expand Down
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@ var retext = require('retext');
var control = require('remark-message-control');
var english = require('retext-english');
var equality = require('retext-equality');
var profanities = require('retext-profanities');
var remark2retext = require('remark-retext');
var sort = require('vfile-sort');

/*
* Processor.
*/

var text = retext().use(english).use(equality);
var text = retext().use(english).use(equality).use(profanities);
var markdown = remark().use(remark2retext, text).use(control, {
'name': 'alex',
'source': 'retext-equality'
'source': ['retext-equality', 'retext-profanities']
});

/**
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"retext": "^1.0.0",
"retext-english": "^1.0.0",
"retext-equality": "^2.0.0",
"retext-profanities": "^1.0.0",
"to-vfile": "^1.0.0",
"update-notifier": "^0.6.0",
"vfile": "^1.1.0",
Expand Down
7 changes: 5 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ test('alex()', function (t) {
t.same(alex([
'The boogeyman wrote all changes to the **master server**. Thus,',
'the slaves were read-only copies of master. But not to worry,',
'he was a cripple.'
'he was a cripple.',
'',
'Eric is pretty set on beating your butt for sheriff.'
].join('\n')).messages.map(String), [
'1:5-1:14: `boogeyman` may be insensitive, use `boogey` instead',
'1:42-1:48: `master` / `slaves` may be insensitive, use `primary` / `replica` instead',
'3:1-3:3: `he` may be insensitive, use `they`, `it` instead',
'3:10-3:17: `cripple` may be insensitive, use `person with a limp` instead'
'3:10-3:17: `cripple` may be insensitive, use `person with a limp` instead',
'5:36-5:40: Don’t use “butt”, it’s profane'
]);
});

Expand Down

0 comments on commit ac2c643

Please sign in to comment.