'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.'

def cosine_similarity(self, document):

    if (self.model is not None):
        return self.model.cosine_similarity(self, document)
    if (document.model is not None):
        return document.model.cosine_similarity(self, document)
    return cosine_similarity(self.vector, document.vector)
