Sha256: 41d615a3dc68a9c72e9726680deec04d20cf37284ca249b972c94f1511803611

Contents?: true

Size: 337 Bytes

Versions: 6

Compression:

Stored size: 337 Bytes

Contents

module Semantic
  class Compare

    class << self
      
      def similarity(vector1, vector2)
        cosine(vector1, vector2)
      end
      
      def cosine(vector1, vector2)
        unless vector2.nil? or vector1.nil?
          (vector2.dot(vector1)) / (vector1.norm * vector2.norm)
        end
      end

    end
    
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
josephwilk-rsemantic-0.1.0 lib/semantic/compare.rb
josephwilk-rsemantic-0.1.1 lib/semantic/compare.rb
josephwilk-rsemantic-0.1.2 lib/semantic/compare.rb
josephwilk-rsemantic-0.1.3 lib/semantic/compare.rb
josephwilk-semantic-0.1.0 lib/semantic/compare.rb
rsemantic-0.1.3 lib/semantic/compare.rb