keyword_finder 0.3 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/keyword_finder/keywords.rb +6 -2
- data/lib/keyword_finder/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4871337596b21ca140b55367a0aabd82266c0963
|
4
|
+
data.tar.gz: ca7d1e8e233bded6f53c3a08d10474fe061150ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3eb9cc1e258421a77fc8c61e0c213b8152ea70fa376b4b61ded9515980277b0252f34d5e1ffde618b21015d9e162096c2e86662fb4dce0598a12c390201a23d
|
7
|
+
data.tar.gz: 41b3272b88725e83fa821f69056213a2a84af78028b20713dce1f54cfd49fee838b4601ad9f3fc993a76e393980eb60b60b347f5c81db0c8bab11aa90d173c88
|
@@ -12,7 +12,11 @@ module KeywordFinder
|
|
12
12
|
spacer = options[:entire_words_only] ? "\\s" : ""
|
13
13
|
@to_regex = {} unless defined?(@to_regex)
|
14
14
|
@to_regex[options[:entire_words_only]] ||= Regexp.new("(#{
|
15
|
-
self.ordered_by_length.collect
|
15
|
+
self.ordered_by_length.collect do |a|
|
16
|
+
a_spacer = spacer
|
17
|
+
a_spacer = "" if (options[:entire_words_only] == :when_short and a.length > 3)
|
18
|
+
"#{a_spacer}#{self.escape_regex_chars(a.gsub(' ', ' '))}#{a_spacer}"
|
19
|
+
end.join("|")
|
16
20
|
})")
|
17
21
|
end
|
18
22
|
|
@@ -46,7 +50,7 @@ module KeywordFinder
|
|
46
50
|
#
|
47
51
|
#
|
48
52
|
# @param [String] sentence that might contain the keywords this instance was initalized with
|
49
|
-
# @param [Hash] options; notably the +:subsentences_strategy+, which can be one of +:none+, +:ignore_if_found_in_main+, +:always_ignore+ and the +:entire_words_only+ boolean, which can be either +true+ or
|
53
|
+
# @param [Hash] options; notably the +:subsentences_strategy+, which can be one of +:none+, +:ignore_if_found_in_main+, +:always_ignore+ and the +:entire_words_only+ boolean, which can be either +true+, +false+, or :when_short
|
50
54
|
|
51
55
|
def find_in sentence, options={}
|
52
56
|
options = {
|