l2e_vocab_blacklist 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32359d6f8e221d893a5b00b182452508066a8af8
4
- data.tar.gz: 37cc97866bb88cf197cc619d63bd6a1a83b5cb88
3
+ metadata.gz: c0a855f57a636fb8e7d01bc4036ad56b0e35976d
4
+ data.tar.gz: ab46f63f8dc08c9a81816e1d0c7bb3f2168b8022
5
5
  SHA512:
6
- metadata.gz: 59abcfa730b9ba973dc356740b38d37f8d82e1f66ebd72902fe85994d756b0580fd48128a343af17e525c80ce2b6c3eba2f3c0844a103fac1c651b14d0d1ef83
7
- data.tar.gz: fe35639b3131ff824fda3639979ca129c195775f1710fc9049936cfb5dac58976a494e78e277710bd43e593b65a0427c274a97470cae693316eb9aa9f3f9ccd2
6
+ metadata.gz: e02de0ce46669ea163efb08cb9c787ddd0c11c9380f902c018344bc4f64815b2bfe2da4cc732831e213ddf00de22de217ae6bf8313976bd134239150c04a46c1
7
+ data.tar.gz: 131180e147384652932bb0aadf3e3e82e22a78a8e9c1d3d532936978e584d7bf474238c2a7050f38c24c1a8efc1d813f0990458242089a81c7983fb6c9d1be17
@@ -4,12 +4,25 @@ require 'csv'
4
4
  class VocabBlacklist
5
5
 
6
6
  # Returns true or false, check to see if the
7
- def self.blacklisted?(str,age ="0")
7
+ def self.blacklisted?(str, age = "0")
8
8
  # Sanitize string
9
- str = str.downcase.strip.gsub(CONSIDER_REGEX, '')
9
+ str = str.downcase.strip
10
+
11
+ whitelisted_phrases = self.whitelist_matches(str)
12
+
10
13
  # Blacklist if any of the words
11
- str.split(" ").each do |word|
12
- return true if check_full_words_csv(word,age)
14
+ str.split(/[ -]/).each do |word|
15
+ word = word.gsub(CONSIDER_REGEX, "")
16
+
17
+ if check_full_words_csv(word, age)
18
+
19
+ is_whitelisted = whitelisted_phrases.any? do |phrase|
20
+ phrase.include?(word)
21
+ end
22
+ if !is_whitelisted
23
+ return true
24
+ end
25
+ end
13
26
  end
14
27
  # For compound dirty words
15
28
  PHRASES.each do |bad_phrase|
@@ -19,30 +32,46 @@ class VocabBlacklist
19
32
  return GREEDY_WORDS.any? { |s| str.include?(s) }
20
33
  end
21
34
 
35
+ def self.whitelist_matches(text)
36
+ text = text.downcase.strip.gsub(CONSIDER_REGEX, "")
37
+ WHITELIST.select do |whitelist_phrase|
38
+ text.include?(whitelist_phrase)
39
+ end
40
+
41
+ end
22
42
 
23
43
  def self.censor(str, age = "0", replace_with = "****")
24
44
  PHRASES.each do |bad_phrase|
