adjust spell correction threshold, a=chris

Chris Pollett [2013-01-01 04:Jan:st]
adjust spell correction threshold, a=chris
Filename
scripts/suggest.js
views/search_view.php
diff --git a/scripts/suggest.js b/scripts/suggest.js
index bef9e7e65..1f7d93838 100644
--- a/scripts/suggest.js
+++ b/scripts/suggest.js
@@ -257,17 +257,29 @@ function onTypeTerm(event, text_field)
  */
 function correctSpelling(word)
 {
-    var prob=0,ret_array,curr_prob=0;
+    var prob = 0;
+
+    ret_array = exist(dictionary, word);
+    if(ret_array != false) {
+        prob = parseInt(ret_array[END_OF_TERM_MARKER]);
+    }
+
+    var ret_array;
+    var curr_prob = 0;
     var candidates = known(edits1(word));
+
     candidates.push(word);
     var corrected_word = "";
-    // Use the fequencies to get the best match
-    for(var i=0;i<candidates.length;i++) {
+    var correct_threshold = 25;
+
+    // Use the frequencies to get the best match
+    for(var i = 0; i < candidates.length; i++) {
         ret_array = exist(dictionary, candidates[i]);
         if(ret_array != false) {
             curr_prob = parseInt(ret_array[END_OF_TERM_MARKER]);
         }
-        if (curr_prob > prob) {
+        if (curr_prob > correct_threshold * prob) {
+            correct_threshold = 1;
             prob = curr_prob;
             corrected_word = candidates[i];
         }
diff --git a/views/search_view.php b/views/search_view.php
index 0b3064d64..9cdcc3b07 100755
--- a/views/search_view.php
+++ b/views/search_view.php
@@ -285,7 +285,6 @@ class SearchView extends View implements CrawlConstants
                     }
                     if(IP_LINK && isset($page[self::IP_ADDRESSES])){
                     foreach($page[self::IP_ADDRESSES] as $address) {?>
-
                     <a href="?<?php e(CSRF_TOKEN."=".$data[CSRF_TOKEN]);
                             ?>&amp;c=search&amp;q=<?php
                             e(urlencode('ip:'.$address));?>&amp;<?php
@@ -346,4 +345,4 @@ class SearchView extends View implements CrawlConstants

     }
 }
-?>
\ No newline at end of file
+?>
ViewGit