app/libs/vsm.js
/*
 To calculate the relevance of a query to a document, we need the
 weight vector for both the query and document (see comment at top of
 file for calculation). Due to not having negative occurrences, the
 result of this method should be between 0 (no matches) and 1 (exactly
 the same)
 */
To calculate the relevance of a query to a document, we need the
weight vector for both the query and document (see comment at top of
file for calculation). Due to not having negative occurrences, the
result of this method should be between 0 (no matches) and 1 (exactly
the same)
To calculate the relevance of a query to a document we need the weight vector for both the query and document ( see comment at top of file for calculation ) . Due to not having negative occurrences the result of this method should be between 0 ( no matches ) and 1 ( exactly the same )
function calculateRelevance(documentWeightVector, queryWeightVector) {
    documentWeightVector = documentWeightVector.weights;
    var dot = math.dot(documentWeightVector, queryWeightVector);
    var docVectorLength = sizeHelper(documentWeightVector);
    var queryVectorLength = sizeHelper(queryWeightVector);
    var denom = docVectorLength * queryVectorLength;
    if(denom === 0){
        return 0;
    } else {
        return dot / denom;
    }
}
function calculateRelevance ( documentWeightVector , queryWeightVector ) { documentWeightVector = documentWeightVector . weights ; var dot = math . dot ( documentWeightVector , queryWeightVector ) ; var docVectorLength = sizeHelper ( documentWeightVector ) ; var queryVectorLength = sizeHelper ( queryWeightVector ) ; var denom = docVectorLength * queryVectorLength ; if ( denom === 0 ) { return 0 ; } else { return dot / denom ; } }
To calculate the relevance of a query to a document, we need the
weight vector for both the query and document (see comment at top of
file for calculation).
To calculate the relevance of a query to a document we need the weight vector for both the query and document ( see comment at top of file for calculation ) .