--- drupal-6/patch/autotagging/autotagging.module	2009-07-24 19:38:20.000000000 +0200
+++ drupal-6/www/sites/all/modules/autotagging/autotagging.module	2010-09-27 15:36:35.000000000 +0200
@@ -48,7 +48,8 @@ function autotagging_nodeapi(&$node, $op
       //
       $text = array();
       $text[] = $node->title;
-      $text[] = str_replace("\n", ' ', $node->body);
+      $text[] = strip_tags( str_replace("\n", ' ', $node->body) );
+      
       $text = implode(' ', $text);
       $ignore_setting = variable_get('autotagging_error_handling', 'Defer');
       foreach (module_implements('autotagging_api_' . $op) as $module_name) {
@@ -61,10 +62,12 @@ function autotagging_nodeapi(&$node, $op
             break;
           }
         }
+
         if (isset($terms) && is_array($terms) && !empty($terms)) {
           // find the vocabulary with which to associate these terms
           //
           foreach ($terms as $vid => $termlist) {
+
             if (empty($node->taxonomy['tags'][$vid])) {
               $node->taxonomy['tags'][$vid] = implode(', ', $termlist);
             } 
@@ -74,13 +77,38 @@ function autotagging_nodeapi(&$node, $op
           }
         }
       }
+
+      $stop_words =  variable_get('autotagging_stop_words', "");
+      $stop_words = array_map( "trim",  explode("\r\n", $stop_words) );
+
+      // refresh taxonomy tags
+      foreach($node->taxonomy['tags'] as $vid => $termlist){
+	if(strlen($termlist) > 0){
+	  
+	  $a_termlist = array_map( "trim", explode(',', $termlist));
+	  $a_termlist = array_values(array_map( "strtolower", $a_termlist));
+
+	  $stop_words = array_values( array_map( "strtolower", $stop_words));
+
+	  $a_termlist = array_diff( $a_termlist, $stop_words);
+	  $a_termlist = array_unique($a_termlist);
+
+	  $node->taxonomy['tags'][$vid] = implode( ',', $a_termlist );
+	}
+      }
+
+
+//       var_dump($node->taxonomy['tags']);die();
+
       // allows modules to act on terms before they're saved.
       module_invoke_all('autotagging_api_presave', $node, $terms);
       taxonomy_node_save($node, $node->taxonomy);
+
       break;
   }
 }
 
+
 function autotagging_requirements($phase) {
   switch ($phase) {
     case 'install':
@@ -97,3 +125,4 @@ function autotagging_requirements($phase
       break;
   }
 }
+
