vector_space_model/Int/VSM-master/vsm.py
def similarity(query,id):
    """Returns the cosine similarity between query and document id.
    Note that we don't bother dividing by the length of the query
    vector, since this doesn't make any difference to the ordering of
    search results."""
    similarity = 0.0
    for term in query:
        if term in dictionary:
            similarity += inverse_document_frequency(term)*imp(term,id)
    similarity = similarity / length[id]
    return similarity
Returns the cosine similarity between query and document id.
    Note that we don't bother dividing by the length of the query
    vector, since this doesn't make any difference to the ordering of
    search results.
Returns the cosine similarity between query and document id.
Note that we don't bother dividing by the length of the query
vector, since this doesn't make any difference to the ordering of
search results.
Returns the cosine similarity between query and document id . Note that we don ' t bother dividing by the length of the query vector since this doesn ' t make any difference to the ordering of search results .
def similarity(query,id):
    similarity = 0.0
    for term in query:
        if term in dictionary:
            similarity += inverse_document_frequency(term)*imp(term,id)
    similarity = similarity / length[id]
    return similarity
def similarity ( query , id ) : similarity = 0.0 for term in query : if term in dictionary : similarity += inverse_document_frequency ( term ) * imp ( term , id ) similarity = similarity / length [ id ] return similarity
Returns the cosine similarity between query and document id.
Returns the cosine similarity between query and document id .
"""Returns the cosine similarity between query and document id.
    Note that we don't bother dividing by the length of the query
    vector, since this doesn't make any difference to the ordering of
    search results."""
query
id