Giter VIP home page Giter VIP logo

profanity's People

Contributors

dependabot[bot] avatar jasonpierce avatar lostigeros avatar lostpebble avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

profanity's Issues

Failed to parse /node_modules/@2toad/profanity/src/data/profane-words.ts

I'm using Yarn v1.22 with React v17.

Failed to parse source map from '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/data/profane-words.ts' file: Error: ENOENT: no such file or directory, open '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/data/profane-words.ts'

Happily, this is working inside the application messages, but it returns many error messages in terminal like the one above.

I tried other versions from npm but none of them solved this issue.

This is the complete error:

Compiled with warnings.

Failed to parse source map from '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/data/profane-words.ts' file: Error: ENOENT: no such file or directory, open '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/data/profane-words.ts'

Failed to parse source map from '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/index.ts' file: Error: ENOENT: no such file or directory, open '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/index.ts'

Failed to parse source map from '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/models/censor-type.ts' file: Error: ENOENT: no such file or directory, open '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/models/censor-type.ts'

Failed to parse source map from '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/models/index.ts' file: Error: ENOENT: no such file or directory, open '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/models/index.ts'

Failed to parse source map from '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/models/list.ts' file: Error: ENOENT: no such file or directory, open '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/models/list.ts'

Failed to parse source map from '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/profanity-options.ts' file: Error: ENOENT: no such file or directory, open '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/profanity-options.ts'

Failed to parse source map from '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/profanity.ts' file: Error: ENOENT: no such file or directory, open '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/profanity.ts'

Failed to parse source map from '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/utils/misc.ts' file: Error: ENOENT: no such file or directory, open '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/utils/misc.ts'

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

WARNING in ./node_modules/@2toad/profanity/dist/data/profane-words.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/data/profane-words.ts' file: Error: ENOENT: no such file or directory, open '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/data/profane-words.ts'

WARNING in ./node_modules/@2toad/profanity/dist/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/index.ts' file: Error: ENOENT: no such file or directory, open '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/index.ts'

WARNING in ./node_modules/@2toad/profanity/dist/models/censor-type.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/models/censor-type.ts' file: Error: ENOENT: no such file or directory, open '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/models/censor-type.ts'

WARNING in ./node_modules/@2toad/profanity/dist/models/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/models/index.ts' file: Error: ENOENT: no such file or directory, open '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/models/index.ts'

WARNING in ./node_modules/@2toad/profanity/dist/models/list.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/models/list.ts' file: Error: ENOENT: no such file or directory, open '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/models/list.ts'

WARNING in ./node_modules/@2toad/profanity/dist/profanity-options.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/profanity-options.ts' file: Error: ENOENT: no such file or directory, open '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/profanity-options.ts'

WARNING in ./node_modules/@2toad/profanity/dist/profanity.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/profanity.ts' file: Error: ENOENT: no such file or directory, open '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/profanity.ts'

WARNING in ./node_modules/@2toad/profanity/dist/utils/misc.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/utils/misc.ts' file: Error: ENOENT: no such file or directory, open '/home/joziasmartini/GitHub/bethype/Frontend/node_modules/@2toad/profanity/src/utils/misc.ts'

webpack compiled with 8 warnings
No issues found.

Exclude blank lines from file import

Presently, if the words.txt file has any blank lines (including a blank line ending at the end of the file), the file import succeeds, but the blank lines are added to the words array, which then wreaks havoc on the profanity filters.

Replace tslint with eslint

tslint has been deprecated. Replace it with the latest version of eslint and eslint's Typescript plugin

NPM tries to install Husky when Profanity is added as a dependency

Husky is used for development of the Profanity lib. It is not used by the Profanity lib when Profanity is included as a dependency in a Node project. Unfortunately, there is no "dev only" script we can add to package.json that will run npm install just within a dev environment.

Resolution: We need to remove the postinstall script from package.json

Add whitelist

could we get a black list command?

for example we keep
options.wholeWord = false;
but for example
someone says 'cock' fair enough it censors it, but if someone says cockpit then it sensors it again
we want to keep the wholeWord to false as its a lot easier to mange than inserting every bit of word in to the file, is this possible?
Thanks, Dane

Remove FS reference for Web Browser JavaScript Support

When trying to compile you package with our web module the following error is output:

ERROR in ./node_modules/@2toad/profanity/dist/list.js Module not found: Error: Can't resolve 'fs' in 'C:\LocalProjects\DrawAlive_Web_Product\Server\Server\node_modules\@2toad\profanity\dist' @ ./node_modules/@2toad/profanity/dist/list.js 4:13-26 @ ./node_modules/@2toad/profanity/dist/profanity.js @ ./node_modules/@2toad/profanity/dist/index.js

Would prefer an alternative to the FS call.

Relax package engine Node version requirement

Hi, I recently started using Profanity and think it is great.

I have an issue with the explicitly set Node engine in the package.json. Currently, it is set to "node": "14.15.0" and it is causing issues in my environment which is running Node 15.

error @2toad/[email protected]: The engine "node" is incompatible with this module. Expected version "14.15.0". Got "15.2.0"

