Example #1
0
 public double cossimDebug(TermVectorDouble v) {
   if (this.size() > v.size()) {
     return v.cossimDebug(this);
   }
   double dotproduct = 0;
   for (Object2DoubleMap.Entry<String> entry : object2DoubleEntrySet()) {
     dotproduct += v.getDouble(entry.getKey()) * entry.getDoubleValue();
     log.info(
         "%s %f %f %s",
         entry.getKey(), v.getDouble(entry.getKey()), entry.getDoubleValue(), dotproduct);
   }
   double magnitude = magnitude() * v.magnitude();
   log.info("magnitude %s %s %s", magnitude(), v.magnitude(), dotproduct / magnitude);
   return (magnitude == 0) ? 0 : dotproduct / magnitude;
 }
Example #2
0
 public double cossim(TermVectorDouble v) {
   double dotproduct = 0;
   for (Object2DoubleMap.Entry<String> entry : object2DoubleEntrySet()) {
     dotproduct += v.getDouble(entry.getKey()) * entry.getValue();
   }
   double magnitude = magnitude() * v.magnitude();
   double result = (magnitude == 0) ? 0 : dotproduct / magnitude;
   return result;
 }