lib/nlp_arabic/acts_as_document.rb
#To calculate weights vector of query
To calculate weights vector of query
To calculate weights vector of query
def weights (tf,syn_hash=nil)
        w = {}
        docs_count = self.count
        df = self.document_freq_of_terms(tf.keys)
        tf.each_pair { |term,freq|
          w[term] = (freq *  Math.log(docs_count.to_f / (1+ df[term]) ))
          if !syn_hash.nil?
            if !syn_hash[term].nil?
              w[term] *= syn_hash[term]
            end
          end
        }
        return w
      end
def weights ( tf , syn_hash = nil ) w = { } docs_count = self . count df = self . document_freq_of_terms ( tf . keys ) tf . each_pair { | term , freq | w [ term ] = ( freq * Math . log ( docs_count . to_f / ( 1 + df [ term ] ) ) ) if ! syn_hash . nil? if ! syn_hash [ term ] . nil? w [ term ] *= syn_hash [ term ] end end } return w end
To calculate weights vector of query
To calculate weights vector of query
tf
<not_specific>
syn_hash
<not_specific>