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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6eb718b2a534b20dca7e09ee120890ec77bfa1b
4
- data.tar.gz: cb754ff99ce1064afeeac4d26276b3962cbd849d
3
+ metadata.gz: 4871337596b21ca140b55367a0aabd82266c0963
4
+ data.tar.gz: ca7d1e8e233bded6f53c3a08d10474fe061150ba
5
5
  SHA512:
6
- metadata.gz: ecadae7d7b8976ffc1546b34781218d3f573d30491f6501ae5b140931cf4a31516964a4eff2bb63af1bf31b45cc2b98000608dc1f9689e72132a573eb3838657
7
- data.tar.gz: a6de7e1c5efdc3f3dc960420ba66ab31d7940cdbd616f82c006241e65382f1320098aa149840adb7a76ca44ef862a9a803a6b153a7587aabb710f7d5687940c7
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{|a| "#{spacer}#{self.escape_regex_chars(a.gsub(' ', ' '))}#{spacer}"}.join("|")
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 +false+
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 = {
@@ -1,3 +1,3 @@
1
1
  module KeywordFinder
2
- VERSION = "0.3"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keyword_finder
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - murb