Pages

Sunday, August 28, 2011

What do the words arsenal and class have in common? (Word censorship in Moodle)

Profanity and word censorship. The purpose of today's post is to share with you how I enabled a Year-2008 improved Moodle censorship filter on my Moodle 1.9.7 site. I will let you know how I tweaked it to achieve the desired effect. So at the end of this post, you will know how to enable the 'new' Censorship filter that allows a good word list while censoring bad words. You will also know how to generate a list of good words that contain a swear word. Like the word mishit, or peacock, or Emily Dickinson. Okay, I think you get the picture.


Do you enable the word censorship filter of your Moodle site? I suspect that there is a high chance that you do not. There are many who consider it useless and ethically challenging. Some may have disabled it because it takes up processing time. My guess is that 99% of forum users are well-behaved and post appropriate and politically-correct text in a Moodle forums. After all, forum participants can be identified by their Moodle username. Okay, but what about the renegade 1% for whom profanity may be common-place in their vocabulary? If the technology allows that 1% to post what we would consider as profane words, should we care enough to do something?


Times, they are a-changing. What used to shock us decades ago no longer shocks society at large. Many of our modern movies, if we care to admit it, contain profanity. In the heat of the moment, in his or her excitement or just out of sheer frustration, a forum user might let loose a bomb-word in a forum post. By the time the offense is detected, the damage may have already been done. 


So do we really need to enable this feature? In its native form, I would say "no". The first time I enabled it, I set it to censor the word "ass". I then proceeded to create a forum where I used the words "Class" and "Assignment". Those two benign words, common to education, were filtered and were displayed as "Cl***" and "A**ignment". Oh no! I then disabled the filter.
However, if we could modify and improve the existing standard Moodle censorship filter, and depending on the subject that you teach, I would say that there is a case for it. By the way, the Word Censorship settings can be found at: Site Administration > Plugins > Filters.



Figure 1. Enabling the standard Moodle censorhip filter.


For those of you who do enable it, you might have discovered that the standard censorship filter has a problem. It can be overzealous in its work. This forum post highlights another complaint. For example, suppose the word ass were a bad word to be filtered. Then the word amass, which is a legitimate and word word, would be censored as am***. Ironically, the word in this format can be even more offensive. Such censorship draws the user's attention to the censored word. The student or child may ask, why is that word censored? Oh! That's why! This is a classic case of technology exacerbating a problem instead of alleviating it. On a related issue, check out http://thedailywtf.com/Articles/The-Clbuttic-Mistake-.aspx for laughs.

Okay, back to Moodle's standard censorship filter. As Anthony Borrow rightly reasons in this Moodle.org forum, the best way to counter profanity in the online classroom is to monitor, supervise, educate and hold the user accountable for his actions and words. True, but wouldn't it be better if the user forum dos-and-donts were coupled with a censorship filter that could also recognise a good word list? Meaning that the Moodle filter would censor the text asses and smartass but leave the words assassin and massachusetts alone? 



This problem was actually solved by John White in 2008. John documented an improved Moodle censorship filter (with overrides) in this moodle.org forum. In that post, John explained how he wrote the filter to be as efficient in processing as possible. 


Figure 2. John White's announcement in 2008 on Moodle.org

To download the improved censorship filter for Moodle 1.9., surf over to this moodle.org 
forum or click on this download link.The following text are taken from John White's installation instructions from the same forum:

To install the filter, the zip files need unpacking into filter/censorship (not censor),
but then the file censorship.php must be dragged into lang/en_utf8 to provide the English language strings.

Finally, there are 3 string definitions to add to the file: lang/en_utf8/admin.php in the alphabetic list (probably just abovegooglemapkey), these are:

$string['goodwordsconfig'] = 'Enter your list of good words that you do not want censored, separated by commas.';
$string['goodwordsdefault'] = 'No default good word list is expected.';
$string['goodwordslist'] = 'Custom good words list';


After editing and saving lang/en_utf8/admin.php, go to "Site Administration | Notifications" to install the new Censorship Filter. Then click on "Site Administration | Modules | Filters | Manage Filters". Choose the "Censorship (with overrrides)" filter and the Enable (eye) icon. Then click on Settings. 


