Sha256: 26cf314c5f89765962778446c9370f5f35af0104d6119acaabb9dc5a6b7ee26c

Contents?: true

Size: 323 Bytes

Versions: 37

Compression:

Stored size: 323 Bytes

Contents

module SuggestTag
  def suggest_tags
    tags = []
    threshold = (self.strip.split(//).size * 0.2).round
    Bookmark.tag_counts(:limit => 100).each do |t|
      distance = Text::Levenshtein.distance(t.name, self)
      tags << t if distance <= threshold
    end
    tags
  end
end

class String
  include SuggestTag
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
enju_bookmark-0.2.2 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.2.1 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.2.0 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.2.0.beta.5 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.2.0.beta.3 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.2.0.beta.2 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.2.0.beta.1 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.1.3 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.1.2 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.1.2.pre23 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.1.2.pre22 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.1.2.pre21 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.1.2.pre20 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.1.2.pre19 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.1.2.pre18 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.1.2.pre17 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.1.2.pre16 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.1.2.pre15 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.1.2.pre14 lib/enju_bookmark/suggest_tag.rb
enju_bookmark-0.1.2.pre13 lib/enju_bookmark/suggest_tag.rb