Currently, each time I run yarn add I have to put a flag to --ignore-engines to install properly.

Please can you set this to be Node 14 and above rather than the current version?

Larger list of word to filter out

The attached file is a merge of the data found here and something claimed to be google's list. The next result is just over a thousand entries instead of fewer than 500. More is not better if too many false positive result, but I think this larger file is good. Changed from .ts to .txt just to upload it.
profane-words.txt

Input word "a$$" causing false positives in the Regex

Hi there, thanks for this library.

I was just running it through an ID generator today to test it out, and printed out when it found an ID containing a bad word- these were some of the IDs it found (I'm using wholeWord=false ):

(I can't see any profanity here:)

MPEUGNMA
68Q56K5A
FCHZ6ZHA
UF7622DA
98AS3KVA
VFR9D5WA
4YX5AWVA
YVMNJU9A
DP4NMN8A
9PJMLM6A
ZNIVMM3A
XJMZC24A

These it found, which I can clearly see the profanity:

FFP7YFAG
S6FASSYJ

After writing this issue now, I can clearly see a pattern emerging. I think there is an issue happening with the input of the text from the file into the regex creation, which is causing one of the rules to include anything which ends with the letter A.

This might be the culprit: a$$- since $ represents "end of word" in regex.


In fact, I can confirm that, once I manually removed it from the words.txt file - I am not getting those false positives anymore.

Add partial grawlix option

Presently, the censor method replaces the entire profane word with a grawlix. Thought it might be cool to add an option that only replaces the vowels in a profane word.

Acceptance Criteria

  1. Add optional usePartialGrawlix param to the censor method. Default to false.
  2. Add partialGrawlix option to ProfanityOptions. Defaults to '*'.
  3. When usePartialGrawlix is true, instead of the entire profane word being replaced with the grawlix, only the vowels are replaced within the profane word. Each vowel is replaced with the partialGrawlix value.
  4. Update readme Options section.

Example

Configure

import { Profanity, ProfanityOptions } from '@2toad/profanity';

const options = new ProfanityOptions();
options.partialGrawlix = '*';

const profanity = new Profanity(options);

Usage

profanity.censor('I like big butts (aka arses) and I cannot lie', true);
// I like big b*tts (aka *rs*s) and I cannot lie

ProfanityOptions wholeWord does not appear to be working as intended

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚. Love this little lib. Nice work!

We tested the module with Massterly (African female name) and it showed:

M***terly

I think this might be fixed if we add the words before building the regex:

  constructor(options?: ProfanityOptions) {
    this.options = options || new ProfanityOptions();

    this.whitelist = new List(() => this.buildRegex());
    this.blacklist = new List(() => this.buildRegex());

    this.blacklist.addWords(profaneWords);
  }

would become:

  constructor(options?: ProfanityOptions) {
    this.options = options || new ProfanityOptions();

   this.blacklist.addWords(profaneWords);

    this.whitelist = new List(() => this.buildRegex());
    this.blacklist = new List(() => this.buildRegex());
  }

Today I used patch-package to patch @2toad/[email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@2toad/profanity/dist/profanity.js b/node_modules/@2toad/profanity/dist/profanity.js
index 9b64c31..0bc494a 100644
--- a/node_modules/@2toad/profanity/dist/profanity.js
+++ b/node_modules/@2toad/profanity/dist/profanity.js
@@ -8,9 +8,9 @@ const profane_words_1 = require("./data/profane-words");
 class Profanity {
     constructor(options) {
         this.options = options || new profanity_options_1.ProfanityOptions();
+        this.blacklist.addWords(profane_words_1.default);
         this.whitelist = new models_1.List(() => this.buildRegex());
         this.blacklist = new models_1.List(() => this.buildRegex());
-        this.blacklist.addWords(profane_words_1.default);
     }
     exists(text) {
         this.regex.lastIndex = 0;

This issue body was partially generated by patch-package.

Need some help

so about 2 years ago i created a bot to work with this however i have been trying to modify it now so it uses different txt files for different servers now instead of one file.

i added a new option to ProfanityOptions
class ProfanityOptions { constructor() { this.wholeWord = true; this.grawlix = '****'; this.guildname = 'yolo'; } }

Which my bot can change WholeWord and Grawlix however its unable to change the guildname part that i added it in. no idea what im doing wrong. and the contact page and your website is refusing to work with me so i was just wondering if you could help explain what i need to-do to add more custom Options to the the profanity filter. i have the bot auto create txt files for every server it's connected to however this is the last part i need to try and sort out been sat here for about 6 hours trying to figure it out that im going mad.

Apologies for it not being an actual issue

Much appreciated, Dane

Cannot add new profane words.

I was checking out this and was trying to implement it into my (NextJS) project.
I had quite a few words to add so I manually added them on the list on "profane-words.js" file, but the filter doesn't seem to work with the added words. Also noticed that profanity.addWords() and profanity.removeWords() only works on the instance where they are triggered, but I may be wrong.

I could use some help here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.