Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

updated readme and Rakefile. Fixed bug in flagged_words.

  • Loading branch information...
commit 44be36d98f7ddca75d88382d6ccc7f8974540540 1 parent c5eec69
authored August 10, 2011
108  README.markdown
Source Rendered
... ...
@@ -1,108 +0,0 @@
1  
-# profanalyzer
2  
-
3  
-* http://profanalyzer.rubyforge.org/
4  
-
5  
-## Description
6  
-
7  
-Profanalyzer has one purpose: analyze a block of text for profanity. It is able to filter profane words as well. 
8  
-
9  
-What sets it slightly apart from other filters is that it classifies each blocked word as "profane", "racist", or "sexual" - although right now, each word is considered "profane". It also rates each word on a scale from 0-5,  which is based on my subjective opinion, as well as whether the word is commonly used in non-profane situations, such as "ass" in "assess".
10  
-
11  
-The Profanalyzer will default to a tolerance of of 4, which will kick back the arguably non-profane words. It will also test against all words, including racist or sexual words.
12  
-
13  
-Lastly, it allows for custom substitutions! For example, the filter at the website http://www.fark.com/ turns the word "fuck" into "fark", and "shit" into "shiat". You can specify these if you want.
14  
-
15  
-## FEATURES/PROBLEMS:
16  
-
17  
-* Tolerance-based filtering
18  
-* Switch between checking all words, racist terms, sexual words, or some 
19  
-  mixture
20  
-* Custom substitutions
21  
-* Boolean-based profanity checking (skipping the filtering)
22  
-
23  
-## SYNOPSIS:
24  
-
25  
-Out of the box, you can simply use Profanalyzer.filter and 
26  
-Profanalyzer.profane?:
27  
-
28  
-    require 'rubygems'
29  
-    require 'profanalyzer'
30  
-    
31  
-    Profanalyzer.profane? "asshole" #==> true
32  
-    Profanalyzer.filter   "asshole" #==> "#!$%@&!"
33  
-
34  
-Then you can change the tolerance:
35  
-
36  
-    Profanalyzer.tolerance = 5
37  
-    Profanalyzer.profane? "hooker" #==> false
38  
-
39  
-Or do specific checking:
40  
-
41  
-    Profanalyzer.check_all = false # turn off catch-all checking
42  
-    Profanalyzer.check_racist = false # don't check racial slurs
43  
-    Profanalyzer.check_sexual = true # sexual checking on
44  
-    
45  
-    Profanalyzer.profane? "mick" #==> false
46  
-    Profanalyzer.profane? "vagina" #==> true
47  
-
48  
-You can obtain a list of the words which fell afoul of profanity checking:
49  
-
50  
-    Profanalyzer.flagged_words("shit damn foo") #==> ["shit", "damn"] 
51  
-    Profanalyzer.flagged_words("profanalyzer is rad!") #==> [] 
52  
-    
53  
-    # With custom settings
54  
-    Profanalyzer.check_all = false
55  
-    Profanalyzer.check_racist = false
56  
-    Profanalyzer.flagged_words("you're a mick") #==> []
57  
-    
58  
-    # You can pass options to the method itself:
59  
-    Profanalyzer.flagged_words("you're a mick", :racist => false) #==> []
60  
-
61  
-Lastly, you can add custom substitutions:
62  
-
63  
-    Profanalyzer.substitute("shit","shiat")
64  
-    Profanalyzer.filter "shit" #==> "shiat"
65  
-    
66  
-    Profanalyzer.substitute(:fuck => :fark)
67  
-    Profanalyzer.filter("fuck") #==> "fark"
68  
-
69  
-
70  
-## Requirements
71  
-
72  
-hoe - a gem for building gems, which I used for profanalyzer.
73  
-
74  
-## Contributors
75  
-
76  
-* Michael Edgar <adgar@carboni.ca>
77  
-* Thomas Hanley <tjhanley.com@gmail.com>
78  
-* Peter Vandenberk <pvandenberk@mac.com>
79  
-* Christopher M. Hobbs <chris@altbit.org> (nilmethod)
80  
-
81  
-## Installation
82  
-
83  
-sudo gem install profanalyzer
84  
-
85  
-## License
86  
-
87  
-(The MIT License)
88  
-
89  
-Copyright (c) 2009 FIX
90  
-
91  
-Permission is hereby granted, free of charge, to any person obtaining
92  
-a copy of this software and associated documentation files (the
93  
-'Software'), to deal in the Software without restriction, including
94  
-without limitation the rights to use, copy, modify, merge, publish,
95  
-distribute, sublicense, and/or sell copies of the Software, and to
96  
-permit persons to whom the Software is furnished to do so, subject to
97  
-the following conditions:
98  
-
99  
-The above copyright notice and this permission notice shall be
100  
-included in all copies or substantial portions of the Software.
101  
-
102  
-THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
103  
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
104  
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
105  
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
106  
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
107  
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
108  
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  Rakefile
@@ -4,27 +4,10 @@ require 'rubygems'
4 4
 require 'hoe'
5 5
 require './lib/profanalyzer.rb'
6 6
 
7  
-Hoe.new('profanalyzer', Profanalyzer::VERSION) do |p|
8  
-  p.rubyforge_name = 'profanalyzer' # if different than lowercase project name
9  
-  p.developer('Michael J. Edgar', 'edgar@triqweb.com')
  7
+Hoe.spec('profanalyzer') do |p|
  8
+  p.developer('Michael J. Edgar', 'adgar@carboni.ca')
10 9
   p.remote_rdoc_dir = ''
11 10
   p.summary = "Analyzes a block of text for profanity. It is able to filter profane words as well."
12  
-  desc 'Post your blog announcement to blogger.'
13  
-  task :post_blogger do
14  
-    require 'blogger'
15  
-    p.with_config do |config, path|
16  
-      break unless config['blogs']
17  
-      subject, title, body, urls = p.announcement
18  
-      
19  
-      config['blogs'].each do |site|
20  
-        next unless site['url'] =~ /www\.blogger\.com/
21  
-        acc = Blogger::Account.new(site['user'],site['password'])
22  
-        post = Blogger::Post.new(:title => title, :content => body, :categories => p.blog_categories, :formatter => :rdiscount)
23  
-        acc.post(site['blog_id'], post)
24  
-
25  
-      end
26  
-    end
27  
-  end
28 11
   desc 'Pushes rdocs to carbonica'
29 12
   task :carbonica => :redocs do
30 13
     sh "scp -r doc/ adgar@carboni.ca@carboni.ca:/var/www/html/projects/#{p.name}/"
2  lib/profanalyzer.rb
@@ -209,10 +209,10 @@ def self.flagged_words(*args)
209 209
     banned_words = self.forbidden_words_from_settings
210 210
     banned_words.each do |word|
211 211
       if str =~ /\b#{word}\b/i
212  
-        @@settings = oldsettings if oldsettings
213 212
         flagged_words << word
214 213
       end
215 214
     end
  215
+    @@settings = oldsettings if oldsettings
216 216
     return flagged_words
217 217
   end
218 218
 

0 notes on commit 44be36d

Please sign in to comment.
Something went wrong with that request. Please try again.