linguine 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/{common_words_en.txt → config/common_words_en.txt} +0 -0
- data/config/swear_words_en.txt +77 -0
- data/lib/linguine.rb +28 -21
- data/linguine-0.0.4.gem +0 -0
- data/linguine.gemspec +1 -1
- data/spec/linguine_spec.rb +2 -7
- data/spec/terms_spec.rb +11 -7
- metadata +5 -5
- data/spec/madlibs_spec.rb +0 -20
File without changes
|
@@ -0,0 +1,77 @@
|
|
1
|
+
anal
|
2
|
+
anus
|
3
|
+
arse
|
4
|
+
ass
|
5
|
+
ballsack
|
6
|
+
balls
|
7
|
+
bastard
|
8
|
+
bitch
|
9
|
+
biatch
|
10
|
+
bloody
|
11
|
+
blowjob
|
12
|
+
blow job
|
13
|
+
bollock
|
14
|
+
bollok
|
15
|
+
boner
|
16
|
+
boob
|
17
|
+
bugger
|
18
|
+
bum
|
19
|
+
butt
|
20
|
+
buttplug
|
21
|
+
clitoris
|
22
|
+
cock
|
23
|
+
coon
|
24
|
+
crap
|
25
|
+
cunt
|
26
|
+
damn
|
27
|
+
dick
|
28
|
+
dildo
|
29
|
+
dyke
|
30
|
+
fag
|
31
|
+
feck
|
32
|
+
fellate
|
33
|
+
fellatio
|
34
|
+
felching
|
35
|
+
fuck
|
36
|
+
f u c k
|
37
|
+
fudgepacker
|
38
|
+
fudge packer
|
39
|
+
flange
|
40
|
+
Goddamn
|
41
|
+
God damn
|
42
|
+
hell
|
43
|
+
homo
|
44
|
+
jerk
|
45
|
+
jizz
|
46
|
+
knobend
|
47
|
+
knob end
|
48
|
+
labia
|
49
|
+
lmao
|
50
|
+
lmfao
|
51
|
+
muff
|
52
|
+
nigger
|
53
|
+
nigga
|
54
|
+
omg
|
55
|
+
penis
|
56
|
+
piss
|
57
|
+
poop
|
58
|
+
prick
|
59
|
+
pube
|
60
|
+
pussy
|
61
|
+
queer
|
62
|
+
scrotum
|
63
|
+
sex
|
64
|
+
shit
|
65
|
+
s hit
|
66
|
+
sh1t
|
67
|
+
slut
|
68
|
+
smegma
|
69
|
+
spunk
|
70
|
+
tit
|
71
|
+
tosser
|
72
|
+
turd
|
73
|
+
twat
|
74
|
+
vagina
|
75
|
+
wank
|
76
|
+
whore
|
77
|
+
wtf
|
data/lib/linguine.rb
CHANGED
@@ -1,33 +1,26 @@
|
|
1
1
|
class Linguine
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
@@common_words = []
|
4
|
+
@@swear_words = []
|
5
|
+
|
6
|
+
def initialize(text, method = :fuzzy)
|
6
7
|
@method = method
|
7
8
|
@text = text
|
8
9
|
@terms = []
|
9
10
|
@madlibs = text
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
|
12
|
+
if @@common_words.empty?
|
13
|
+
read_common_words
|
14
|
+
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def read_common_words
|
21
|
-
File.open('common_words_en.txt', 'r') do |f|
|
22
|
-
while line = f.gets
|
23
|
-
@common_words << line.gsub("\n", '')
|
24
|
-
end
|
16
|
+
if @@swear_words.empty?
|
17
|
+
read_swear_words
|
25
18
|
end
|
26
19
|
end
|
27
20
|
|
28
|
-
def
|
21
|
+
def terms
|
29
22
|
@text.split(' ').uniq.each do |word|
|
30
|
-
if
|
23
|
+
if !@@common_words.include?(word)
|
31
24
|
@terms << {
|
32
25
|
word: word,
|
33
26
|
score: Linguine::Scores.scrabble_score(word)
|
@@ -38,8 +31,22 @@ class Linguine
|
|
38
31
|
@terms.sort_by{|t| t[:score]}.reverse
|
39
32
|
end
|
40
33
|
|
41
|
-
|
42
|
-
|
34
|
+
private
|
35
|
+
|
36
|
+
def read_common_words
|
37
|
+
File.open('config/common_words_en.txt', 'r') do |f|
|
38
|
+
while line = f.gets
|
39
|
+
@@common_words << line.gsub("\n", '')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def read_swear_words
|
45
|
+
File.open('config/swear_words_en.txt', 'r') do |f|
|
46
|
+
while line = f.gets
|
47
|
+
@@swear_words << line.gsub("\n", '')
|
48
|
+
end
|
49
|
+
end
|
43
50
|
end
|
44
51
|
|
45
52
|
end
|
data/linguine-0.0.4.gem
ADDED
Binary file
|
data/linguine.gemspec
CHANGED
data/spec/linguine_spec.rb
CHANGED
@@ -3,12 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Linguine do
|
4
4
|
|
5
5
|
it 'should initialize' do
|
6
|
-
@linguine = Linguine.new(
|
6
|
+
@linguine = Linguine.new('This is my text. There are many like it, but this one is mine.', :fuzzy)
|
7
7
|
end
|
8
|
-
|
9
|
-
it 'should have a list of common words' do
|
10
|
-
@linguine = Linguine.new(:rough, 'This is my text. There are many like it, but this one is mine.')
|
11
|
-
@linguine.common_words.should_not be_empty
|
12
|
-
end
|
13
|
-
|
8
|
+
|
14
9
|
end
|
data/spec/terms_spec.rb
CHANGED
@@ -5,25 +5,29 @@ describe Linguine do
|
|
5
5
|
context 'collect terms' do
|
6
6
|
|
7
7
|
it 'should return a value' do
|
8
|
-
@linguine = Linguine.new(
|
8
|
+
@linguine = Linguine.new('This is my text. There are many like it, but this one is mine.', :fuzzy)
|
9
9
|
@linguine.terms.should_not be_empty
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'should return a sorted list of terms' do
|
13
|
-
@linguine = Linguine.new(
|
14
|
-
@linguine.terms.first.should == {word: '
|
13
|
+
@linguine = Linguine.new('This is my text. There are many like it, but this one is mine.', :fuzzy)
|
14
|
+
@linguine.terms.first.should == {word: 'text.', score: 11}
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should return a unique list of terms' do
|
18
|
-
@linguine = Linguine.new(
|
18
|
+
@linguine = Linguine.new('This is my text. There are many like it, but this one is mine.', :fuzzy)
|
19
19
|
@linguine.terms.should == @linguine.terms.uniq
|
20
20
|
end
|
21
21
|
|
22
|
-
it 'should
|
23
|
-
@linguine = Linguine.new(
|
24
|
-
puts @linguine.terms
|
22
|
+
it 'should not add common words to the terms' do
|
23
|
+
@linguine = Linguine.new('war', :fuzzy)
|
25
24
|
@linguine.terms.should be_empty
|
26
25
|
end
|
26
|
+
|
27
|
+
it 'should add non common words to the terms' do
|
28
|
+
@linguine = Linguine.new('war famine', :fuzzy)
|
29
|
+
@linguine.terms.should == [{word: 'famine', score: 11}]
|
30
|
+
end
|
27
31
|
|
28
32
|
end
|
29
33
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linguine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-26 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: ''
|
15
15
|
email:
|
@@ -21,12 +21,13 @@ files:
|
|
21
21
|
- Gemfile
|
22
22
|
- Gemfile.lock
|
23
23
|
- README.md
|
24
|
-
- common_words_en.txt
|
24
|
+
- config/common_words_en.txt
|
25
|
+
- config/swear_words_en.txt
|
25
26
|
- lib/linguine.rb
|
26
27
|
- lib/linguine/scores.rb
|
28
|
+
- linguine-0.0.4.gem
|
27
29
|
- linguine.gemspec
|
28
30
|
- spec/linguine_spec.rb
|
29
|
-
- spec/madlibs_spec.rb
|
30
31
|
- spec/spec_helper.rb
|
31
32
|
- spec/terms_spec.rb
|
32
33
|
homepage: http://rubygems.org/gems/linguine
|
@@ -55,6 +56,5 @@ specification_version: 3
|
|
55
56
|
summary: ''
|
56
57
|
test_files:
|
57
58
|
- spec/linguine_spec.rb
|
58
|
-
- spec/madlibs_spec.rb
|
59
59
|
- spec/spec_helper.rb
|
60
60
|
- spec/terms_spec.rb
|
data/spec/madlibs_spec.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Linguine do
|
4
|
-
|
5
|
-
context 'madlibs' do
|
6
|
-
|
7
|
-
it 'should return a shuffled version' do
|
8
|
-
text = 'This is my text. There are many like it, but this one is mine.'
|
9
|
-
@linguine = Linguine.new(:rough, text)
|
10
|
-
@linguine.madlibs.should_not == text
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should capitalize the sentence' do
|
14
|
-
@linguine = Linguine.new(:rough, 'This is my text. There are many like it, but this one is mine.')
|
15
|
-
@linguine.madlibs[0].should == @linguine.madlibs[0].capitalize
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|