Sha256: cb7ad6136eff1ab9a4f266df16bdc41cac35ce3f7cfd54e05ba9466ae564602f
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
# encoding: UTF-8 require File.dirname(__FILE__) + '/base' module OmniCat class Doc < ::OmniCat::Base attr_reader :content, :count, :tokens def initialize(doc_hash = {}) @content = doc_hash[:content] @count = (doc_hash[:count] || 1).to_i @tokens = tokenize_with_counts unless @tokens.is_a?(Hash) end def increment_count @count += 1 end def decrement_count @count -= 1 if @count > 0 end private # nodoc def minus_tokens body = @content OmniCat.config.token_patterns[:minus].each { |p| body.gsub!(p, ' ') } body end # nodoc def plus_tokens(body) body_tokens = [] OmniCat.config.token_patterns[:plus].each { |p| body_tokens += body.scan(p) } body_tokens end # nodoc def exclude_tokens OmniCat.config.exclude_tokens end # nodoc def tokenize_with_counts tokenize.hashify_with_counts end # nodoc def tokenize plus_tokens(minus_tokens) - exclude_tokens end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
omnicat-0.2.2 | lib/omnicat/doc.rb |
omnicat-0.2.1 | lib/omnicat/doc.rb |
omnicat-0.2.0 | lib/omnicat/doc.rb |