MCPcopy Index your code
hub / github.com/clips/pattern / cosine_similarity

Method cosine_similarity

pattern/vector/__init__.py:574–582  ·  view source on GitHub ↗

Returns the similarity between the two documents as a number between 0.0-1.0. If both documents are part of the same model the calculations are cached for reuse.

(self, document)

Source from the content-addressed store, hash-verified

572 return v
573
574 def cosine_similarity(self, document):
575 """ Returns the similarity between the two documents as a number between 0.0-1.0.
576 If both documents are part of the same model the calculations are cached for reuse.
577 """
578 if self.model is not None:
579 return self.model.cosine_similarity(self, document)
580 if document.model is not None:
581 return document.model.cosine_similarity(self, document)
582 return cosine_similarity(self.vector, document.vector)
583
584 similarity = cosine_similarity
585

Callers 1

Calls 2

cosine_similarityFunction · 0.85
cosine_similarityMethod · 0.45

Tested by 1