Bomberman

This add-on is operated by Ikayzo Inc.

Shelter from profanity bombing

Bomberman

Last Updated: 19 March 2014

Table of Contents

Bomberman: shelter from profanity bombing, is an add-on for providing profanity detection/filtering for text content.

Sometimes your content has to be family friendly, or safe for work. Adding Bomberman to your application is like putting a bomb shelter around your application. With this add-on you can tailor exactly which words and phrases you would like to filter based on your target demographic.

There are currently 3 different ways Bomberman can help shelter you from profanity your user entered content.

  1. Check if a piece of text contains profanity
  2. Replace profane words in a piece of text with ‘***’ or other another string of your choosing
  3. Wrap the profane words in closing and ending tags/characters to highlight them in a piece of text

Bomberman is accessible via an HTTP API and has supported client libraries for Ruby.

Provisioning the add-on

Bomberman can be attached to a Heroku application via the CLI:

A list of all plans available can be found here.

$ heroku addons:add bomberman
-----> Adding bomberman to drunken-tyrion-4005... done, v18 (free)

Once Bomberman has been added a BOMBERMAN_API_KEY setting will be available in the app configuration and will contain the API key for the. This can be confirmed using the heroku config:get command.

$ heroku config:get BOMBERMAN_API_KEY
793687a6753581e75510d09bc221c8a6

After installing Bomberman the application is configured to fully integrate with the add-on.

Local setup

Environment setup

After provisioning the add-on it’s necessary to locally replicate the config vars so your development environment can operate against the service.

Though less portable it’s also possible to set local environment variables using export BOMBERMAN_API_KEY=value.

Use Foreman to reliably configure and run the process formation specified in your app’s Procfile. Foreman reads configuration variables from an .env file. Use the following command to add the BOMBERMAN_API_KEY values retrieved from heroku config to .env.

$ heroku config -s | grep BOMBERMAN_API_KEY >> .env
$ more .env

Credentials and other sensitive configuration values should not be committed to source-control. In Git exclude the .env file with: echo .env >> .gitignore.

Using with Rails 3.x

We developed a ruby client gem for making requests to the Bomberman API.

Ruby on Rails applications will need to add the following entry into their Gemfile specifying the Bomberman client library.

gem 'bomberman'

Update application dependencies with bundler.

$ bundle install

Now create an initializer file config/initializers/bomberman.rb with your BOMBERMAN_API_KEY

Bomberman.configure do |config|
  config.api_key = ENV['BOMBERMAN_API_KEY']
end

Assuming you have setup your local environment per previous section, you can now use Bomberman::Profanity functionality both locally and on Heroku.

Checking if text contains profanity

To check if a piece of text or corpus contains profanity use the .profane?(corpus) method. This will return a boolean value as the result

non_profane_text = "The quick brown fox jumped over the lazy dog."
Bomberman::Profanity.profane?(non_profane_text)
  #=> false
profane_text = "The quick brown fox jumped over the F-BOMBing lazy dog."
Bomberman::Profanity.profane?(profane_text)
  #=> true

Censoring profane words & phrases

If you would like to save or display text where the profane words (if any) are obfuscated the .censor(corpus, replacement_text) method is what you are looking for.

non_profane_text = "The quick brown fox jumped over the lazy dog."
Bomberman::Profanity.censor(non_profane_text, "####")
  #=> "The quick brown fox jumped over the lazy dog."
profane_text = "The quick brown fox jumped over the F-BOMBing lazy dog."
Bomberman::Profanity.censor(profane_text, "####")
  #=> "The quick brown fox jumped over the ### lazy dog."

The replacement_text parameter is a string and optional. "***" is suppled by default.

Highlighting profane words & phrases

Sometimes it is useful to leave the original profane word/phrase intact but wrap it in some sort of tag to make it stand out. This can be accomplished with the .highlight(corpus, start_tag, end_tag) method.

non_profane_text = "The quick brown fox jumped over the lazy dog."
BomberMan::Profanity.highlight(non_profane_text, "<blink>", "</blink>")
  #=> "The quick brown fox jumped over the lazy dog."
profane_text = "The quick brown fox jumped over the F-BOMBing lazy dog."
BomberMan::Profanity.highlight(profane_text, "<blink>", "</blink>")
  #=> "The quick brown fox jumped over the <blink>F-BOMBing</blink> lazy dog."

The start_tag & end_tag parameters are strings and optional. A pair of opening and closing <strong> tags are used if none are provided.

Checking japanese text for profanity

Bomberman supports checking Japanese text for profanity. To do this pass an optional language argument with the value :ja as the last parameter to any of the Bomberman::Profanity methods

  non_profane_text = "聖パトリックの日"
  Bomberman::Profanity.profane?(non_profane_text, :ja)
     #=> false

Dashboard

The Bomberman dashboard allows you to tailor your profanity shelter to your specific needs. From here you can choose what specific words or phrases you want to block or allow through.

Bomberman Heroku Dashboard

The dashboard can be accessed via the CLI:

$ heroku addons:open bomberman
Opening bomberman for drunken-tyrion-4005…

or by visiting the Heroku apps web interface and selecting the application. Select Bomberman from the Add-ons menu.

Allowed phrases

These are phrases that include one or more words that by themselves would be considered profane, but strung together they compose a phrase you would like to allow through your shelter. Allowed Phrases must contain more than one word (non whitespace characters separated by a space).

Blocked phrases

Just because a phrase does not include profanity does not mean that it isn’t offensive to your users. Here you can beef up your shelter with specific phrases your targeted demographic might not like to see in your content. Blocked Phrases must contain more than one word (non whitespace characters separated by a space).

Blocked words

Adds custom protection to your shelter just like Blocked Phrases but for single words (cannot contain whitespace).

Japanese blocked words

Bomberman support for the Japanese language allows you to add custom blocked words. Click on the “Japanese” button in the language toggle at the top of the page. From here you will be brought to a Japanese localized page where you can manage the blocked words for this language.

Bomberman Japanese Heroku Dashboard

Troubleshooting

We are just starting out. If you experience trouble please contact us at bomberman-support@ikayzo.com.

Migrating between plans

Application owners should carefully manage the migration timing to ensure proper application function during the migration process.

Use the heroku addons:upgrade command to migrate to a new plan.

$ heroku addons:upgrade bomberman:f-bomb
-----> Upgrading bomberman:newplan to drunken-tyrion-4005... done, v18 ($59/mo)
       Your plan has been updated to: bomberman:f-bomb

Removing the add-on

Bomberman can be removed via the CLI.

This will destroy all associated data and cannot be undone!

$ heroku addons:remove bomberman
-----> Removing bomberman from drunken-tyrion-4005... done, v20 (free)

Support

All Bomberman support and runtime issues should be submitted via email to bomberman-support@ikayzo.com.