Figure 3. Enabling the new Censorship filter


Edit the settings as in the very mild example shown below. In the example below, I am filtering the words ass and arse. Conversely, I am instructing the filter that the words Arsenal, amass, ambassador and sparse are to be left untouched.

Figure 4. Configuring the new improved censorship filter.


Click Save Changes. Then let's give the filter a run for its money! Create a forum post. Here's a rude forum post with some 'rude' words in it. Not that there are some normal words with rude words inside them. My apologies to Arsene Wenger and the fans of AFC!


Figure 5. A rude post.


After clicking the Post button, this is the end result:



Figure 6. The censorship filter works. Notice that the good words were untouched.

Well, it works - the words 'Arsenal', 'amassing", 'ambassador' and 'sparse' are spared the censor's asterisks. 

However, there is just one small problem. Do a mouseover on any one of the asterisk groups (censored word) and you will see the original censored word popup as a tooltip! Is this helpful? I think not.


Figure 7. The mouseover text is a problem. Do you really want that word to be shown to the user?


There is a way to solve this dilemma. I referred to this forum post on Moodle.org and then deduced the exact locations of the improved censorship filter's filter.php file to edit. Comment the lines as shown in the green lines of code. The modified lines of code are shown in magenta text below.



(around line 68 of filter.php)
// Mask used to determine if already censored
//$lmask = '<span class="censoredtext" title="';
$lmask = '<span class="censoredtext" ';
//$rmask = '">';
$rmask = '>';
...
(around line 95 of filter.php)
//$bwords[$key] = new filterobject_with_override($badword, $lmask.$badword.$rmask, $rspan, str_pad('',strlen($badword),'*'));
$bwords[$key] = new filterobject_with_override($badword, $lmask.$rmask, $rspan, str_pad('',strlen($badword),'*'));



There's just one more thing to be mindful off. Coming back the "Custom good words list" of Figure 4, what if you wanted to populate it with more good words? Hold on a second there bud, why would you want to do that? Well perhaps you're a moral purist who doesn't want to leave anything to chance. Even though 99% of your users' forum posts are clean and keep to your organisation's rules and guidelines. And perhaps, you're not worried about the filter bogging down your Moodle system because your server is running on Gigabytes of memory. So aren't there more words that contain the 'offensive' word ass? When will you get them from? Consult the Oxford Advanced Dictionary?

I would like to suggest the website http://www.morewords.com/contains/addwordhere.
If you were to surf to the URL http://www.morewords.com/contains/ass, the output would be a very long list of words containing the substring "ass" as in "hassle". As in the image below.



Figure 8. Now you know what can be in the good words list. There's over 1,000 words that contain the word "ass"!


If you want more good words to add to your filter, you can check out my lists on this forum post. I don't think I want to post them here because they contain the hidden bad words. Besides, this Blogspot site is rated G for General. There are literally hundreds, if not thousands, of such words. So choose your good words with care and do not overwhelm your Moodle system with them.


In conclusion, this improved censorship filter works with my Moodle 1.9.7 site. I have not tried the improved censorship filter with Moodle 2.x. On my site, I enabled the filter to block the common profanity words. I'm not telling you what they are on this blog! As for the good words, I have only enabled a few. If you are using your Moodle 1.9x site for your students to learn English literature or writing skills, then I think this filter will be an invaluable tool. The author of David Copperfield, and the author of the poem 'I am nobody who are you' would thank you for it. If they were alive today. So maybe their estates will thank you for enabling the filter.


So there you have it, a discerning text censorship system for your Moodle site. Whether you use it is up to you. Until the next time, this is Frankie signing off. To my Malaysian readers, "Selamat Hari Merdaka 2011 (Happy Independence Day)". To my international audience, wherever you are, my parting message to you is, "you have got to try a durian!".

If you like this post or site
a small donation would be nice but would last only a day,
otherwise leaving a comment (or a compliment) below will last me a month!

2 comments:

  1. Frankie, where do I find your solution for the hidden text filter from February 2012?

    Greetings, ger Tielemans

    ReplyDelete
    Replies
    1. Hi Ger! I'm not sure I understand what you are asking. Kindly repeat the question?

      Delete

Ratings and Recommendations by outbrain