question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Combined bad words not being detected as profane.

See original GitHub issue
filter.isProfane('fuckshit') // returns false 
filter.isProfane('fuck shit') // returns true

In lang.json, it has *fuck* and I was hoping that would mean anything around the word fuck would be caught like ‘gofuckyourself’, etc.

Of course, we only want to do this to certain words like fuck or shit that do not make up any other word in the dictionary: http://www.morewords.com/contains/fuck/ And, we avoid the Clbuttic mistake as well.

Any way to get it to work this way?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:8
  • Comments:12

github_iconTop GitHub Comments

1reaction
lockielukecommented, Dec 21, 2021

Currently using patch-package to solve the problem

diff --git a/node_modules/bad-words/lib/badwords.js b/node_modules/bad-words/lib/badwords.js
index 3990c41..15de96e 100644
--- a/node_modules/bad-words/lib/badwords.js
+++ b/node_modules/bad-words/lib/badwords.js
@@ -31,11 +31,11 @@ class Filter {
    */
   isProfane(string) {
     return this.list
-      .filter((word) => {
-        const wordExp = new RegExp(`\\b${word.replace(/(\W)/g, '\\$1')}\\b`, 'gi');
-        return !this.exclude.includes(word.toLowerCase()) && wordExp.test(string);
-      })
-      .length > 0 || false;
+        .filter((word) => {
+          const wordExp = new RegExp(`\\b(\\w*${word.replace(/(\W)/g, '\\$1')}\\w*)\\b`, 'gi');
+          return !this.exclude.includes(word.toLowerCase()) && wordExp.test(string);
+        })
+        .length > 0 || false;
   }
 
   /**

0reactions
Jameskmongercommented, Jan 14, 2021

@bernardbaker important to consider the Scunthorpe problem when considering includes or indexOf

Read more comments on GitHub >

github_iconTop Results From Across the Web

Method of Profanity Detection Using Word Embedding and ...
Therefore, in this study, we attempt to accurately identify profanity in the following two cases: (1) when Internet users use profanity by ...
Read more >
How to Catch Profanity with R - Towards Data Science
These are just a few lexicons of bad words. There are many many more ready to be used. For better results, why not...
Read more >
stephenhaunts/ProfanityDetector: This is a simple ... - GitHub
This is where you get a false-positive result from a profanity detector because a profanity pattern is found inside a non-profane word.
Read more >
Bad Word Filter PRO - Solution against profanity and obscenity
The "Bad Word Filter" works with any language and writing system. It is easily customizable, runs on all Unity platforms and the source...
Read more >
The Science of Swear Words (Warning: NSFW AF) - WIRED
So not only does English profanity tend to be pronounced with closed monosyllables, but English speakers moreover think that closed ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found