/*
  * Instead of looking at every term across all documents,
  * only look at the terms in the query, because all other terms
  * will be 0, resulting in q*d=0.
  * Typically the number of terms in a query is less than
  * the number of terms in a document.
  */
 private static double ComputeProduct(DocumentVector query, NormalizedVector doc)
 {
     double val = 0;
     foreach (KeyValuePair<string, int> term in query)
     {
         double d;
         doc.TryGetValue(term.Key, out d);
         val += term.Value * d;
     }
     return val;
 }
Пример #2
0
        /*
         * Instead of looking at every term across all documents,
         * only look at the terms in the query, because all other terms
         * will be 0, resulting in q*d=0.
         * Typically the number of terms in a query is less than
         * the number of terms in a document.
         */
        private static double ComputeProduct(DocumentVector query, NormalizedVector doc)
        {
            double val = 0;

            foreach (KeyValuePair <string, int> term in query)
            {
                double d;
                doc.TryGetValue(term.Key, out d);
                val += term.Value * d;
            }
            return(val);
        }