25
- str.gsub!(/#{bad_phrase}/i, replace_with)
45
+ str.gsub!(/#{ bad_phrase }/i, replace_with)
26
46
  end
27
47
 
48
+ whitelisted_phrases = self.whitelist_matches(str)
49
+
28
50
  str.split(/ /).map do |working_word|
51
+ working_word.split(/-/).map do |sub_working_word|
52
+ word = sub_working_word.downcase.gsub(CONSIDER_REGEX, "")
29
53
 
30
- word = working_word.downcase.gsub(CONSIDER_REGEX, '')
54
+ is_whitelisted = whitelisted_phrases.any? do |phrase|
55
+ phrase.include?(word)
56
+ end
31
57
 
32
- if check_full_words_csv(word,age)
33
- working_word.gsub!(/#{word}/i, replace_with)
34
- end
58
+ if !is_whitelisted
59
+ if check_full_words_csv(word, age)
60
+ sub_working_word.gsub!(/#{ word }/i, replace_with)
61
+ end
35
62
 
36
- if GREEDY_WORDS.any? { |w| word.include?(w) }
37
- working_word = replace_with
38
- end
39
-
40
- working_word
63
+ if GREEDY_WORDS.any? { |w| word.include?(w) }
64
+ sub_working_word = replace_with
65
+ end
66
+ end
67
+
68
+ sub_working_word
69
+ end.join("-")
41
70
  end.join(" ")
42
71
  end
43
72
 
44
73
  def self.file_to_normalized_words(file)
45
- CSV.parse(File.read(file)).map(&:first).reject { |s| s.to_s.strip.empty? }.map(&:downcase).map { |s| s.gsub(CONSIDER_REGEX, '') }
74
+ CSV.parse(File.read(file)).map(&:first).reject { |s| s.to_s.strip.empty? }.map(&:downcase).map { |s| s.gsub(CONSIDER_REGEX, "") }
46
75
  end
47
76
 
48
77
  def self.words_with_expansions(words)
@@ -55,15 +84,17 @@ class VocabBlacklist
55
84
  PHRASES = file_to_normalized_words("#{BLACKLIST_DIR}/full_words.csv").select { |w| w.split(" ").length > 1 }
56
85
  FULL_WORDS = file_to_normalized_words("#{BLACKLIST_DIR}/full_words.csv").reject { |w| w.split(" ").length > 1 }
57
86
  GREEDY_WORDS = words_with_expansions(file_to_normalized_words("#{BLACKLIST_DIR}/greedy_words.txt")).uniq.freeze
87
+ WHITELIST = file_to_normalized_words("#{BLACKLIST_DIR}/whitelist.csv").uniq.freeze
58
88
 
59
89
  FULL_WORDS_CSV = CSV.parse(File.read("#{BLACKLIST_DIR}/full_words.csv"))
60
90
 
61
91
  private
62
92
 
63
- def self.check_full_words_csv(word,age)
64
- FULL_WORDS_CSV.each do |row|
65
- return true if row[1].to_i >= age.to_i && row[0].downcase == word.downcase
93
+ def self.check_full_words_csv(word, age)
94
+ FULL_WORDS_CSV.each do |row|
95
+ return true if row[1].to_i >= age.to_i && row[0].downcase == word.downcase
96
+ end
97
+ return false
66
98
  end
67
- return false
68
- end
99
+
69
100
  end
@@ -7,6 +7,8 @@ Apeshit,15
7
7
  Ass,15
8
8
  Asshole,10
9
9
  B*tch,15
10
+ Badass,15
11
+ Bad-ass,15
10
12
  Barbiturates,5
11
13
  Bastard,10
12
14
  Beaner,15
@@ -52,6 +54,8 @@ Crip,10
52
54
  Cum,15
53
55
  Cumming,15
54
56
  Cumshot,15
57
+ Cumslut,15
58
+ Cum-slut,15
55
59
  Cunnilingus,15
56
60
  Cunt,15
57
61
  Damn,5
@@ -69,7 +73,6 @@ Doggy Style,15
69
73
  Doobie,15
70
74
  Douche,15
71
75
  Drag Queen,5
72
- Drugs,5
73
76
  Dyke,15
74
77
  Ejaculate,10
75
78
  Ejaculation,10
@@ -121,6 +124,7 @@ Hickey,5
121
124
  Hickie,5
122
125
  Homosexual,5
123
126
  Hooker,10
127
+ Horny,15
124
128
  Huff,10
125
129
  Huffing,10
126
130
  Hungover,10
@@ -132,6 +136,8 @@ Jerk Off,15
132
136
  Jerkoff,15
133
137
  Jigga,15
134
138
  Joint,10
139
+ Kickass,15
140
+ Kick-ass,15
135
141
  Kunt,15
136
142
  Kyke,15
137
143
  Labia,10
@@ -144,7 +150,6 @@ Lubrication,5
144
150
  Lust,5
145
151
  Lustful,5
146
152
  Marijuana,10
147
- Mary Jane,15
148
153
  Masturbate,10
149
154
  Masturbating,10
150
155
  Masturbation,10
@@ -159,14 +164,13 @@ Moneyshot,15
159
164
  Moron,5
160
165
  Motherf*cker,15
161
166
  Narcotic,5
162
- Negro,5
163
- Nicotine,5
164
167
  Nigga,15
165
168
  Nignog,15
166
169
  Nips,15
167
170
  Niptip,15
168
171
  Nookie,15
169
172
  Nooky,15
173
+ Nude,10
170
174
  Opiates,5
171
175
  Opium,5
172
176
  Oral sex,15
@@ -178,7 +182,6 @@ Oxy,15
178
182
  Oxycodone,10
179
183
  P*ss,15
180
184
  Panties,10
181
- Pee,5
182
185
  Penile,5
183
186
  Penis,10
184
187
  Playboy,10
@@ -235,7 +238,6 @@ Sucker,10
235
238
  Suicide,5
236
239
  Syphilis,10
237
240
  T*t,15
238
- Tequila,5
239
241
  Testes,10
240
242
  Testicle,10
241
243
  Testicular,10
@@ -252,6 +254,7 @@ Transgendered,5
252
254
  Transvestite,10
253
255
  Turd,15
254
256
  Twerk,15
257
+ Uncensored,10
255
258
  Urethra,10
256
259
  Urine,5
257
260
  Uterus,5
@@ -0,0 +1 @@
1
+ moby dick,5
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: l2e_vocab_blacklist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Sherrid
8
- - Learn2Earn
9
- - Whooo's Reading
8
+ - Gilles Ferone
9
+ - Whooo's Reading by Learn2Earn
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-08-13 00:00:00.000000000 Z
13
+ date: 2018-04-02 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Detect words and partial-words that shouldn't be used on Learn2Earn Whooo's
16
16
  Reading website
@@ -19,10 +19,11 @@ executables: []
19
19
  extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
+ - README.md
22
23
  - lib/l2e_vocab_blacklist.rb
23
- - lib/l2e_vocab_blacklist/blacklists/greedy_words.txt
24
24
  - lib/l2e_vocab_blacklist/blacklists/full_words.csv
25
- - README.md
25
+ - lib/l2e_vocab_blacklist/blacklists/greedy_words.txt
26
+ - lib/l2e_vocab_blacklist/blacklists/whitelist.csv
26
27
  homepage: https://github.com/whooosreading/l2e_vocab_blacklist
27
28
  licenses:
28
29
  - All rights reserved, for now
@@ -33,17 +34,17 @@ require_paths:
33
34
  - lib
34
35
  required_ruby_version: !ruby/object:Gem::Requirement
35
36
  requirements:
36
- - - '>='
37
+ - - ">="
37
38
  - !ruby/object:Gem::Version
38
39
  version: '0'
39
40
  required_rubygems_version: !ruby/object:Gem::Requirement
40
41
  requirements:
41
- - - '>='
42
+ - - ">="
42
43
  - !ruby/object:Gem::Version
43
44
  version: '0'
44
45
  requirements: []
45
46
  rubyforge_project:
46
- rubygems_version: 2.0.3
47
+ rubygems_version: 2.6.11
47
48
  signing_key:
48
49
  specification_version: 4
49
50
  summary: L2E Vocab Blacklist