find_keywords 0.0.3 → 0.1.1
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.
- checksums.yaml +4 -4
- data/README.md +22 -2
- data/find_keywords.gemspec +1 -1
- data/lib/find_keywords.rb +33 -60
- data/lib/find_keywords/find_keywords_string.rb +7 -0
- data/lib/find_keywords/remove_words_list.rb +78 -0
- data/lib/find_keywords/version.rb +1 -1
- data/spec/find_keywords_spec.rb +155 -80
- metadata +19 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90edb8b5485b51988bccf0db2ca9b7d94076eae1
|
4
|
+
data.tar.gz: 592138a923816431592da53f6bea6181ea6e0e1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2af4992aef8e1ff9a26e5a2dc5ba327405920fa9583f0d841197350d377b690ad71a5835d66ebfe1887dd7a9935b3ee51527fd642ed6974937f2ba909fbb6aef
|
7
|
+
data.tar.gz: 55a5af6a3d0fb065b247e703f06ddd04a84e2f7710fd413d280cfbee38e93821dbe890e29571f5f595faf9649db169e282cffb2eb438ac04842f7cf7a68e3855
|
data/README.md
CHANGED
@@ -18,9 +18,29 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
Find keywords is used to take a string (sentence), list (array), or a hash and return only
|
21
|
+
Find keywords is used to take a string (sentence), list (array), or a hash and return only keywords. It will remove the stop words and / or a list of other words provided.
|
22
22
|
|
23
|
-
|
23
|
+
You can now add a custom list of removal words using the class RemoveWordsList.
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
industry_specific_words= FindKeywords::RemoveWordsList.new(%w(free shipping members for))
|
27
|
+
sentence = "free shipping For women members"
|
28
|
+
keywords = FindKeywords::Keywords.new(sentence, industry_specific_words).keywords
|
29
|
+
keywords => ["women"]
|
30
|
+
```
|
31
|
+
There are three option for removing word lists.
|
32
|
+
|
33
|
+
Use both costum list and stop word list by add "all".
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
TODO:
|
37
|
+
industry_specific_words= FindKeywords::RemoveWordsList.new(%w(free shipping members for))
|
38
|
+
sentence = "free shipping For women members"
|
39
|
+
keywords = FindKeywords::Keywords.new(sentence, "all").keywords
|
40
|
+
keywords => ["women"]
|
41
|
+
```
|
42
|
+
|
43
|
+
```ruby
|
24
44
|
sentence = "_the yellow__jeans_"
|
25
45
|
keywords = FindKeywords::Keywords.new(sentence).keywords
|
26
46
|
keywords => ["yellow", "jeans"]
|
data/find_keywords.gemspec
CHANGED
@@ -20,6 +20,6 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "rspec"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
24
24
|
spec.add_development_dependency "pry"
|
25
25
|
end
|
data/lib/find_keywords.rb
CHANGED
@@ -1,51 +1,14 @@
|
|
1
1
|
require "find_keywords/version"
|
2
|
+
require "find_keywords/remove_words_list"
|
3
|
+
require "find_keywords/find_keywords_string"
|
2
4
|
|
3
5
|
module FindKeywords
|
4
|
-
|
5
|
-
STOP_WORDS = [
|
6
|
-
'a','cannot','into','our','thus','about','co','is','ours','to','above',
|
7
|
-
'could','it','ourselves','together','across','down','its','out','too',
|
8
|
-
'after','during','itself','over','toward','afterwards','each','last','own',
|
9
|
-
'towards','again','eg','latter','per','under','against','either','latterly',
|
10
|
-
'perhaps','until','all','else','least','rather','up','almost','elsewhere',
|
11
|
-
'less','same','upon','alone','enough','ltd','seem','us','along','etc',
|
12
|
-
'many','seemed','very','already','even','may','seeming','via','also','ever',
|
13
|
-
'me','seems','was','although','every','meanwhile','several','we','always',
|
14
|
-
'everyone','might','she','well','among','everything','more','should','were',
|
15
|
-
'amongst','everywhere','moreover','since','what','an','except','most','so',
|
16
|
-
'whatever','and','few','mostly','some','when','another','first','much',
|
17
|
-
'somehow','whence','any','for','must','someone','whenever','anyhow',
|
18
|
-
'former','my','something','where','anyone','formerly','myself','sometime',
|
19
|
-
'whereafter','anything','from','namely','sometimes','whereas','anywhere',
|
20
|
-
'further','neither','somewhere','whereby','are','had','never','still',
|
21
|
-
'wherein','around','has','nevertheless','such','whereupon','as','have',
|
22
|
-
'next','than','wherever','at','he','no','that','whether','be','hence',
|
23
|
-
'nobody','the','whither','became','her','none','their','which','because',
|
24
|
-
'here','noone','them','while','become','hereafter','nor','themselves','who',
|
25
|
-
'becomes','hereby','not','then','whoever','becoming','herein','nothing',
|
26
|
-
'thence','whole','been','hereupon','now','there','whom','before','hers',
|
27
|
-
'nowhere','thereafter','whose','beforehand','herself','of','thereby','why',
|
28
|
-
'behind','him','off','therefore','will','being','himself','often','therein',
|
29
|
-
'with','below','his','on','thereupon','within','beside','how','once',
|
30
|
-
'these','without','besides','however','one','they','would','between','i',
|
31
|
-
'only','this','yet','beyond','ie','onto','those','you','both','if','or',
|
32
|
-
'though','your','but','in','other','through','yours','by','inc','others',
|
33
|
-
'throughout','yourself','can','indeed','otherwise','thru','yourselves'
|
34
|
-
]
|
35
|
-
|
36
|
-
MARKET_WORDS = [ 'select','styles','shop','reg','orig','set', 'sets', 'offer',
|
37
|
-
'valid','get','free','shipping','double','december','coupon','save','ends',
|
38
|
-
'january','affiliate','exclusive','buy','use','code','size','order','use',
|
39
|
-
'checkout','expires','purchase','just','plus','sales','tax','promo','holiday',
|
40
|
-
'delivery','ca','co','ma','mi','oh','ri','online','members','back','points',
|
41
|
-
'orders'
|
42
|
-
]
|
43
|
-
|
44
6
|
class Keywords
|
45
7
|
|
46
8
|
attr_accessor :sentence
|
9
|
+
attr_reader :keywords
|
47
10
|
|
48
|
-
def initialize (sentence)
|
11
|
+
def initialize (sentence, word_list = "stop_words")
|
49
12
|
if sentence.is_a?(String)
|
50
13
|
@sentence = sentence
|
51
14
|
elsif sentence.is_a?(Array)
|
@@ -54,32 +17,42 @@ module FindKeywords
|
|
54
17
|
@sentence = sentence.collect { |k, v| "#{k} #{v} " }.join
|
55
18
|
else
|
56
19
|
@sentence = ''
|
57
|
-
end
|
20
|
+
end
|
21
|
+
@keywords = find_keywords(@sentence, word_list)
|
58
22
|
end
|
59
23
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
slug
|
24
|
+
private
|
25
|
+
|
26
|
+
def find_keywords(sentence, word_list)
|
27
|
+
slug = sentence.downcase
|
28
|
+
#slug.gsub!(/(\d{2}|\d{1})\/(\d{2}|\d{1})(-|.-.)(\d{2}|\d{1})\/(\d{2}|\d{1})/, "") #add rev 0.0.2 remove date
|
29
|
+
#slug.gsub!(/(sept|oct|nov|dec|jan|feb|mar|apr|may|jun|jul|aug)(\s*)(\d*|)(-|.-.|)/, "") #add rev 0.0.2 remove date
|
64
30
|
slug.gsub! /['`]/,""
|
65
|
-
slug.gsub! /\s
|
66
|
-
slug.gsub! /\s*&\s*/, " and "
|
67
|
-
slug.gsub! /\s*[^A-Za-z0-9\.\-]\s*/, ' '
|
68
|
-
#slug.gsub! /\ \d+/, ''
|
69
|
-
slug.gsub!(/[^a-zA-Z ]/,'')
|
31
|
+
slug.gsub! /\s*[^A-Za-z]\s*/, ' '
|
70
32
|
slug.gsub!(/ +/,' ')
|
71
|
-
|
72
|
-
#slug.gsub! /_+/,"_"
|
73
|
-
#strip off leading/trailing underscore
|
74
|
-
#slug.gsub! /\A[_\.]+|[_\.]+\z/,""
|
33
|
+
slug.gsub!(/^\s|\s$/,'')
|
75
34
|
words = slug.downcase.scan(/\w+/)
|
76
|
-
|
77
|
-
slug_words = slug_words.select { |word| !MARKET_WORDS.include?(word)}
|
78
|
-
slug = slug_words.join(' ')
|
79
|
-
keywords = slug.scan(/\w+/)
|
35
|
+
keywords = words.select { |word| !remove_words(word_list).include?(word) }
|
80
36
|
keywords.delete_if { |word| word.size <= 2 }
|
81
37
|
keywords.uniq! if keywords.uniq
|
82
|
-
|
38
|
+
keywords
|
39
|
+
end
|
40
|
+
|
41
|
+
def remove_words(word_list)
|
42
|
+
case word_list
|
43
|
+
when "stop_words"
|
44
|
+
FindKeywords::RemoveWordsList.stop_words
|
45
|
+
when "all_custom"
|
46
|
+
FindKeywords::RemoveWordsList.all_custom
|
47
|
+
when "all"
|
48
|
+
FindKeywords::RemoveWordsList.all
|
49
|
+
else
|
50
|
+
if word_list.is_a?(FindKeywords::RemoveWordsList)
|
51
|
+
word_list.word_list
|
52
|
+
else
|
53
|
+
FindKeywords::RemoveWordsList.stop_words
|
54
|
+
end
|
55
|
+
end
|
83
56
|
end
|
84
57
|
end
|
85
58
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module FindKeywords
|
2
|
+
STOP_WORDS = [
|
3
|
+
'a','cannot','into','our','thus','about','co','is','ours','to','above',
|
4
|
+
'could','it','ourselves','together','across','down','its','out','too',
|
5
|
+
'after','during','itself','over','toward','afterwards','each','last','own',
|
6
|
+
'towards','again','eg','latter','per','under','against','either','latterly',
|
7
|
+
'perhaps','until','all','else','least','rather','up','almost','elsewhere',
|
8
|
+
'less','same','upon','alone','enough','ltd','seem','us','along','etc',
|
9
|
+
'many','seemed','very','already','even','may','seeming','via','also','ever',
|
10
|
+
'me','seems','was','although','every','meanwhile','several','we','always',
|
11
|
+
'everyone','might','she','well','among','everything','more','should','were',
|
12
|
+
'amongst','everywhere','moreover','since','what','an','except','most','so',
|
13
|
+
'whatever','and','few','mostly','some','when','another','first','much',
|
14
|
+
'somehow','whence','any','for','must','someone','whenever','anyhow',
|
15
|
+
'former','my','something','where','anyone','formerly','myself','sometime',
|
16
|
+
'whereafter','anything','from','namely','sometimes','whereas','anywhere',
|
17
|
+
'further','neither','somewhere','whereby','are','had','never','still',
|
18
|
+
'wherein','around','has','nevertheless','such','whereupon','as','have',
|
19
|
+
'next','than','wherever','at','he','no','that','whether','be','hence',
|
20
|
+
'nobody','the','whither','became','her','none','their','which','because',
|
21
|
+
'here','noone','them','while','become','hereafter','nor','themselves','who',
|
22
|
+
'becomes','hereby','not','then','whoever','becoming','herein','nothing',
|
23
|
+
'thence','whole','been','hereupon','now','there','whom','before','hers',
|
24
|
+
'nowhere','thereafter','whose','beforehand','herself','of','thereby','why',
|
25
|
+
'behind','him','off','therefore','will','being','himself','often','therein',
|
26
|
+
'with','below','his','on','thereupon','within','beside','how','once',
|
27
|
+
'these','without','besides','however','one','they','would','between','i',
|
28
|
+
'only','this','yet','beyond','ie','onto','those','you','both','if','or',
|
29
|
+
'though','your','but','in','other','through','yours','by','inc','others',
|
30
|
+
'throughout','yourself','can','indeed','otherwise','thru','yourselves'
|
31
|
+
]
|
32
|
+
|
33
|
+
MARKET_WORDS = [ 'select','styles','shop','reg','orig','set', 'sets', 'offer',
|
34
|
+
'valid','get','free','shipping','double','december','coupon','save','ends',
|
35
|
+
'january','affiliate','exclusive','buy','use','code','size','order','use',
|
36
|
+
'checkout','expires','purchase','just','plus','sales','tax','promo','holiday',
|
37
|
+
'delivery','ca','co','ma','mi','oh','ri','online','members','back','points',
|
38
|
+
'orders'
|
39
|
+
]
|
40
|
+
|
41
|
+
class RemoveWordsList
|
42
|
+
|
43
|
+
attr_reader :word_list
|
44
|
+
|
45
|
+
@@instance_collector = []
|
46
|
+
|
47
|
+
def initialize (word_list)
|
48
|
+
if word_list.is_a?(String)
|
49
|
+
@word_list = word_list.split(" ")
|
50
|
+
elsif word_list.is_a?(Array)
|
51
|
+
@word_list = word_list
|
52
|
+
elsif word_list.is_a?(Hash)
|
53
|
+
@word_list = word_list.collect { |k, v| "#{k} #{v} " }.join.split(" ")
|
54
|
+
else
|
55
|
+
@word_list = []
|
56
|
+
end
|
57
|
+
@@instance_collector << self
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.all
|
61
|
+
all_custom + stop_words
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.all_custom
|
65
|
+
all_words = []
|
66
|
+
@@instance_collector.each do | words |
|
67
|
+
words.word_list.each do | word |
|
68
|
+
all_words << word
|
69
|
+
end
|
70
|
+
end
|
71
|
+
all_words
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.stop_words
|
75
|
+
STOP_WORDS
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/spec/find_keywords_spec.rb
CHANGED
@@ -1,104 +1,179 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "FindKeywords" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
describe "Keywords" do
|
5
|
+
context "errors" do
|
6
|
+
|
7
|
+
it "requires a string" do
|
8
|
+
expect {FindKeywords::Keywords.new}.to raise_error(ArgumentError)
|
9
|
+
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
it "returns blank on nil input" do
|
12
|
+
sentence = nil
|
13
|
+
keywords = FindKeywords::Keywords.new(sentence).keywords
|
14
|
+
expect(keywords).to eq([])
|
15
|
+
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
it "splits an array to string" do
|
18
|
+
sentence = ["the", "fox", "shoes"]
|
19
|
+
keywords = FindKeywords::Keywords.new(sentence).keywords
|
20
|
+
expect(keywords).to eq(["fox", "shoes"])
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
it "convert hash to string" do
|
24
|
+
sentence = { the: "big dog", animal: "fox", wears: "shoes" }
|
25
|
+
keywords = FindKeywords::Keywords.new(sentence).keywords
|
26
|
+
expect(keywords).to eq(["big", "dog", "animal", "fox", "wears", "shoes"])
|
27
|
+
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
it "retuns no key words for numbers" do
|
30
|
+
sentence = 567
|
31
|
+
keywords = FindKeywords::Keywords.new(sentence).keywords
|
32
|
+
expect(keywords).to eq([])
|
33
|
+
end
|
33
34
|
end
|
34
|
-
end
|
35
35
|
|
36
|
-
|
36
|
+
context "remove unneeded characters" do
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
it "removes symbols @ and &" do
|
45
|
-
sentence = "@kirk & jarvis"
|
46
|
-
keywords = FindKeywords::Keywords.new(sentence).keywords
|
47
|
-
expect(keywords).to eq(['kirk', 'jarvis'])
|
48
|
-
end
|
38
|
+
it "removes $ % inside words" do
|
39
|
+
sentence = "The $100 savings$20 cashback save%20 now"
|
40
|
+
keywords = FindKeywords::Keywords.new(sentence).keywords
|
41
|
+
expect(keywords).to eq(["savings", "cashback", "save"])
|
42
|
+
end
|
49
43
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
44
|
+
it "removes apostrophes" do
|
45
|
+
sentence = "Kirk's"
|
46
|
+
keywords = FindKeywords::Keywords.new(sentence).keywords
|
47
|
+
expect(keywords).to eq(['kirks'])
|
48
|
+
end
|
49
|
+
|
50
|
+
it "removes symbols @ and &" do
|
51
|
+
sentence = "@kirk & jarvis"
|
52
|
+
keywords = FindKeywords::Keywords.new(sentence).keywords
|
53
|
+
expect(keywords).to eq(['kirk', 'jarvis'])
|
54
|
+
end
|
61
55
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
56
|
+
it "replace all non alphanumeric, underscore or periods with blank" do
|
57
|
+
sentence = "@kirk & jarvis_ the ship. $ %"
|
58
|
+
keywords = FindKeywords::Keywords.new(sentence).keywords
|
59
|
+
expect(keywords).to eq(['kirk', 'jarvis', 'ship'])
|
60
|
+
end
|
61
|
+
|
62
|
+
it "replace all numbers with nothing" do
|
63
|
+
sentence = "@kirk & jarvis_ the ship. $ 20 %"
|
64
|
+
keywords = FindKeywords::Keywords.new(sentence).keywords
|
65
|
+
expect(keywords).to eq(['kirk', 'jarvis', 'ship'])
|
66
|
+
end
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
it "downcases all words" do
|
69
|
+
sentence = "@kirk & JARVIS_ the ship. $ 20 %"
|
70
|
+
keywords = FindKeywords::Keywords.new(sentence).keywords
|
71
|
+
expect(keywords).to eq(['kirk', 'jarvis', 'ship'])
|
72
|
+
end
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
it "removes stop words" do
|
75
|
+
sentence = "The quick brown fox jump over the lazy dog."
|
76
|
+
keywords = FindKeywords::Keywords.new(sentence).keywords
|
77
|
+
expect(keywords).to eq(["quick", "brown", "fox", "jump", "lazy", "dog"])
|
78
|
+
end
|
79
|
+
|
80
|
+
it "removes industry specific words" do
|
81
|
+
industry_specific_words= FindKeywords::RemoveWordsList.new(%w(free shipping members for))
|
82
|
+
sentence = "free shipping For women members"
|
83
|
+
keywords = FindKeywords::Keywords.new(sentence, industry_specific_words).keywords
|
84
|
+
expect(keywords).to eq(["women"])
|
85
|
+
end
|
86
|
+
|
87
|
+
it "removes duplicutes" do
|
88
|
+
sentence = "women women women"
|
89
|
+
keywords = FindKeywords::Keywords.new(sentence).keywords
|
90
|
+
expect(keywords).to eq(["women"])
|
91
|
+
end
|
79
92
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
93
|
+
it "removes words less than 2 characters" do
|
94
|
+
sentence = "ta vg the game"
|
95
|
+
keywords = FindKeywords::Keywords.new(sentence).keywords
|
96
|
+
expect(keywords).to eq(["game"])
|
97
|
+
end
|
98
|
+
|
99
|
+
it "removes leading and trailing underscore" do
|
100
|
+
sentence = "_the yellow__jeans_"
|
101
|
+
keywords = FindKeywords::Keywords.new(sentence).keywords
|
102
|
+
expect(keywords).to eq(["yellow", "jeans"])
|
103
|
+
end
|
104
|
+
|
105
|
+
it "removes date Oct - 25 and specific removal list" do
|
106
|
+
industry_specific_words = FindKeywords::RemoveWordsList.new(%w(code with sept oct))
|
107
|
+
sentence = "Dana Buchman Apparel with code DANA10. Sept 24 – Oct 4 10-20-2014"
|
108
|
+
keywords = FindKeywords::Keywords.new(sentence, industry_specific_words).keywords
|
109
|
+
expect(keywords).to eq(["dana", "buchman", "apparel"])
|
110
|
+
end
|
111
|
+
end
|
112
|
+
context "with custom and stop word removal lists" do
|
113
|
+
context "all_custom" do
|
114
|
+
it "only removes words from multiple remove word lists" do
|
115
|
+
industry_specific_words = FindKeywords::RemoveWordsList.new(%w(class with))
|
116
|
+
simple_words = FindKeywords::RemoveWordsList.new(%w(this a is means))
|
117
|
+
sentence = "This means that a class definition is executed with that class"
|
118
|
+
keywords = FindKeywords::Keywords.new(sentence, "all_custom").keywords
|
119
|
+
expect(keywords).to eq(["that", "definition", "executed"])
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context "all - both custon and stop words list" do
|
124
|
+
it "removes words from multiple remove word lists and stop words list" do
|
125
|
+
industry_specific_words = FindKeywords::RemoveWordsList.new(%w(gem parsing))
|
126
|
+
simple_words = FindKeywords::RemoveWordsList.new(%w(please note using simple))
|
127
|
+
sentence = "Please note that this gem is using an extremely simple language natural processor, so parsing is not perfect, but it works."
|
128
|
+
keywords = FindKeywords::Keywords.new(sentence, "all").keywords
|
129
|
+
expect(keywords).to eq(["extremely", "language", "natural", "processor", "perfect", "works"])
|
130
|
+
end
|
131
|
+
end
|
84
132
|
end
|
85
133
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
134
|
+
end
|
135
|
+
describe "RemoveWordsList" do
|
136
|
+
describe ".stop_words" do
|
137
|
+
let(:words) { FindKeywords::RemoveWordsList.stop_words }
|
138
|
+
it "returns array of stop words" do
|
139
|
+
expect(words).to be_kind_of(Array)
|
140
|
+
end
|
141
|
+
|
142
|
+
it "last word is yourselves" do
|
143
|
+
expect(words.last).to eq("yourselves")
|
144
|
+
end
|
90
145
|
end
|
91
146
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
147
|
+
describe ".word_list" do
|
148
|
+
let(:words) { FindKeywords::RemoveWordsList.new(%w(the is a and know)) }
|
149
|
+
|
150
|
+
it "returns word list" do
|
151
|
+
expect(words.word_list.last).to eq("know")
|
152
|
+
end
|
96
153
|
end
|
97
154
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
155
|
+
describe ".all_custom" do
|
156
|
+
before do
|
157
|
+
FindKeywords::RemoveWordsList.new(%w(the is a and know))
|
158
|
+
FindKeywords::RemoveWordsList.new(%w(easiest way to mnemonically))
|
159
|
+
FindKeywords::RemoveWordsList.new(%w(Can you point me))
|
160
|
+
end
|
161
|
+
|
162
|
+
it "returns array of all words" do
|
163
|
+
expect(FindKeywords::RemoveWordsList.all_custom).to be_kind_of(Array)
|
164
|
+
end
|
165
|
+
|
166
|
+
it "last word is yourselves" do
|
167
|
+
expect(FindKeywords::RemoveWordsList.all_custom.last).to eq("me")
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe "find_keywords_string" do
|
173
|
+
describe ".keywords" do
|
174
|
+
it "returns keywords from string" do
|
175
|
+
expect("the is a and know".keywords).to eq(["know"])
|
176
|
+
end
|
102
177
|
end
|
103
178
|
end
|
104
179
|
end
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: find_keywords
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirk Jarvis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '3.1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '3.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Finds keywords in a sentence. Uses a stop word list and market word
|
@@ -74,14 +74,16 @@ executables: []
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
-
- .gitignore
|
78
|
-
- .rspec
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
79
|
- Gemfile
|
80
80
|
- LICENSE.txt
|
81
81
|
- README.md
|
82
82
|
- Rakefile
|
83
83
|
- find_keywords.gemspec
|
84
84
|
- lib/find_keywords.rb
|
85
|
+
- lib/find_keywords/find_keywords_string.rb
|
86
|
+
- lib/find_keywords/remove_words_list.rb
|
85
87
|
- lib/find_keywords/version.rb
|
86
88
|
- spec/find_keywords_spec.rb
|
87
89
|
- spec/spec_helper.rb
|
@@ -95,17 +97,17 @@ require_paths:
|
|
95
97
|
- lib
|
96
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
99
|
requirements:
|
98
|
-
- -
|
100
|
+
- - ">="
|
99
101
|
- !ruby/object:Gem::Version
|
100
102
|
version: '0'
|
101
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
104
|
requirements:
|
103
|
-
- -
|
105
|
+
- - ">="
|
104
106
|
- !ruby/object:Gem::Version
|
105
107
|
version: '0'
|
106
108
|
requirements: []
|
107
109
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.4.6
|
109
111
|
signing_key:
|
110
112
|
specification_version: 4
|
111
113
|
summary: Finds keywords in a sentence
|