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)
| 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 |