Class: Semantic::Compare
- Inherits:
-
Object
- Object
- Semantic::Compare
- Defined in:
- lib/semantic/compare.rb
Class Method Summary collapse
Class Method Details
.cosine(vector1, vector2) ⇒ Object
10 11 12 13 14 |
# File 'lib/semantic/compare.rb', line 10 def cosine(vector1, vector2) unless vector2.nil? or vector1.nil? (vector2.dot(vector1)) / (vector1.norm * vector2.norm) end end |
.similarity(vector1, vector2) ⇒ Object
6 7 8 |
# File 'lib/semantic/compare.rb', line 6 def similarity(vector1, vector2) cosine(vector1, vector2) end |