Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to add more words to dictionary? #7

Open
valcaro87 opened this issue Jul 29, 2021 · 2 comments
Open

how to add more words to dictionary? #7

valcaro87 opened this issue Jul 29, 2021 · 2 comments

Comments

@valcaro87
Copy link

No description provided.

@valcaro87
Copy link
Author

@amiel
Copy link

amiel commented Apr 28, 2022

I realize your question was quite a while ago, but in case this helps the next person looking here, I was able to add more disallowed words with something like this:

profanity_filter = ProfanityFilter.new
profanity_filter.available_strategies[:custom] = CustomProfanityFilterStrategy.setup

profanity_filter.profane? word, strategies: [:duplicate_characters, :custom]

```ruby
# You may want to change your base strategy here, depending on your needs
class CustomProfanityFilterStrategy < ProfanityFilterEngine::AllowDuplicateCharactersStrategy
  # Put all of your words here, or load them from a file somehow
  DICTIONARY = %w[idiots].freeze

  def self.setup
    new(dictionary: DICTIONARY, ignore_case: true)
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants