﻿//定义干扰词列表
 var strNwall =",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,";
	  strNwall+="p,q,r,s,t,u,v,w,x,y,z,after,all,also,";
      strNwall+="an,and,another,any,are,as,at,be,because,been,";
      strNwall+="before,being,between,both,but,by,came,can,come,";
      strNwall+="could,did,do,each,for,from,get,got,had,has,";
      strNwall+="have,he,her,here,him,himself,his,how,if,in,into,";
      strNwall+="is,it,like,make,many,me,might,more,most,much,must,";
      strNwall+="my,never,now,of,on,only,or,other,our,out,over,said,";
      strNwall+="same,see,should,since,some,still,such,take,than,that,";
      strNwall+="the,their,them,then,there,these,they,this,those,through,";
      strNwall+="to,too,under,up,very,was,way,we,well,were,what,where,";
      strNwall+="which,while,who,with,would,you,your,";
      strNwall+="的,一,不,在,人,有,是,为,以,于,上,他,而,后,之,来,";
      strNwall+="及,了,因,下,可,到,由,这,与,也,此,但,并,个,其,已,";
      strNwall+="无,小,我,们,起,最,再,今,去,好,只,又,或,很,亦,某,";
      strNwall+="把,那,你,乃,它,";
      strNwall="\,+,-,!,(,),:,^,[,],{,},~,*,?";
String.prototype.trim = function () {
	return this.replace(/^\s*|\s*$/g,'');
};
function isNw(strKw)
{
	//判断是否是干扰词
	if(strKw=="") 
          return false
	var sKw=strKw.toLowerCase();
	if(strNwall.indexOf(","+sKw+",")==-1)
	{
		return false;
	}
	else
	{
		return true;
	}
}
function remove_noise_word(strKw)
{
	//去掉干扰词,',/,:,;,!,.,?
	var strTmp=strKw;
	//去掉标点符号
	strTmp=strTmp.replace(/[,]+/g," ");
	strTmp=strTmp.replace(/[-]+/g," ");
	strTmp=strTmp.replace(/[(]+/g," ");
	strTmp=strTmp.replace(/[)]+/g," ");
	strTmp=strTmp.replace(/[.]+/g," ");
	strTmp=strTmp.replace(/[!]+/g," ");
	strTmp=strTmp.replace(/[/]+/g," ");
	strTmp=strTmp.replace(/[\\]+/g," ");
	strTmp=strTmp.replace(/[:]+/g," ");
	strTmp=strTmp.replace(/[;]+/g," ");
	strTmp=strTmp.replace(/[']+/g," ");
	strTmp=strTmp.replace(/[?]+/g," ");
	strTmp=strTmp.replace(/\"/g," ");

	var arr;
	arr=strTmp.split(" ");
	var strReturn="";
	for(i=0;i<arr.length;i++){
		if(!isNw(arr[i])&&arr[i]!=""&&arr[i]!=" "){
			//不是干扰词
			strReturn=strReturn+" "+arr[i];
		}
	}
	return strReturn.trim()
}

