function jh(str) { document.getElementById("software").innerHTML = document.getElementById(str).innerHTML document.getElementById("programme").innerHTML = document.getElementById(str+"1").innerHTML }
论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > Sql Server教程
Tag:注入,存储过程,分页,安全,优化,加密,索引,日志,压缩,base64,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,触发器,socket,安装,sqlserver2000,sqlserver2005,sqlserver2008,视频教程

如何将全文检索中的“干扰词”去除

文章类别:Sql Server | 发表日期:2008-10-5 21:36:18

包括以下内容,然后调用:remove_noise_word()即可www.9246369chinai tp ow er.comzkJky

 www.9246369chinai tp ow er.comzkJky

<SCRIPT LANGUAGE=javascript>
<!--
  noise_word_list_ch = new Array("?","about","$","1","2","3","4","5","6","7","8","9","0","_",
        "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o",
        "p","q","r","s","t","u","v","w","x","y","z","after","all","also",
        "an","and","another","any","are","as","at","be","because","been",
        "before","being","between","both","but","by","came","can","come",
        "could","did","do","each","for","from","get","got","had","has",
        "have","he","her","here","him","himself","his","how","if","in","into",
        "is","it","like","make","many","me","might","more","most","much","must",
        "my","never","now","of","on","only","or","other","our","out","over","said",
        "same","see","should","since","some","still","such","take","than","that",
        "the","their","them","then","there","these","they","this","those","through",
        "to","too","under","up","very","was","way","we","well","were","what","where",
        "which","while","who","with","would","you","your",
        "的","一","不","在","人","有","是","为","以","于","上","他","而","后","之","来",
        "及","了","因","下","可","到","由","这","与","也","此","但","并","个","其","已",
         "无","小","我","们","起","最","再","今","去","好","只","又","或","很","亦","某",
        "把","那","你","乃","它"); www.9246369chinai tp ow er.comzkJky

function trim_str_key(inputVal){
 inputStr = inputVal.toString()
 while ((inputStr.charAt(inputStr.length - 1) == " ") || (inputStr.charAt(0) == " ")){     www.9246369chinai tp ow er.comzkJky

    //如果最右边为空格则删去
    if (inputStr.charAt(inputStr.length - 1) == " "){
         inputStr = inputStr.substring(0,inputStr.length - 1)
    }
    //如果最左边为空格则删去
    if (inputStr.charAt(0) == " "){
       inputStr = inputStr.substring(1,inputStr.length)
    }
 }
 return inputStr
}www.9246369chinai tp ow er.comzkJky

function is_ch_noise_word(str_key){
   var key_word = trim_str_key(str_key);
   key_word = key_word.toLowerCase();
   var listlength=noise_word_list_ch.length;
   var tmp_str = "";
   for(i=0;i<listlength;i++){
      tmp_str = noise_word_list_ch[i]
      if(tmp_str==key_word){ 
         return true;
      }
   }
   return false;
www.9246369chinai tp ow er.comzkJky

function remove_noise_word(str_source){
  var tmp_str = "";
  var ch = "";
  var str_out = "";
  var i = 0;
  str_source = trim_str_key(str_source); 
  var str_source_length = str_source.length;
 
  if(str_source_length == 0){
    return str_out;
  }
  
  for (i=0;i < str_source_length; i++){ 
    ch = str_source.charAt(i);
    if(ch==" "){ //如果为空格则表示是下一个关键词
  if(!(is_ch_noise_word(tmp_str))){ //不是干扰词就输出
     if(tmp_str!=" "){  //防止连续的两个空格
       str_out = str_out + tmp_str + " ";
     } 
  }
  tmp_str = "";
    }
    else{
       tmp_str = tmp_str + ch;
    }
  }
  str_out = str_out + tmp_str;   
  return trim_str_key(str_out); 
}www.9246369chinai tp ow er.comzkJky

//下面是一个测试
//var abc = "av  n";
//var nnnn = remove_noise_word(abc);
//alert(nnnn);
//-->
</SCRIPT>
www.9246369chinai tp ow er.comzkJky

上一篇:{技巧}实用的存储过程之一 人气:1817
下一篇:{技巧}实用的存储过程之二 人气:1662
视频教程列表
文章教程搜索
 
Sql Server推荐教程
Sql Server热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058