_binary From c8db4d93f2fd23bde3be458253372ad574198f6b Mon Sep 17 00:00:00 2001
From: Shailesh Padave <shaileshpadave49@gmail.com>
Date: Wed, 28 May 2014 22:01:52 -0700
Subject: [PATCH] Modified cosine ranking function

---
 lib/wordnet.php | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/wordnet.php b/lib/wordnet.php
index 07c9228..47f5f8c 100644
--- a/lib/wordnet.php
+++ b/lib/wordnet.php
@@ -271,7 +271,8 @@ class WordNet
         $cnt_sentB = 0;
         $arrayA = array();
         $arrayB = array();
-        $x = 0;
+        $resA = 0;
+        $resB = 0;
         $merged_words = array_unique(array_merge($sentenceA, $sentenceB));
         foreach ($sentenceA as $word) {
             $arrayA[$word] = 0;
@@ -283,11 +284,11 @@ class WordNet
             $resA = isset($arrayA[$word]) ? 1 : 0;
             $resB = isset($arrayB[$word]) ? 1 : 0;
             $result += $resA * $resB;
-            $cnt_sentA += $x;
+            $cnt_sentA += $resA;
             $cnt_sentB += $resB;
         }
         $score = ($cnt_sentA * $cnt_sentB) != 0 ?
-            $result / sqrt($normA * $cnt_sentB) : 0;
+            $result / sqrt($cnt_sentA * $cnt_sentB) : 0;
         return $score;
     }
     /**
-- 
1.8.4.msysgit.0

